mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2024-11-27 14:09:11 -05:00
digital output 'buffer' and fix ifdef
This commit is contained in:
parent
96c05cd532
commit
cac5d0b9ea
@ -21,7 +21,7 @@
|
|||||||
IMPLEMENT_APP(CubicSDR)
|
IMPLEMENT_APP(CubicSDR)
|
||||||
|
|
||||||
// console output buffer for windows
|
// console output buffer for windows
|
||||||
#ifdef _WIN64_
|
#ifdef _WINDOWS
|
||||||
class outbuf : public std::streambuf {
|
class outbuf : public std::streambuf {
|
||||||
public:
|
public:
|
||||||
outbuf() {
|
outbuf() {
|
||||||
@ -51,7 +51,7 @@ bool CubicSDR::OnInit() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// console output for windows
|
// console output for windows
|
||||||
#ifdef _WIN64_
|
#ifdef _WINDOWS
|
||||||
if (AllocConsole()) {
|
if (AllocConsole()) {
|
||||||
freopen("CONOUT$", "w", stdout);
|
freopen("CONOUT$", "w", stdout);
|
||||||
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED);
|
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED);
|
||||||
|
@ -233,12 +233,14 @@ void DemodulatorThread::threadMain() {
|
|||||||
// Reset demodulator Constellations & Lock
|
// Reset demodulator Constellations & Lock
|
||||||
updateDemodulatorCons(0);
|
updateDemodulatorCons(0);
|
||||||
|
|
||||||
|
// create digital output buffer
|
||||||
|
demodOutputDataDigital = new unsigned int[bufSize];
|
||||||
|
|
||||||
if (demodulatorType == DEMOD_TYPE_FM) {
|
if (demodulatorType == DEMOD_TYPE_FM) {
|
||||||
currentDemodLock = false;
|
currentDemodLock = false;
|
||||||
freqdem_demodulate_block(demodFM, &agcData[0], bufSize, &demodOutputData[0]);
|
freqdem_demodulate_block(demodFM, &agcData[0], bufSize, &demodOutputData[0]);
|
||||||
} else {
|
} else {
|
||||||
float p;
|
float p;
|
||||||
unsigned int bitstream;
|
|
||||||
switch (demodulatorType.load()) {
|
switch (demodulatorType.load()) {
|
||||||
case DEMOD_TYPE_LSB:
|
case DEMOD_TYPE_LSB:
|
||||||
currentDemodLock = false;
|
currentDemodLock = false;
|
||||||
@ -262,7 +264,7 @@ void DemodulatorThread::threadMain() {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
// advanced demodulators
|
// advanced demodulators
|
||||||
// tneeds refactoring
|
// needs refactoring
|
||||||
case DEMOD_TYPE_ASK:
|
case DEMOD_TYPE_ASK:
|
||||||
|
|
||||||
switch (demodulatorCons) {
|
switch (demodulatorCons) {
|
||||||
@ -304,10 +306,12 @@ void DemodulatorThread::threadMain() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < bufSize; i++) {
|
for (int i = 0; i < bufSize; i++) {
|
||||||
modem_demodulate(demodASK, inp->data[i], &bitstream);
|
|
||||||
|
|
||||||
|
modem_demodulate(demodASK, inp->data[i], &demodOutputDataDigital[i]);
|
||||||
// std::cout << bitstream << std::endl;
|
// std::cout << bitstream << std::endl;
|
||||||
}
|
}
|
||||||
updateDemodulatorLock(demodASK, 0.5f);
|
updateDemodulatorLock(demodASK, 0.005f);
|
||||||
break;
|
break;
|
||||||
case DEMOD_TYPE_APSK:
|
case DEMOD_TYPE_APSK:
|
||||||
|
|
||||||
@ -350,17 +354,21 @@ void DemodulatorThread::threadMain() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < bufSize; i++) {
|
for (int i = 0; i < bufSize; i++) {
|
||||||
modem_demodulate(demodAPSK, inp->data[i], &bitstream);
|
|
||||||
|
|
||||||
|
modem_demodulate(demodAPSK, inp->data[i], &demodOutputDataDigital[i]);
|
||||||
// std::cout << bitstream << std::endl;
|
// std::cout << bitstream << std::endl;
|
||||||
}
|
}
|
||||||
updateDemodulatorLock(demodAPSK, 0.5f);
|
updateDemodulatorLock(demodAPSK, 0.005f);
|
||||||
break;
|
break;
|
||||||
case DEMOD_TYPE_BPSK:
|
case DEMOD_TYPE_BPSK:
|
||||||
for (int i = 0; i < bufSize; i++) {
|
for (int i = 0; i < bufSize; i++) {
|
||||||
modem_demodulate(demodBPSK, inp->data[i], &bitstream);
|
|
||||||
|
|
||||||
|
modem_demodulate(demodBPSK, inp->data[i], &demodOutputDataDigital[i]);
|
||||||
// std::cout << bitstream << std::endl;
|
// std::cout << bitstream << std::endl;
|
||||||
}
|
}
|
||||||
updateDemodulatorLock(demodBPSK, 0.8f);
|
updateDemodulatorLock(demodBPSK, 0.005f);
|
||||||
break;
|
break;
|
||||||
case DEMOD_TYPE_DPSK:
|
case DEMOD_TYPE_DPSK:
|
||||||
|
|
||||||
@ -403,10 +411,12 @@ void DemodulatorThread::threadMain() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < bufSize; i++) {
|
for (int i = 0; i < bufSize; i++) {
|
||||||
modem_demodulate(demodDPSK, inp->data[i], &bitstream);
|
|
||||||
|
|
||||||
|
modem_demodulate(demodDPSK, inp->data[i], &demodOutputDataDigital[i]);
|
||||||
// std::cout << bitstream << std::endl;
|
// std::cout << bitstream << std::endl;
|
||||||
}
|
}
|
||||||
updateDemodulatorLock(demodDPSK, 0.8f);
|
updateDemodulatorLock(demodDPSK, 0.005f);
|
||||||
break;
|
break;
|
||||||
case DEMOD_TYPE_PSK:
|
case DEMOD_TYPE_PSK:
|
||||||
|
|
||||||
@ -449,17 +459,21 @@ void DemodulatorThread::threadMain() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < bufSize; i++) {
|
for (int i = 0; i < bufSize; i++) {
|
||||||
modem_demodulate(demodPSK, inp->data[i], &bitstream);
|
|
||||||
|
|
||||||
|
modem_demodulate(demodPSK, inp->data[i], &demodOutputDataDigital[i]);
|
||||||
// std::cout << bitstream << std::endl;
|
// std::cout << bitstream << std::endl;
|
||||||
}
|
}
|
||||||
updateDemodulatorLock(demodPSK, 0.8f);
|
updateDemodulatorLock(demodPSK, 0.005f);
|
||||||
break;
|
break;
|
||||||
case DEMOD_TYPE_OOK:
|
case DEMOD_TYPE_OOK:
|
||||||
for (int i = 0; i < bufSize; i++) {
|
for (int i = 0; i < bufSize; i++) {
|
||||||
modem_demodulate(demodOOK, inp->data[i], &bitstream);
|
|
||||||
|
|
||||||
|
modem_demodulate(demodOOK, inp->data[i], &demodOutputDataDigital[i]);
|
||||||
// std::cout << bitstream << std::endl;
|
// std::cout << bitstream << std::endl;
|
||||||
}
|
}
|
||||||
updateDemodulatorLock(demodOOK, 0.8f);
|
updateDemodulatorLock(demodOOK, 0.005f);
|
||||||
break;
|
break;
|
||||||
case DEMOD_TYPE_SQAM:
|
case DEMOD_TYPE_SQAM:
|
||||||
|
|
||||||
@ -502,17 +516,21 @@ void DemodulatorThread::threadMain() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < bufSize; i++) {
|
for (int i = 0; i < bufSize; i++) {
|
||||||
modem_demodulate(demodSQAM, inp->data[i], &bitstream);
|
|
||||||
|
|
||||||
|
modem_demodulate(demodSQAM, inp->data[i], &demodOutputDataDigital[i]);
|
||||||
// std::cout << bitstream << std::endl;
|
// std::cout << bitstream << std::endl;
|
||||||
}
|
}
|
||||||
updateDemodulatorLock(demodSQAM, 0.8f);
|
updateDemodulatorLock(demodSQAM, 0.005f);
|
||||||
break;
|
break;
|
||||||
case DEMOD_TYPE_ST:
|
case DEMOD_TYPE_ST:
|
||||||
for (int i = 0; i < bufSize; i++) {
|
for (int i = 0; i < bufSize; i++) {
|
||||||
modem_demodulate(demodST, inp->data[i], &bitstream);
|
|
||||||
|
|
||||||
|
modem_demodulate(demodST, inp->data[i], &demodOutputDataDigital[i]);
|
||||||
// std::cout << bitstream << std::endl;
|
// std::cout << bitstream << std::endl;
|
||||||
}
|
}
|
||||||
updateDemodulatorLock(demodST, 0.8f);
|
updateDemodulatorLock(demodST, 0.005f);
|
||||||
break;
|
break;
|
||||||
case DEMOD_TYPE_QAM:
|
case DEMOD_TYPE_QAM:
|
||||||
|
|
||||||
@ -555,14 +573,18 @@ void DemodulatorThread::threadMain() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < bufSize; i++) {
|
for (int i = 0; i < bufSize; i++) {
|
||||||
modem_demodulate(demodQAM, inp->data[i], &bitstream);
|
|
||||||
|
|
||||||
|
modem_demodulate(demodQAM, inp->data[i], &demodOutputDataDigital[i]);
|
||||||
// std::cout << bitstream << std::endl;
|
// std::cout << bitstream << std::endl;
|
||||||
}
|
}
|
||||||
updateDemodulatorLock(demodQAM, 0.5f);
|
updateDemodulatorLock(demodQAM, 0.5f);
|
||||||
break;
|
break;
|
||||||
case DEMOD_TYPE_QPSK:
|
case DEMOD_TYPE_QPSK:
|
||||||
for (int i = 0; i < bufSize; i++) {
|
for (int i = 0; i < bufSize; i++) {
|
||||||
modem_demodulate(demodQPSK, inp->data[i], &bitstream);
|
|
||||||
|
|
||||||
|
modem_demodulate(demodQPSK, inp->data[i], &demodOutputDataDigital[i]);
|
||||||
// std::cout << bitstream << std::endl;
|
// std::cout << bitstream << std::endl;
|
||||||
}
|
}
|
||||||
updateDemodulatorLock(demodQPSK, 0.8f);
|
updateDemodulatorLock(demodQPSK, 0.8f);
|
||||||
@ -597,6 +619,9 @@ void DemodulatorThread::threadMain() {
|
|||||||
unsigned int numAudioWritten;
|
unsigned int numAudioWritten;
|
||||||
msresamp_rrrf_execute(audioResampler, &demodOutputData[0], bufSize, &resampledOutputData[0], &numAudioWritten);
|
msresamp_rrrf_execute(audioResampler, &demodOutputData[0], bufSize, &resampledOutputData[0], &numAudioWritten);
|
||||||
|
|
||||||
|
// destroy the digital buffer
|
||||||
|
delete[] demodOutputDataDigital;
|
||||||
|
|
||||||
if (stereo) {
|
if (stereo) {
|
||||||
if (demodStereoData.size() != bufSize) {
|
if (demodStereoData.size() != bufSize) {
|
||||||
if (demodStereoData.capacity() < bufSize) {
|
if (demodStereoData.capacity() < bufSize) {
|
||||||
@ -770,10 +795,36 @@ void DemodulatorThread::threadMain() {
|
|||||||
demodAM = demodAM_DSB_CSP;
|
demodAM = demodAM_DSB_CSP;
|
||||||
ampmodem_reset(demodAM);
|
ampmodem_reset(demodAM);
|
||||||
break;
|
break;
|
||||||
// case DEMOD_TYPE_QPSK:
|
case DEMOD_TYPE_ASK:
|
||||||
// std::cout << "reset modem qpsk" << std::endl;
|
modem_reset(demodASK);
|
||||||
// modem_reset(demodQPSK);
|
break;
|
||||||
// break;
|
case DEMOD_TYPE_APSK:
|
||||||
|
modem_reset(demodAPSK);
|
||||||
|
break;
|
||||||
|
case DEMOD_TYPE_BPSK:
|
||||||
|
modem_reset(demodBPSK);
|
||||||
|
break;
|
||||||
|
case DEMOD_TYPE_DPSK:
|
||||||
|
modem_reset(demodDPSK);
|
||||||
|
break;
|
||||||
|
case DEMOD_TYPE_PSK:
|
||||||
|
modem_reset(demodPSK);
|
||||||
|
break;
|
||||||
|
case DEMOD_TYPE_OOK:
|
||||||
|
modem_reset(demodOOK);
|
||||||
|
break;
|
||||||
|
case DEMOD_TYPE_SQAM:
|
||||||
|
modem_reset(demodSQAM);
|
||||||
|
break;
|
||||||
|
case DEMOD_TYPE_ST:
|
||||||
|
modem_reset(demodST);
|
||||||
|
break;
|
||||||
|
case DEMOD_TYPE_QAM:
|
||||||
|
modem_reset(demodQAM);
|
||||||
|
break;
|
||||||
|
case DEMOD_TYPE_QPSK:
|
||||||
|
modem_reset(demodQPSK);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
demodulatorType = newDemodType;
|
demodulatorType = newDemodType;
|
||||||
}
|
}
|
||||||
|
@ -61,6 +61,8 @@ protected:
|
|||||||
std::vector<float> resampledOutputData;
|
std::vector<float> resampledOutputData;
|
||||||
std::vector<float> resampledStereoData;
|
std::vector<float> resampledStereoData;
|
||||||
|
|
||||||
|
unsigned int *demodOutputDataDigital;
|
||||||
|
|
||||||
DemodulatorThreadPostInputQueue* iqInputQueue;
|
DemodulatorThreadPostInputQueue* iqInputQueue;
|
||||||
DemodulatorThreadOutputQueue* audioVisOutputQueue;
|
DemodulatorThreadOutputQueue* audioVisOutputQueue;
|
||||||
AudioThreadInputQueue *audioOutputQueue;
|
AudioThreadInputQueue *audioOutputQueue;
|
||||||
|
Loading…
Reference in New Issue
Block a user