diff --git a/src/AppFrame.cpp b/src/AppFrame.cpp index b659b0f..970a738 100644 --- a/src/AppFrame.cpp +++ b/src/AppFrame.cpp @@ -57,6 +57,7 @@ AppFrame::AppFrame() : demodModeSelector->addChoice(DEMOD_TYPE_LSB, "LSB"); demodModeSelector->addChoice(DEMOD_TYPE_USB, "USB"); demodModeSelector->addChoice(DEMOD_TYPE_DSB, "DSB"); + demodModeSelector->addChoice(DEMOD_TYPE_RAW, "I/Q"); demodModeSelector->setSelection(DEMOD_TYPE_FM); demodModeSelector->setHelpTip("Choose modulation type: Frequency Modulation, Amplitude Modulation and Lower, Upper or Double Side-Band."); demodTray->Add(demodModeSelector, 2, wxEXPAND | wxALL, 0); diff --git a/src/demod/DemodDefs.h b/src/demod/DemodDefs.h index a3db3e0..c5381d0 100644 --- a/src/demod/DemodDefs.h +++ b/src/demod/DemodDefs.h @@ -13,6 +13,8 @@ #define DEMOD_TYPE_LSB 3 #define DEMOD_TYPE_USB 4 #define DEMOD_TYPE_DSB 5 +#define DEMOD_TYPE_RAW 6 + class DemodulatorThread; class DemodulatorThreadCommand { diff --git a/src/demod/DemodulatorInstance.cpp b/src/demod/DemodulatorInstance.cpp index 0f16c68..ed5bb96 100644 --- a/src/demod/DemodulatorInstance.cpp +++ b/src/demod/DemodulatorInstance.cpp @@ -220,13 +220,12 @@ void DemodulatorInstance::setOutputDevice(int device_id) { if (!active) { audioThread->setInitOutputDevice(device_id); } else if (audioThread) { - setAudioSampleRate(AudioThread::deviceSampleRate[device_id]); - AudioThreadCommand command; command.cmd = AudioThreadCommand::AUDIO_THREAD_CMD_SET_DEVICE; command.int_value = device_id; audioThread->getCommandQueue()->push(command); } + setAudioSampleRate(AudioThread::deviceSampleRate[device_id]); currentOutputDevice = device_id; } @@ -258,6 +257,13 @@ void DemodulatorInstance::setDemodulatorType(int demod_type_in) { checkBandwidth(); threadQueueControl->push(command); } + if (currentDemodType == DEMOD_TYPE_RAW) { + if (currentAudioSampleRate) { + setBandwidth(currentAudioSampleRate); + } else { + setBandwidth(AudioThread::deviceSampleRate[getOutputDevice()]); + } + } } int DemodulatorInstance::getDemodulatorType() { @@ -265,6 +271,13 @@ int DemodulatorInstance::getDemodulatorType() { } void DemodulatorInstance::setBandwidth(int bw) { + if (currentDemodType == DEMOD_TYPE_RAW) { + if (currentAudioSampleRate) { + bw = currentAudioSampleRate; + } else { + bw = AudioThread::deviceSampleRate[getOutputDevice()]; + } + } if (!active) { currentBandwidth = bw; checkBandwidth(); @@ -321,6 +334,9 @@ void DemodulatorInstance::setAudioSampleRate(int sampleRate) { command.llong_value = sampleRate; threadQueueCommand->push(command); } + if (currentDemodType == DEMOD_TYPE_RAW) { + setBandwidth(currentAudioSampleRate); + } } int DemodulatorInstance::getAudioSampleRate() { diff --git a/src/demod/DemodulatorThread.cpp b/src/demod/DemodulatorThread.cpp index 160e04d..6f7246f 100644 --- a/src/demod/DemodulatorThread.cpp +++ b/src/demod/DemodulatorThread.cpp @@ -173,6 +173,8 @@ void DemodulatorThread::threadMain() { if (demodulatorType == DEMOD_TYPE_FM) { freqdem_demodulate_block(demodFM, &agcData[0], bufSize, &demodOutputData[0]); + } else if (demodulatorType == DEMOD_TYPE_RAW) { + // do nothing here.. } else { float p; switch (demodulatorType.load()) { @@ -222,6 +224,10 @@ void DemodulatorThread::threadMain() { } unsigned int numAudioWritten; + + if (demodulatorType == DEMOD_TYPE_RAW) { + numAudioWritten = bufSize; + } else { msresamp_rrrf_execute(audioResampler, &demodOutputData[0], bufSize, &resampledOutputData[0], &numAudioWritten); if (stereo && inp->sampleRate >= 100000) { @@ -276,6 +282,7 @@ void DemodulatorThread::threadMain() { msresamp_rrrf_execute(stereoResampler, &demodStereoData[0], bufSize, &resampledStereoData[0], &numAudioWritten); } + } if (currentSignalLevel > signalLevel) { signalLevel = signalLevel + (currentSignalLevel - signalLevel) * 0.5; @@ -303,7 +310,17 @@ void DemodulatorThread::threadMain() { ati->sampleRate = audioSampleRate; ati->setRefCount(1); - if (stereo && inp->sampleRate >= 100000) { + if (demodulatorType == DEMOD_TYPE_RAW) { + ati->channels = 2; + if (ati->data.capacity() < (numAudioWritten * 2)) { + ati->data.reserve(numAudioWritten * 2); + } + ati->data.resize(numAudioWritten * 2); + for (int i = 0; i < numAudioWritten; i++) { + ati->data[i * 2] = agcData[i].real; + ati->data[i * 2 + 1] = agcData[i].imag; + } + } else if (stereo && inp->sampleRate >= 100000) { ati->channels = 2; if (ati->data.capacity() < (numAudioWritten * 2)) { ati->data.reserve(numAudioWritten * 2); @@ -344,18 +361,25 @@ void DemodulatorThread::threadMain() { ati_vis->busy_update.lock(); int num_vis = DEMOD_VIS_SIZE; - if (stereo && inp->sampleRate >= 100000) { + if (demodulatorType == DEMOD_TYPE_RAW || (stereo && inp->sampleRate >= 100000)) { ati_vis->channels = 2; int stereoSize = ati->data.size(); - if (stereoSize > DEMOD_VIS_SIZE) { - stereoSize = DEMOD_VIS_SIZE; + if (stereoSize > DEMOD_VIS_SIZE * 2) { + stereoSize = DEMOD_VIS_SIZE * 2; } ati_vis->data.resize(stereoSize); - for (int i = 0; i < stereoSize / 2; i++) { - ati_vis->data[i] = ati->data[i * 2]; - ati_vis->data[i + stereoSize / 2] = ati->data[i * 2 + 1]; + if (demodulatorType == DEMOD_TYPE_RAW) { + for (int i = 0; i < stereoSize / 2; i++) { + ati_vis->data[i] = ati->data[i * 2] * 0.5; + ati_vis->data[i + stereoSize / 2] = ati->data[i * 2 + 1] * 0.5; + } + } else { + for (int i = 0; i < stereoSize / 2; i++) { + ati_vis->data[i] = ati->data[i * 2]; + ati_vis->data[i + stereoSize / 2] = ati->data[i * 2 + 1]; + } } } else { ati_vis->channels = 1;