From 73ca52aee138d68a31dcacf45bb58ba57bc58c93 Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Tue, 17 Nov 2015 18:57:42 -0500 Subject: [PATCH] Convert demodulator type ids to strings for now --- src/AppFrame.cpp | 79 +++++++++++++++++---------- src/CubicSDRDefs.h | 2 +- src/demod/DemodDefs.h | 42 +++++++------- src/demod/DemodulatorInstance.cpp | 14 ++--- src/demod/DemodulatorInstance.h | 9 ++- src/demod/DemodulatorMgr.cpp | 6 +- src/demod/DemodulatorMgr.h | 6 +- src/demod/DemodulatorPreThread.cpp | 44 +++++++-------- src/demod/DemodulatorPreThread.h | 12 ++-- src/demod/DemodulatorThread.cpp | 6 +- src/demod/DemodulatorThread.h | 6 +- src/demod/DemodulatorWorkerThread.h | 14 +---- src/visual/ModeSelectorCanvas.cpp | 18 ++++++ src/visual/ModeSelectorCanvas.h | 2 + src/visual/PrimaryGLContext.cpp | 85 ++++++----------------------- src/visual/WaterfallCanvas.cpp | 18 +++--- 16 files changed, 174 insertions(+), 189 deletions(-) diff --git a/src/AppFrame.cpp b/src/AppFrame.cpp index 51f86ef..5bddf93 100644 --- a/src/AppFrame.cpp +++ b/src/AppFrame.cpp @@ -67,28 +67,28 @@ AppFrame::AppFrame() : gainSpacerItem->Show(false); demodModeSelector = new ModeSelectorCanvas(demodPanel, attribList); - demodModeSelector->addChoice(DEMOD_TYPE_FM, "FM"); - demodModeSelector->addChoice(DEMOD_TYPE_AM, "AM"); - 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->addChoice(0, "FM"); + demodModeSelector->addChoice(1, "AM"); + demodModeSelector->addChoice(2, "LSB"); + demodModeSelector->addChoice(3, "USB"); + demodModeSelector->addChoice(4, "DSB"); + demodModeSelector->addChoice(5, "I/Q"); + demodModeSelector->setSelection("FM"); demodModeSelector->setHelpTip("Choose modulation type: Frequency Modulation, Amplitude Modulation and Lower, Upper or Double Side-Band."); demodTray->Add(demodModeSelector, 2, wxEXPAND | wxALL, 0); #ifdef ENABLE_DIGITAL_LAB demodModeSelectorAdv = new ModeSelectorCanvas(this, attribList); - demodModeSelectorAdv->addChoice(DEMOD_TYPE_ASK, "ASK"); - demodModeSelectorAdv->addChoice(DEMOD_TYPE_APSK, "APSK"); - demodModeSelectorAdv->addChoice(DEMOD_TYPE_BPSK, "BPSK"); - demodModeSelectorAdv->addChoice(DEMOD_TYPE_DPSK, "DPSK"); - demodModeSelectorAdv->addChoice(DEMOD_TYPE_PSK, "PSK"); - demodModeSelectorAdv->addChoice(DEMOD_TYPE_OOK, "OOK"); - demodModeSelectorAdv->addChoice(DEMOD_TYPE_ST, "ST"); - demodModeSelectorAdv->addChoice(DEMOD_TYPE_SQAM, "SQAM"); - demodModeSelectorAdv->addChoice(DEMOD_TYPE_QAM, "QAM"); - demodModeSelectorAdv->addChoice(DEMOD_TYPE_QPSK, "QPSK"); + demodModeSelectorAdv->addChoice(0, "ASK"); + demodModeSelectorAdv->addChoice(1, "APSK"); + demodModeSelectorAdv->addChoice(2, "BPSK"); + demodModeSelectorAdv->addChoice(3, "DPSK"); + demodModeSelectorAdv->addChoice(4, "PSK"); + demodModeSelectorAdv->addChoice(5, "OOK"); + demodModeSelectorAdv->addChoice(6, "ST"); + demodModeSelectorAdv->addChoice(7, "SQAM"); + demodModeSelectorAdv->addChoice(8, "QAM"); + demodModeSelectorAdv->addChoice(9, "QPSK"); demodModeSelectorAdv->setHelpTip("Choose advanced modulation types."); demodTray->Add(demodModeSelectorAdv, 3, wxEXPAND | wxALL, 0); @@ -638,7 +638,7 @@ void AppFrame::OnMenu(wxCommandEvent& event) { } else if (event.GetId() == wxID_RESET) { wxGetApp().getDemodMgr().terminateAll(); wxGetApp().setFrequency(100000000); - wxGetApp().getDemodMgr().setLastDemodulatorType(DEMOD_TYPE_FM); + wxGetApp().getDemodMgr().setLastDemodulatorType("FM"); demodModeSelector->setSelection(1); wxGetApp().getDemodMgr().setLastMuted(false); wxGetApp().getDemodMgr().setLastStereo(false); @@ -855,7 +855,7 @@ void AppFrame::OnIdle(wxIdleEvent& event) { int outputDevice = demod->getOutputDevice(); scopeCanvas->setDeviceName(outputDevices[outputDevice].name); outputDeviceMenuItems[outputDevice]->Check(true); - int dType = demod->getDemodulatorType(); + std::string dType = demod->getDemodulatorType(); demodModeSelector->setSelection(dType); #ifdef ENABLE_DIGITAL_LAB int dCons = demod->getDemodulatorCons(); @@ -868,12 +868,12 @@ void AppFrame::OnIdle(wxIdleEvent& event) { long long centerFreq = demod->getFrequency(); unsigned int demodBw = (unsigned int) ceil((float) demod->getBandwidth() * 2.25); - if (demod->getDemodulatorType() == DEMOD_TYPE_USB) { + if (demod->getDemodulatorType() == "USB") { demodBw /= 2; centerFreq += demod->getBandwidth() / 4; } - if (demod->getDemodulatorType() == DEMOD_TYPE_LSB) { + if (demod->getDemodulatorType() == "LSB") { demodBw /= 2; centerFreq -= demod->getBandwidth() / 4; } @@ -889,18 +889,18 @@ void AppFrame::OnIdle(wxIdleEvent& event) { demodWaterfallCanvas->setCenterFrequency(centerFreq); demodSpectrumCanvas->setCenterFrequency(centerFreq); } - int dSelection = demodModeSelector->getSelection(); + std::string dSelection = demodModeSelector->getSelectionLabel(); #ifdef ENABLE_DIGITAL_LAB - int dSelectionadv = demodModeSelectorAdv->getSelection(); + std::string dSelectionadv = demodModeSelectorAdv->getSelectionLabel(); int dSelectionCons = demodModeSelectorCons->getSelection(); // basic demodulators - if (dSelection != -1 && dSelection != demod->getDemodulatorType()) { + if (dSelection != "" && dSelection != demod->getDemodulatorType()) { demod->setDemodulatorType(dSelection); demodModeSelectorAdv->setSelection(-1); } // advanced demodulators - else if (dSelectionadv != -1 && dSelectionadv != demod->getDemodulatorType()) { + else if (dSelectionadv != "" && dSelectionadv != demod->getDemodulatorType()) { demod->setDemodulatorType(dSelectionadv); demodModeSelector->setSelection(-1); } @@ -951,18 +951,18 @@ void AppFrame::OnIdle(wxIdleEvent& event) { } else { DemodulatorMgr *mgr = &wxGetApp().getDemodMgr(); - int dSelection = demodModeSelector->getSelection(); + std::string dSelection = demodModeSelector->getSelectionLabel(); #ifdef ENABLE_DIGITAL_LAB - int dSelectionadv = demodModeSelectorAdv->getSelection(); + std::string dSelectionadv = demodModeSelectorAdv->getSelectionLabel(); int dSelectionCons = demodModeSelectorCons->getSelection(); // basic demodulators - if (dSelection != -1 && dSelection != mgr->getLastDemodulatorType()) { + if (dSelection != "" && dSelection != mgr->getLastDemodulatorType()) { mgr->setLastDemodulatorType(dSelection); demodModeSelectorAdv->setSelection(-1); } // advanced demodulators - else if(dSelectionadv != -1 && dSelectionadv != mgr->getLastDemodulatorType()) { + else if(dSelectionadv != "" && dSelectionadv != mgr->getLastDemodulatorType()) { mgr->setLastDemodulatorType(dSelectionadv); demodModeSelector->setSelection(-1); } @@ -1175,7 +1175,7 @@ bool AppFrame::loadSession(std::string fileName) { long bandwidth = *demod->getNext("bandwidth"); long long freq = *demod->getNext("frequency"); - int type = demod->hasAnother("type") ? *demod->getNext("type") : DEMOD_TYPE_FM; + std::string type = demod->hasAnother("type") ? string(*demod->getNext("type")) : "FM"; float squelch_level = demod->hasAnother("squelch_level") ? (float) *demod->getNext("squelch_level") : 0; int squelch_enabled = demod->hasAnother("squelch_enabled") ? (int) *demod->getNext("squelch_enabled") : 0; int stereo = demod->hasAnother("stereo") ? (int) *demod->getNext("stereo") : 0; @@ -1183,6 +1183,25 @@ bool AppFrame::loadSession(std::string fileName) { std::string output_device = demod->hasAnother("output_device") ? string(*(demod->getNext("output_device"))) : ""; float gain = demod->hasAnother("gain") ? (float) *demod->getNext("gain") : 1.0; + // TODO: Check if "type" is numeric and perform update to new values + //#define DEMOD_TYPE_NULL 0 + //#define DEMOD_TYPE_FM 1 + //#define DEMOD_TYPE_AM 2 + //#define DEMOD_TYPE_LSB 3 + //#define DEMOD_TYPE_USB 4 + //#define DEMOD_TYPE_DSB 5 + //#define DEMOD_TYPE_ASK 6 + //#define DEMOD_TYPE_APSK 7 + //#define DEMOD_TYPE_BPSK 8 + //#define DEMOD_TYPE_DPSK 9 + //#define DEMOD_TYPE_PSK 10 + //#define DEMOD_TYPE_OOK 11 + //#define DEMOD_TYPE_ST 12 + //#define DEMOD_TYPE_SQAM 13 + //#define DEMOD_TYPE_QAM 14 + //#define DEMOD_TYPE_QPSK 15 + //#define DEMOD_TYPE_RAW 16 + DemodulatorInstance *newDemod = wxGetApp().getDemodMgr().newThread(); loadedDemod = newDemod; numDemodulators++; diff --git a/src/CubicSDRDefs.h b/src/CubicSDRDefs.h index 07d7d02..38b2913 100644 --- a/src/CubicSDRDefs.h +++ b/src/CubicSDRDefs.h @@ -30,7 +30,7 @@ const char filePathSeparator = #define DEFAULT_SAMPLE_RATE 2500000 #define DEFAULT_FFT_SIZE 2048 -#define DEFAULT_DEMOD_TYPE 1 +#define DEFAULT_DEMOD_TYPE "FM" #define DEFAULT_DEMOD_BW 200000 #define DEFAULT_WATERFALL_LPS 30 diff --git a/src/demod/DemodDefs.h b/src/demod/DemodDefs.h index ce6e36b..ded4606 100644 --- a/src/demod/DemodDefs.h +++ b/src/demod/DemodDefs.h @@ -7,23 +7,23 @@ #include #include -#define DEMOD_TYPE_NULL 0 -#define DEMOD_TYPE_FM 1 -#define DEMOD_TYPE_AM 2 -#define DEMOD_TYPE_LSB 3 -#define DEMOD_TYPE_USB 4 -#define DEMOD_TYPE_DSB 5 -#define DEMOD_TYPE_ASK 6 -#define DEMOD_TYPE_APSK 7 -#define DEMOD_TYPE_BPSK 8 -#define DEMOD_TYPE_DPSK 9 -#define DEMOD_TYPE_PSK 10 -#define DEMOD_TYPE_OOK 11 -#define DEMOD_TYPE_ST 12 -#define DEMOD_TYPE_SQAM 13 -#define DEMOD_TYPE_QAM 14 -#define DEMOD_TYPE_QPSK 15 -#define DEMOD_TYPE_RAW 16 +//#define DEMOD_TYPE_NULL 0 +//#define DEMOD_TYPE_FM 1 +//#define DEMOD_TYPE_AM 2 +//#define DEMOD_TYPE_LSB 3 +//#define DEMOD_TYPE_USB 4 +//#define DEMOD_TYPE_DSB 5 +//#define DEMOD_TYPE_ASK 6 +//#define DEMOD_TYPE_APSK 7 +//#define DEMOD_TYPE_BPSK 8 +//#define DEMOD_TYPE_DPSK 9 +//#define DEMOD_TYPE_PSK 10 +//#define DEMOD_TYPE_OOK 11 +//#define DEMOD_TYPE_ST 12 +//#define DEMOD_TYPE_SQAM 13 +//#define DEMOD_TYPE_QAM 14 +//#define DEMOD_TYPE_QPSK 15 +//#define DEMOD_TYPE_RAW 16 #include "IOThread.h" @@ -62,11 +62,11 @@ public: }; DemodulatorThreadControlCommand() : - cmd(DEMOD_THREAD_CMD_CTL_NULL), demodType(DEMOD_TYPE_NULL) { + cmd(DEMOD_THREAD_CMD_CTL_NULL), demodType("") { } DemodulatorThreadControlCommandEnum cmd; - int demodType; + std::string demodType; }; class DemodulatorThreadIQData: public ReferenceCounter { @@ -145,11 +145,11 @@ public: unsigned int bandwidth; // set equal to disable second stage re-sampling? unsigned int audioSampleRate; - int demodType; + std::string demodType; DemodulatorThreadParameters() : frequency(0), sampleRate(DEFAULT_SAMPLE_RATE), bandwidth(200000), audioSampleRate(0), - demodType(DEMOD_TYPE_FM) { + demodType("FM") { } diff --git a/src/demod/DemodulatorInstance.cpp b/src/demod/DemodulatorInstance.cpp index 0cd93aa..1405ef4 100644 --- a/src/demod/DemodulatorInstance.cpp +++ b/src/demod/DemodulatorInstance.cpp @@ -271,16 +271,16 @@ void DemodulatorInstance::checkBandwidth() { // } } -void DemodulatorInstance::setDemodulatorType(int demod_type_in) { +void DemodulatorInstance::setDemodulatorType(std::string demod_type_in) { currentDemodType = demod_type_in; - if (currentDemodType == DEMOD_TYPE_RAW) { + if (currentDemodType == "I/Q") { if (currentAudioSampleRate) { setBandwidth(currentAudioSampleRate); } else { setBandwidth(AudioThread::deviceSampleRate[getOutputDevice()]); } - } else if (currentDemodType == DEMOD_TYPE_USB || currentDemodType == DEMOD_TYPE_LSB || currentDemodType == DEMOD_TYPE_DSB || currentDemodType == DEMOD_TYPE_AM) { + } else if (currentDemodType == "USB" || currentDemodType == "LSB" || currentDemodType == "DSB" || currentDemodType == "AM") { demodulatorThread->setAGC(false); } else { demodulatorThread->setAGC(true); @@ -300,7 +300,7 @@ void DemodulatorInstance::setDemodulatorType(int demod_type_in) { } } -int DemodulatorInstance::getDemodulatorType() { +std::string DemodulatorInstance::getDemodulatorType() { return currentDemodType; } @@ -321,7 +321,7 @@ int DemodulatorInstance::getDemodulatorCons() { } void DemodulatorInstance::setBandwidth(int bw) { - if (currentDemodType == DEMOD_TYPE_RAW) { + if (currentDemodType == "I/Q") { if (currentAudioSampleRate) { bw = currentAudioSampleRate; } else { @@ -384,7 +384,7 @@ void DemodulatorInstance::setAudioSampleRate(int sampleRate) { command.llong_value = sampleRate; pipeDemodCommand->push(command); } - if (currentDemodType == DEMOD_TYPE_RAW) { + if (currentDemodType == "I/Q") { setBandwidth(currentAudioSampleRate); } } @@ -400,7 +400,7 @@ int DemodulatorInstance::getAudioSampleRate() { void DemodulatorInstance::setGain(float gain_in) { currentAudioGain = gain_in; - if (currentDemodType == DEMOD_TYPE_RAW) { + if (currentDemodType == "I/Q") { if (gain_in < 0.25) { audioThread->setGain(1.0); demodulatorThread->setAGC(false); diff --git a/src/demod/DemodulatorInstance.h b/src/demod/DemodulatorInstance.h index 19d3fb6..60cd25c 100644 --- a/src/demod/DemodulatorInstance.h +++ b/src/demod/DemodulatorInstance.h @@ -53,8 +53,8 @@ public: void setOutputDevice(int device_id); int getOutputDevice(); - void setDemodulatorType(int demod_type_in); - int getDemodulatorType(); + void setDemodulatorType(std::string demod_type_in); + std::string getDemodulatorType(); void setDemodulatorLock(bool demod_lock_in); int getDemodulatorLock(); @@ -99,6 +99,9 @@ private: void checkBandwidth(); + Modem *currentModem; + ModemKit *currentModemKit; + std::atomic label; // std::atomic_bool terminated; // std::atomic_bool demodTerminated; // @@ -111,7 +114,7 @@ private: std::atomic_llong currentFrequency; std::atomic_int currentBandwidth; - std::atomic_int currentDemodType; + std::string currentDemodType; std::atomic_int currentDemodCons; std::atomic_int currentOutputDevice; std::atomic_int currentAudioSampleRate; diff --git a/src/demod/DemodulatorMgr.cpp b/src/demod/DemodulatorMgr.cpp index fcc2c1b..bfb100e 100644 --- a/src/demod/DemodulatorMgr.cpp +++ b/src/demod/DemodulatorMgr.cpp @@ -76,7 +76,7 @@ std::vector *DemodulatorMgr::getDemodulatorsAt(long long long long halfBuffer = bandwidth / 2; - if ((freq <= (freqTest + ((testDemod->getDemodulatorType() != DEMOD_TYPE_LSB)?halfBandwidthTest:0) + halfBuffer)) && (freq >= (freqTest - ((testDemod->getDemodulatorType() != DEMOD_TYPE_USB)?halfBandwidthTest:0) - halfBuffer))) { + if ((freq <= (freqTest + ((testDemod->getDemodulatorType() != "LSB")?halfBandwidthTest:0) + halfBuffer)) && (freq >= (freqTest - ((testDemod->getDemodulatorType() != "USB")?halfBandwidthTest:0) - halfBuffer))) { foundDemods->push_back(testDemod); } } @@ -184,11 +184,11 @@ void DemodulatorMgr::setLastBandwidth(int lastBandwidth) { this->lastBandwidth = lastBandwidth; } -int DemodulatorMgr::getLastDemodulatorType() const { +std::string DemodulatorMgr::getLastDemodulatorType() const { return lastDemodType; } -void DemodulatorMgr::setLastDemodulatorType(int lastDemodType) { +void DemodulatorMgr::setLastDemodulatorType(std::string lastDemodType) { this->lastDemodType = lastDemodType; } diff --git a/src/demod/DemodulatorMgr.h b/src/demod/DemodulatorMgr.h index 0cfb4ed..739c1c5 100644 --- a/src/demod/DemodulatorMgr.h +++ b/src/demod/DemodulatorMgr.h @@ -25,8 +25,8 @@ public: int getLastBandwidth() const; void setLastBandwidth(int lastBandwidth); - int getLastDemodulatorType() const; - void setLastDemodulatorType(int lastDemodType); + std::string getLastDemodulatorType() const; + void setLastDemodulatorType(std::string lastDemodType); int getLastDemodulatorCons() const; void setLastDemodulatorCons(int lastDemodCons); @@ -57,7 +57,7 @@ private: DemodulatorInstance *activeVisualDemodulator; int lastBandwidth; - int lastDemodType; + std::string lastDemodType; bool lastDemodLock; int lastDemodCons; bool lastSquelchEnabled; diff --git a/src/demod/DemodulatorPreThread.cpp b/src/demod/DemodulatorPreThread.cpp index 32d235b..35f69d4 100644 --- a/src/demod/DemodulatorPreThread.cpp +++ b/src/demod/DemodulatorPreThread.cpp @@ -8,7 +8,7 @@ #include "DemodulatorPreThread.h" #include "CubicSDR.h" -DemodulatorPreThread::DemodulatorPreThread() : IOThread(), iqResampler(NULL), iqResampleRatio(1), audioResampler(NULL), stereoResampler(NULL), audioResampleRatio(1), firStereoLeft(NULL), firStereoRight(NULL), iirStereoPilot(NULL), iqInputQueue(NULL), iqOutputQueue(NULL), threadQueueNotify(NULL), commandQueue(NULL) +DemodulatorPreThread::DemodulatorPreThread() : IOThread(), iqResampler(NULL), iqResampleRatio(1), iqInputQueue(NULL), iqOutputQueue(NULL), threadQueueNotify(NULL), commandQueue(NULL) { initialized.store(false); @@ -272,27 +272,27 @@ void DemodulatorPreThread::run() { iqResampleRatio = result.iqResampleRatio; } - if (result.firStereoLeft) { - firStereoLeft = result.firStereoLeft; - } - - if (result.firStereoRight) { - firStereoRight = result.firStereoRight; - } - - if (result.iirStereoPilot) { - iirStereoPilot = result.iirStereoPilot; - } - - if (result.audioResampler) { - audioResampler = result.audioResampler; - audioResampleRatio = result.audioResamplerRatio; - stereoResampler = result.stereoResampler; - } - - if (result.audioSampleRate) { - params.audioSampleRate = result.audioSampleRate; - } +// if (result.firStereoLeft) { +// firStereoLeft = result.firStereoLeft; +// } +// +// if (result.firStereoRight) { +// firStereoRight = result.firStereoRight; +// } +// +// if (result.iirStereoPilot) { +// iirStereoPilot = result.iirStereoPilot; +// } +// +// if (result.audioResampler) { +// audioResampler = result.audioResampler; +// audioResampleRatio = result.audioResamplerRatio; +// stereoResampler = result.stereoResampler; +// } +// +// if (result.audioSampleRate) { +// params.audioSampleRate = result.audioSampleRate; +// } if (result.bandwidth) { params.bandwidth = result.bandwidth; diff --git a/src/demod/DemodulatorPreThread.h b/src/demod/DemodulatorPreThread.h index f3edc41..3875858 100644 --- a/src/demod/DemodulatorPreThread.h +++ b/src/demod/DemodulatorPreThread.h @@ -37,13 +37,13 @@ protected: double iqResampleRatio; std::vector resampledData; - msresamp_rrrf audioResampler; - msresamp_rrrf stereoResampler; - double audioResampleRatio; +// msresamp_rrrf audioResampler; +// msresamp_rrrf stereoResampler; +// double audioResampleRatio; - firfilt_rrrf firStereoLeft; - firfilt_rrrf firStereoRight; - iirfilt_crcf iirStereoPilot; +// firfilt_rrrf firStereoLeft; +// firfilt_rrrf firStereoRight; +// iirfilt_crcf iirStereoPilot; DemodulatorThreadParameters params; DemodulatorThreadParameters lastParams; diff --git a/src/demod/DemodulatorThread.cpp b/src/demod/DemodulatorThread.cpp index 3f9d4a7..8c9f2d5 100644 --- a/src/demod/DemodulatorThread.cpp +++ b/src/demod/DemodulatorThread.cpp @@ -16,7 +16,7 @@ DemodulatorThread::DemodulatorThread() : IOThread(), iqAutoGain(NULL), amOutputC // stereo.store(false); muted.store(false); agcEnabled.store(false); - demodulatorType.store(DEMOD_TYPE_FM); + demodulatorType = "FM"; // demodFM = freqdem_create(0.5); // demodAM_USB = ampmodem_create(0.5, 0.0, LIQUID_AMPMODEM_USB, 1); @@ -965,11 +965,11 @@ float DemodulatorThread::getSquelchLevel() { return squelchLevel; } -void DemodulatorThread::setDemodulatorType(int demod_type_in) { +void DemodulatorThread::setDemodulatorType(std::string demod_type_in) { demodulatorType = demod_type_in; } -int DemodulatorThread::getDemodulatorType() { +std::string DemodulatorThread::getDemodulatorType() { return demodulatorType; } diff --git a/src/demod/DemodulatorThread.h b/src/demod/DemodulatorThread.h index 216996c..7e92ba7 100644 --- a/src/demod/DemodulatorThread.h +++ b/src/demod/DemodulatorThread.h @@ -34,8 +34,8 @@ public: void setSquelchLevel(float signal_level_in); float getSquelchLevel(); - void setDemodulatorType(int demod_type_in); - int getDemodulatorType(); + void setDemodulatorType(std::string demod_type_in); + std::string getDemodulatorType(); void setDemodulatorLock(bool demod_lock_in); int getDemodulatorLock(); @@ -140,7 +140,7 @@ protected: // std::atomic_bool stereo; std::atomic_bool muted; std::atomic_bool agcEnabled; - std::atomic_int demodulatorType; + std::string demodulatorType; std::atomic_int demodulatorCons; int audioSampleRate; diff --git a/src/demod/DemodulatorWorkerThread.h b/src/demod/DemodulatorWorkerThread.h index 4a202c9..633ef5f 100644 --- a/src/demod/DemodulatorWorkerThread.h +++ b/src/demod/DemodulatorWorkerThread.h @@ -7,6 +7,7 @@ #include "AudioThread.h" #include "ThreadQueue.h" #include "CubicSDRDefs.h" +#include "Modem.h" class DemodulatorWorkerThreadResult { public: @@ -15,8 +16,7 @@ public: }; DemodulatorWorkerThreadResult() : - cmd(DEMOD_WORKER_THREAD_RESULT_NULL), iqResampler(NULL), iqResampleRatio(0), audioResampler(NULL), stereoResampler(NULL), audioResamplerRatio( - 0), firStereoLeft(NULL), firStereoRight(NULL), iirStereoPilot(NULL), sampleRate(0), bandwidth(0), audioSampleRate(0) { + cmd(DEMOD_WORKER_THREAD_RESULT_NULL), iqResampler(nullptr), iqResampleRatio(0), sampleRate(0), bandwidth(0), modemKit(nullptr) { } @@ -29,20 +29,12 @@ public: msresamp_crcf iqResampler; double iqResampleRatio; - msresamp_rrrf audioResampler; - msresamp_rrrf stereoResampler; - double audioResamplerRatio; - - firfilt_rrrf firStereoLeft; - firfilt_rrrf firStereoRight; - iirfilt_crcf iirStereoPilot; DemodulatorThread *demodThread; long long sampleRate; unsigned int bandwidth; - unsigned int audioSampleRate; - + ModemKit *modemKit; }; class DemodulatorWorkerThreadCommand { diff --git a/src/visual/ModeSelectorCanvas.cpp b/src/visual/ModeSelectorCanvas.cpp index f52f533..d89be48 100644 --- a/src/visual/ModeSelectorCanvas.cpp +++ b/src/visual/ModeSelectorCanvas.cpp @@ -155,6 +155,24 @@ void ModeSelectorCanvas::addChoice(int value, std::string label) { numChoices = selections.size(); } +void ModeSelectorCanvas::setSelection(std::string label) { + for (int i = 0; i < numChoices; i++) { + if (selections[i].label == label) { + currentSelection = i; + return; + } + } + currentSelection = -1; + Refresh(); +} + +std::string ModeSelectorCanvas::getSelectionLabel() { + if (currentSelection == -1) { + return ""; + } + return selections[currentSelection].label; +} + void ModeSelectorCanvas::setSelection(int value) { for (int i = 0; i < numChoices; i++) { if (selections[i].value == value) { diff --git a/src/visual/ModeSelectorCanvas.h b/src/visual/ModeSelectorCanvas.h index 2c76294..ca2a524 100644 --- a/src/visual/ModeSelectorCanvas.h +++ b/src/visual/ModeSelectorCanvas.h @@ -32,6 +32,8 @@ public: void setHelpTip(std::string tip); void addChoice(int value, std::string label); + void setSelection(std::string label); + std::string getSelectionLabel(); void setSelection(int value); int getSelection(); diff --git a/src/visual/PrimaryGLContext.cpp b/src/visual/PrimaryGLContext.cpp index f11fdac..7aea40a 100644 --- a/src/visual/PrimaryGLContext.cpp +++ b/src/visual/PrimaryGLContext.cpp @@ -87,7 +87,7 @@ void PrimaryGLContext::DrawDemodInfo(DemodulatorInstance *demod, RGBA4f color, l glColor4f(color.r, color.g, color.b, 0.6); float ofs = ((float) demod->getBandwidth()) / (float) srate; - float ofsLeft = (demod->getDemodulatorType()!=DEMOD_TYPE_USB)?ofs:0, ofsRight = (demod->getDemodulatorType()!=DEMOD_TYPE_LSB)?ofs:0; + float ofsLeft = (demod->getDemodulatorType()!="USB")?ofs:0, ofsRight = (demod->getDemodulatorType()!="LSB")?ofs:0; float labelHeight = 20.0 / viewHeight; float hPos = -1.0 + labelHeight; @@ -139,9 +139,9 @@ void PrimaryGLContext::DrawDemodInfo(DemodulatorInstance *demod, RGBA4f color, l demodLabel = std::string("[M] ") + demodLabel; } - if (demod->getDemodulatorType() == DEMOD_TYPE_USB) { + if (demod->getDemodulatorType() == "USB") { GLFont::getFont(GLFont::GLFONT_SIZE16).drawString(demodLabel, uxPos, hPos, 16, GLFont::GLFONT_ALIGN_LEFT, GLFont::GLFONT_ALIGN_CENTER); - } else if (demod->getDemodulatorType() == DEMOD_TYPE_LSB) { + } else if (demod->getDemodulatorType() == "LSB") { GLFont::getFont(GLFont::GLFONT_SIZE16).drawString(demodLabel, uxPos, hPos, 16, GLFont::GLFONT_ALIGN_RIGHT, GLFont::GLFONT_ALIGN_CENTER); } else { GLFont::getFont(GLFont::GLFONT_SIZE16).drawString(demodLabel, uxPos, hPos, 16, GLFont::GLFONT_ALIGN_CENTER, GLFont::GLFONT_ALIGN_CENTER); @@ -172,7 +172,7 @@ void PrimaryGLContext::DrawDemod(DemodulatorInstance *demod, RGBA4f color, long glColor4f(color.r, color.g, color.b, 0.6); float ofs = ((float) demod->getBandwidth()) / (float) srate; - float ofsLeft = (demod->getDemodulatorType()!=DEMOD_TYPE_USB)?ofs:0, ofsRight = (demod->getDemodulatorType()!=DEMOD_TYPE_LSB)?ofs:0; + float ofsLeft = (demod->getDemodulatorType()!="USB")?ofs:0, ofsRight = (demod->getDemodulatorType()!="LSB")?ofs:0; glBegin(GL_LINES); glVertex3f((uxPos - 0.5) * 2.0, 1.0, 0.0); @@ -217,69 +217,20 @@ void PrimaryGLContext::DrawDemod(DemodulatorInstance *demod, RGBA4f color, long std::string demodStr = ""; GLFont::Align demodAlign = GLFont::GLFONT_ALIGN_CENTER; - switch (demod->getDemodulatorType()) { - case DEMOD_TYPE_FM: - demodStr = "FM"; - demodAlign = GLFont::GLFONT_ALIGN_CENTER; - break; - case DEMOD_TYPE_AM: - demodStr = "AM"; - demodAlign = GLFont::GLFONT_ALIGN_CENTER; - break; - case DEMOD_TYPE_LSB: - demodStr = "LSB"; + demodStr = demod->getDemodulatorType(); + + demodAlign = GLFont::GLFONT_ALIGN_CENTER; + + if (demodStr == "LSB") { demodAlign = GLFont::GLFONT_ALIGN_RIGHT; uxPos -= xOfs; - break; - case DEMOD_TYPE_USB: - demodStr = "USB"; + } else if (demodStr == "USB") { demodAlign = GLFont::GLFONT_ALIGN_LEFT; uxPos += xOfs; - break; - // advanced demodulators start here - case DEMOD_TYPE_ASK: - demodStr = "ASK"; - demodAlign = GLFont::GLFONT_ALIGN_CENTER; - break; - case DEMOD_TYPE_APSK: - demodStr = "APSK"; - demodAlign = GLFont::GLFONT_ALIGN_CENTER; - break; - case DEMOD_TYPE_BPSK: - demodStr = "BPSK"; - demodAlign = GLFont::GLFONT_ALIGN_CENTER; - break; - case DEMOD_TYPE_DPSK: - demodStr = "DPSK"; - demodAlign = GLFont::GLFONT_ALIGN_CENTER; - break; - case DEMOD_TYPE_PSK: - demodStr = "PSK"; - demodAlign = GLFont::GLFONT_ALIGN_CENTER; - break; - case DEMOD_TYPE_OOK: - demodStr = "OOK"; - demodAlign = GLFont::GLFONT_ALIGN_CENTER; - break; - case DEMOD_TYPE_SQAM: - demodStr = "SQAM"; - demodAlign = GLFont::GLFONT_ALIGN_CENTER; - break; - case DEMOD_TYPE_ST: - demodStr = "ST"; - demodAlign = GLFont::GLFONT_ALIGN_CENTER; - break; - case DEMOD_TYPE_QAM: - demodStr = "QAM"; - demodAlign = GLFont::GLFONT_ALIGN_CENTER; - break; - case DEMOD_TYPE_QPSK: - demodStr = "QPSK"; - demodAlign = GLFont::GLFONT_ALIGN_CENTER; - break; } + // advanced demodulators start here - if (demod->getDemodulatorCons() != NULL && demod->getDemodulatorCons() > 0) { + if (demod->getDemodulatorCons() > 0) { demodStr = demodStr + std::to_string(demod->getDemodulatorCons()); } @@ -306,7 +257,7 @@ void PrimaryGLContext::DrawFreqSelector(float uxPos, RGBA4f color, float w, long long long bw = 0; - int last_type = wxGetApp().getDemodMgr().getLastDemodulatorType(); + std::string last_type = wxGetApp().getDemodMgr().getLastDemodulatorType(); if (!demod) { bw = wxGetApp().getDemodMgr().getLastBandwidth(); @@ -337,12 +288,12 @@ void PrimaryGLContext::DrawFreqSelector(float uxPos, RGBA4f color, float w, long ofs = ((float) bw) / (float) srate; } - if (last_type != DEMOD_TYPE_USB) { + if (last_type != "USB") { glVertex3f((uxPos - 0.5) * 2.0 - ofs, 1.0, 0.0); glVertex3f((uxPos - 0.5) * 2.0 - ofs, -1.0, 0.0); } - if (last_type != DEMOD_TYPE_LSB) { + if (last_type != "LSB") { glVertex3f((uxPos - 0.5) * 2.0 + ofs, 1.0, 0.0); glVertex3f((uxPos - 0.5) * 2.0 + ofs, -1.0, 0.0); } @@ -359,7 +310,7 @@ void PrimaryGLContext::DrawRangeSelector(float uxPos1, float uxPos2, RGBA4f colo uxPos1=temp; } - int last_type = wxGetApp().getDemodMgr().getLastDemodulatorType(); + std::string last_type = wxGetApp().getDemodMgr().getLastDemodulatorType(); glDisable(GL_TEXTURE_2D); @@ -367,14 +318,14 @@ void PrimaryGLContext::DrawRangeSelector(float uxPos1, float uxPos2, RGBA4f colo glBlendFunc(GL_SRC_ALPHA, GL_ONE); glColor4f(color.r, color.g, color.b, 0.6); - glLineWidth((last_type == DEMOD_TYPE_USB)?2.0:1.0); + glLineWidth((last_type == "USB")?2.0:1.0); glBegin(GL_LINES); glVertex3f((uxPos1 - 0.5) * 2.0, 1.0, 0.0); glVertex3f((uxPos1 - 0.5) * 2.0, -1.0, 0.0); glEnd(); - glLineWidth((last_type == DEMOD_TYPE_LSB)?2.0:1.0); + glLineWidth((last_type == "LSB")?2.0:1.0); glBegin(GL_LINES); glVertex3f((uxPos2 - 0.5) * 2.0, 1.0, 0.0); diff --git a/src/visual/WaterfallCanvas.cpp b/src/visual/WaterfallCanvas.cpp index 971552e..85f4fc2 100644 --- a/src/visual/WaterfallCanvas.cpp +++ b/src/visual/WaterfallCanvas.cpp @@ -253,7 +253,7 @@ void WaterfallCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { long long currentCenterFreq = getCenterFrequency(); ColorTheme *currentTheme = ThemeMgr::mgr.currentTheme; - int last_type = wxGetApp().getDemodMgr().getLastDemodulatorType(); + std::string last_type = wxGetApp().getDemodMgr().getLastDemodulatorType(); if (mouseTracker.mouseInView() || wxGetApp().getDemodMgr().getActiveDemodulator()) { hoverAlpha += (1.0f-hoverAlpha)*0.1f; @@ -277,7 +277,7 @@ void WaterfallCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { glContext->DrawDemod(lastActiveDemodulator, isNew?currentTheme->waterfallHighlight:currentTheme->waterfallDestroy, currentCenterFreq, currentBandwidth); - if ((last_type == DEMOD_TYPE_LSB || last_type == DEMOD_TYPE_USB) && mouseTracker.mouseDown()) { + if ((last_type == "LSB" || last_type == "USB") && mouseTracker.mouseDown()) { centerPos = mouseTracker.getMouseX(); glContext->DrawRangeSelector(centerPos, centerPos-width, isNew?currentTheme->waterfallNew:currentTheme->waterfallHover); } else { @@ -534,8 +534,8 @@ void WaterfallCanvas::OnMouseMoved(wxMouseEvent& event) { double maxDist = ((double)halfBw + bufferBw); if ((double)dist <= maxDist) { - if ((freqDiff > 0 && demod->getDemodulatorType() == DEMOD_TYPE_USB) || - (freqDiff < 0 && demod->getDemodulatorType() == DEMOD_TYPE_LSB)) { + if ((freqDiff > 0 && demod->getDemodulatorType() == "USB") || + (freqDiff < 0 && demod->getDemodulatorType() == "LSB")) { continue; } @@ -565,12 +565,12 @@ void WaterfallCanvas::OnMouseMoved(wxMouseEvent& event) { if (abs(freqDiff) > (activeDemodulator->getBandwidth() / 3)) { if (freqDiff > 0) { - if (activeDemodulator->getDemodulatorType() != DEMOD_TYPE_USB) { + if (activeDemodulator->getDemodulatorType() != "USB") { nextDragState = WF_DRAG_BANDWIDTH_LEFT; SetCursor(wxCURSOR_SIZEWE); } } else { - if (activeDemodulator->getDemodulatorType() != DEMOD_TYPE_LSB) { + if (activeDemodulator->getDemodulatorType() != "LSB") { nextDragState = WF_DRAG_BANDWIDTH_RIGHT; SetCursor(wxCURSOR_SIZEWE); } @@ -712,9 +712,9 @@ void WaterfallCanvas::OnMouseReleased(wxMouseEvent& event) { float width = mouseTracker.getOriginDeltaMouseX(); float pos; - int last_type = mgr->getLastDemodulatorType(); + std::string last_type = mgr->getLastDemodulatorType(); - if (last_type == DEMOD_TYPE_LSB || last_type == DEMOD_TYPE_USB) { + if (last_type == "LSB" || last_type == "USB") { float pos1 = mouseTracker.getOriginMouseX(); float pos2 = mouseTracker.getMouseX(); @@ -724,7 +724,7 @@ void WaterfallCanvas::OnMouseReleased(wxMouseEvent& event) { pos2 = tmp; } - pos = (last_type == DEMOD_TYPE_LSB)?pos2:pos1; + pos = (last_type == "LSB")?pos2:pos1; width *= 2; } else { pos = mouseTracker.getOriginMouseX() + width / 2.0;