Convert demodulator type ids to strings for now

This commit is contained in:
Charles J. Cliffe 2015-11-17 18:57:42 -05:00
parent e33b8952d4
commit 73ca52aee1
16 changed files with 174 additions and 189 deletions

View File

@ -67,28 +67,28 @@ AppFrame::AppFrame() :
gainSpacerItem->Show(false); gainSpacerItem->Show(false);
demodModeSelector = new ModeSelectorCanvas(demodPanel, attribList); demodModeSelector = new ModeSelectorCanvas(demodPanel, attribList);
demodModeSelector->addChoice(DEMOD_TYPE_FM, "FM"); demodModeSelector->addChoice(0, "FM");
demodModeSelector->addChoice(DEMOD_TYPE_AM, "AM"); demodModeSelector->addChoice(1, "AM");
demodModeSelector->addChoice(DEMOD_TYPE_LSB, "LSB"); demodModeSelector->addChoice(2, "LSB");
demodModeSelector->addChoice(DEMOD_TYPE_USB, "USB"); demodModeSelector->addChoice(3, "USB");
demodModeSelector->addChoice(DEMOD_TYPE_DSB, "DSB"); demodModeSelector->addChoice(4, "DSB");
demodModeSelector->addChoice(DEMOD_TYPE_RAW, "I/Q"); demodModeSelector->addChoice(5, "I/Q");
demodModeSelector->setSelection(DEMOD_TYPE_FM); demodModeSelector->setSelection("FM");
demodModeSelector->setHelpTip("Choose modulation type: Frequency Modulation, Amplitude Modulation and Lower, Upper or Double Side-Band."); demodModeSelector->setHelpTip("Choose modulation type: Frequency Modulation, Amplitude Modulation and Lower, Upper or Double Side-Band.");
demodTray->Add(demodModeSelector, 2, wxEXPAND | wxALL, 0); demodTray->Add(demodModeSelector, 2, wxEXPAND | wxALL, 0);
#ifdef ENABLE_DIGITAL_LAB #ifdef ENABLE_DIGITAL_LAB
demodModeSelectorAdv = new ModeSelectorCanvas(this, attribList); demodModeSelectorAdv = new ModeSelectorCanvas(this, attribList);
demodModeSelectorAdv->addChoice(DEMOD_TYPE_ASK, "ASK"); demodModeSelectorAdv->addChoice(0, "ASK");
demodModeSelectorAdv->addChoice(DEMOD_TYPE_APSK, "APSK"); demodModeSelectorAdv->addChoice(1, "APSK");
demodModeSelectorAdv->addChoice(DEMOD_TYPE_BPSK, "BPSK"); demodModeSelectorAdv->addChoice(2, "BPSK");
demodModeSelectorAdv->addChoice(DEMOD_TYPE_DPSK, "DPSK"); demodModeSelectorAdv->addChoice(3, "DPSK");
demodModeSelectorAdv->addChoice(DEMOD_TYPE_PSK, "PSK"); demodModeSelectorAdv->addChoice(4, "PSK");
demodModeSelectorAdv->addChoice(DEMOD_TYPE_OOK, "OOK"); demodModeSelectorAdv->addChoice(5, "OOK");
demodModeSelectorAdv->addChoice(DEMOD_TYPE_ST, "ST"); demodModeSelectorAdv->addChoice(6, "ST");
demodModeSelectorAdv->addChoice(DEMOD_TYPE_SQAM, "SQAM"); demodModeSelectorAdv->addChoice(7, "SQAM");
demodModeSelectorAdv->addChoice(DEMOD_TYPE_QAM, "QAM"); demodModeSelectorAdv->addChoice(8, "QAM");
demodModeSelectorAdv->addChoice(DEMOD_TYPE_QPSK, "QPSK"); demodModeSelectorAdv->addChoice(9, "QPSK");
demodModeSelectorAdv->setHelpTip("Choose advanced modulation types."); demodModeSelectorAdv->setHelpTip("Choose advanced modulation types.");
demodTray->Add(demodModeSelectorAdv, 3, wxEXPAND | wxALL, 0); demodTray->Add(demodModeSelectorAdv, 3, wxEXPAND | wxALL, 0);
@ -638,7 +638,7 @@ void AppFrame::OnMenu(wxCommandEvent& event) {
} else if (event.GetId() == wxID_RESET) { } else if (event.GetId() == wxID_RESET) {
wxGetApp().getDemodMgr().terminateAll(); wxGetApp().getDemodMgr().terminateAll();
wxGetApp().setFrequency(100000000); wxGetApp().setFrequency(100000000);
wxGetApp().getDemodMgr().setLastDemodulatorType(DEMOD_TYPE_FM); wxGetApp().getDemodMgr().setLastDemodulatorType("FM");
demodModeSelector->setSelection(1); demodModeSelector->setSelection(1);
wxGetApp().getDemodMgr().setLastMuted(false); wxGetApp().getDemodMgr().setLastMuted(false);
wxGetApp().getDemodMgr().setLastStereo(false); wxGetApp().getDemodMgr().setLastStereo(false);
@ -855,7 +855,7 @@ void AppFrame::OnIdle(wxIdleEvent& event) {
int outputDevice = demod->getOutputDevice(); int outputDevice = demod->getOutputDevice();
scopeCanvas->setDeviceName(outputDevices[outputDevice].name); scopeCanvas->setDeviceName(outputDevices[outputDevice].name);
outputDeviceMenuItems[outputDevice]->Check(true); outputDeviceMenuItems[outputDevice]->Check(true);
int dType = demod->getDemodulatorType(); std::string dType = demod->getDemodulatorType();
demodModeSelector->setSelection(dType); demodModeSelector->setSelection(dType);
#ifdef ENABLE_DIGITAL_LAB #ifdef ENABLE_DIGITAL_LAB
int dCons = demod->getDemodulatorCons(); int dCons = demod->getDemodulatorCons();
@ -868,12 +868,12 @@ void AppFrame::OnIdle(wxIdleEvent& event) {
long long centerFreq = demod->getFrequency(); long long centerFreq = demod->getFrequency();
unsigned int demodBw = (unsigned int) ceil((float) demod->getBandwidth() * 2.25); unsigned int demodBw = (unsigned int) ceil((float) demod->getBandwidth() * 2.25);
if (demod->getDemodulatorType() == DEMOD_TYPE_USB) { if (demod->getDemodulatorType() == "USB") {
demodBw /= 2; demodBw /= 2;
centerFreq += demod->getBandwidth() / 4; centerFreq += demod->getBandwidth() / 4;
} }
if (demod->getDemodulatorType() == DEMOD_TYPE_LSB) { if (demod->getDemodulatorType() == "LSB") {
demodBw /= 2; demodBw /= 2;
centerFreq -= demod->getBandwidth() / 4; centerFreq -= demod->getBandwidth() / 4;
} }
@ -889,18 +889,18 @@ void AppFrame::OnIdle(wxIdleEvent& event) {
demodWaterfallCanvas->setCenterFrequency(centerFreq); demodWaterfallCanvas->setCenterFrequency(centerFreq);
demodSpectrumCanvas->setCenterFrequency(centerFreq); demodSpectrumCanvas->setCenterFrequency(centerFreq);
} }
int dSelection = demodModeSelector->getSelection(); std::string dSelection = demodModeSelector->getSelectionLabel();
#ifdef ENABLE_DIGITAL_LAB #ifdef ENABLE_DIGITAL_LAB
int dSelectionadv = demodModeSelectorAdv->getSelection(); std::string dSelectionadv = demodModeSelectorAdv->getSelectionLabel();
int dSelectionCons = demodModeSelectorCons->getSelection(); int dSelectionCons = demodModeSelectorCons->getSelection();
// basic demodulators // basic demodulators
if (dSelection != -1 && dSelection != demod->getDemodulatorType()) { if (dSelection != "" && dSelection != demod->getDemodulatorType()) {
demod->setDemodulatorType(dSelection); demod->setDemodulatorType(dSelection);
demodModeSelectorAdv->setSelection(-1); demodModeSelectorAdv->setSelection(-1);
} }
// advanced demodulators // advanced demodulators
else if (dSelectionadv != -1 && dSelectionadv != demod->getDemodulatorType()) { else if (dSelectionadv != "" && dSelectionadv != demod->getDemodulatorType()) {
demod->setDemodulatorType(dSelectionadv); demod->setDemodulatorType(dSelectionadv);
demodModeSelector->setSelection(-1); demodModeSelector->setSelection(-1);
} }
@ -951,18 +951,18 @@ void AppFrame::OnIdle(wxIdleEvent& event) {
} else { } else {
DemodulatorMgr *mgr = &wxGetApp().getDemodMgr(); DemodulatorMgr *mgr = &wxGetApp().getDemodMgr();
int dSelection = demodModeSelector->getSelection(); std::string dSelection = demodModeSelector->getSelectionLabel();
#ifdef ENABLE_DIGITAL_LAB #ifdef ENABLE_DIGITAL_LAB
int dSelectionadv = demodModeSelectorAdv->getSelection(); std::string dSelectionadv = demodModeSelectorAdv->getSelectionLabel();
int dSelectionCons = demodModeSelectorCons->getSelection(); int dSelectionCons = demodModeSelectorCons->getSelection();
// basic demodulators // basic demodulators
if (dSelection != -1 && dSelection != mgr->getLastDemodulatorType()) { if (dSelection != "" && dSelection != mgr->getLastDemodulatorType()) {
mgr->setLastDemodulatorType(dSelection); mgr->setLastDemodulatorType(dSelection);
demodModeSelectorAdv->setSelection(-1); demodModeSelectorAdv->setSelection(-1);
} }
// advanced demodulators // advanced demodulators
else if(dSelectionadv != -1 && dSelectionadv != mgr->getLastDemodulatorType()) { else if(dSelectionadv != "" && dSelectionadv != mgr->getLastDemodulatorType()) {
mgr->setLastDemodulatorType(dSelectionadv); mgr->setLastDemodulatorType(dSelectionadv);
demodModeSelector->setSelection(-1); demodModeSelector->setSelection(-1);
} }
@ -1175,7 +1175,7 @@ bool AppFrame::loadSession(std::string fileName) {
long bandwidth = *demod->getNext("bandwidth"); long bandwidth = *demod->getNext("bandwidth");
long long freq = *demod->getNext("frequency"); 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; 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 squelch_enabled = demod->hasAnother("squelch_enabled") ? (int) *demod->getNext("squelch_enabled") : 0;
int stereo = demod->hasAnother("stereo") ? (int) *demod->getNext("stereo") : 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"))) : ""; std::string output_device = demod->hasAnother("output_device") ? string(*(demod->getNext("output_device"))) : "";
float gain = demod->hasAnother("gain") ? (float) *demod->getNext("gain") : 1.0; 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(); DemodulatorInstance *newDemod = wxGetApp().getDemodMgr().newThread();
loadedDemod = newDemod; loadedDemod = newDemod;
numDemodulators++; numDemodulators++;

View File

@ -30,7 +30,7 @@ const char filePathSeparator =
#define DEFAULT_SAMPLE_RATE 2500000 #define DEFAULT_SAMPLE_RATE 2500000
#define DEFAULT_FFT_SIZE 2048 #define DEFAULT_FFT_SIZE 2048
#define DEFAULT_DEMOD_TYPE 1 #define DEFAULT_DEMOD_TYPE "FM"
#define DEFAULT_DEMOD_BW 200000 #define DEFAULT_DEMOD_BW 200000
#define DEFAULT_WATERFALL_LPS 30 #define DEFAULT_WATERFALL_LPS 30

View File

@ -7,23 +7,23 @@
#include <atomic> #include <atomic>
#include <mutex> #include <mutex>
#define DEMOD_TYPE_NULL 0 //#define DEMOD_TYPE_NULL 0
#define DEMOD_TYPE_FM 1 //#define DEMOD_TYPE_FM 1
#define DEMOD_TYPE_AM 2 //#define DEMOD_TYPE_AM 2
#define DEMOD_TYPE_LSB 3 //#define DEMOD_TYPE_LSB 3
#define DEMOD_TYPE_USB 4 //#define DEMOD_TYPE_USB 4
#define DEMOD_TYPE_DSB 5 //#define DEMOD_TYPE_DSB 5
#define DEMOD_TYPE_ASK 6 //#define DEMOD_TYPE_ASK 6
#define DEMOD_TYPE_APSK 7 //#define DEMOD_TYPE_APSK 7
#define DEMOD_TYPE_BPSK 8 //#define DEMOD_TYPE_BPSK 8
#define DEMOD_TYPE_DPSK 9 //#define DEMOD_TYPE_DPSK 9
#define DEMOD_TYPE_PSK 10 //#define DEMOD_TYPE_PSK 10
#define DEMOD_TYPE_OOK 11 //#define DEMOD_TYPE_OOK 11
#define DEMOD_TYPE_ST 12 //#define DEMOD_TYPE_ST 12
#define DEMOD_TYPE_SQAM 13 //#define DEMOD_TYPE_SQAM 13
#define DEMOD_TYPE_QAM 14 //#define DEMOD_TYPE_QAM 14
#define DEMOD_TYPE_QPSK 15 //#define DEMOD_TYPE_QPSK 15
#define DEMOD_TYPE_RAW 16 //#define DEMOD_TYPE_RAW 16
#include "IOThread.h" #include "IOThread.h"
@ -62,11 +62,11 @@ public:
}; };
DemodulatorThreadControlCommand() : DemodulatorThreadControlCommand() :
cmd(DEMOD_THREAD_CMD_CTL_NULL), demodType(DEMOD_TYPE_NULL) { cmd(DEMOD_THREAD_CMD_CTL_NULL), demodType("") {
} }
DemodulatorThreadControlCommandEnum cmd; DemodulatorThreadControlCommandEnum cmd;
int demodType; std::string demodType;
}; };
class DemodulatorThreadIQData: public ReferenceCounter { class DemodulatorThreadIQData: public ReferenceCounter {
@ -145,11 +145,11 @@ public:
unsigned int bandwidth; // set equal to disable second stage re-sampling? unsigned int bandwidth; // set equal to disable second stage re-sampling?
unsigned int audioSampleRate; unsigned int audioSampleRate;
int demodType; std::string demodType;
DemodulatorThreadParameters() : DemodulatorThreadParameters() :
frequency(0), sampleRate(DEFAULT_SAMPLE_RATE), bandwidth(200000), audioSampleRate(0), frequency(0), sampleRate(DEFAULT_SAMPLE_RATE), bandwidth(200000), audioSampleRate(0),
demodType(DEMOD_TYPE_FM) { demodType("FM") {
} }

View File

@ -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; currentDemodType = demod_type_in;
if (currentDemodType == DEMOD_TYPE_RAW) { if (currentDemodType == "I/Q") {
if (currentAudioSampleRate) { if (currentAudioSampleRate) {
setBandwidth(currentAudioSampleRate); setBandwidth(currentAudioSampleRate);
} else { } else {
setBandwidth(AudioThread::deviceSampleRate[getOutputDevice()]); 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); demodulatorThread->setAGC(false);
} else { } else {
demodulatorThread->setAGC(true); demodulatorThread->setAGC(true);
@ -300,7 +300,7 @@ void DemodulatorInstance::setDemodulatorType(int demod_type_in) {
} }
} }
int DemodulatorInstance::getDemodulatorType() { std::string DemodulatorInstance::getDemodulatorType() {
return currentDemodType; return currentDemodType;
} }
@ -321,7 +321,7 @@ int DemodulatorInstance::getDemodulatorCons() {
} }
void DemodulatorInstance::setBandwidth(int bw) { void DemodulatorInstance::setBandwidth(int bw) {
if (currentDemodType == DEMOD_TYPE_RAW) { if (currentDemodType == "I/Q") {
if (currentAudioSampleRate) { if (currentAudioSampleRate) {
bw = currentAudioSampleRate; bw = currentAudioSampleRate;
} else { } else {
@ -384,7 +384,7 @@ void DemodulatorInstance::setAudioSampleRate(int sampleRate) {
command.llong_value = sampleRate; command.llong_value = sampleRate;
pipeDemodCommand->push(command); pipeDemodCommand->push(command);
} }
if (currentDemodType == DEMOD_TYPE_RAW) { if (currentDemodType == "I/Q") {
setBandwidth(currentAudioSampleRate); setBandwidth(currentAudioSampleRate);
} }
} }
@ -400,7 +400,7 @@ int DemodulatorInstance::getAudioSampleRate() {
void DemodulatorInstance::setGain(float gain_in) { void DemodulatorInstance::setGain(float gain_in) {
currentAudioGain = gain_in; currentAudioGain = gain_in;
if (currentDemodType == DEMOD_TYPE_RAW) { if (currentDemodType == "I/Q") {
if (gain_in < 0.25) { if (gain_in < 0.25) {
audioThread->setGain(1.0); audioThread->setGain(1.0);
demodulatorThread->setAGC(false); demodulatorThread->setAGC(false);

View File

@ -53,8 +53,8 @@ public:
void setOutputDevice(int device_id); void setOutputDevice(int device_id);
int getOutputDevice(); int getOutputDevice();
void setDemodulatorType(int demod_type_in); void setDemodulatorType(std::string demod_type_in);
int getDemodulatorType(); std::string getDemodulatorType();
void setDemodulatorLock(bool demod_lock_in); void setDemodulatorLock(bool demod_lock_in);
int getDemodulatorLock(); int getDemodulatorLock();
@ -99,6 +99,9 @@ private:
void checkBandwidth(); void checkBandwidth();
Modem *currentModem;
ModemKit *currentModemKit;
std::atomic<std::string *> label; // std::atomic<std::string *> label; //
std::atomic_bool terminated; // std::atomic_bool terminated; //
std::atomic_bool demodTerminated; // std::atomic_bool demodTerminated; //
@ -111,7 +114,7 @@ private:
std::atomic_llong currentFrequency; std::atomic_llong currentFrequency;
std::atomic_int currentBandwidth; std::atomic_int currentBandwidth;
std::atomic_int currentDemodType; std::string currentDemodType;
std::atomic_int currentDemodCons; std::atomic_int currentDemodCons;
std::atomic_int currentOutputDevice; std::atomic_int currentOutputDevice;
std::atomic_int currentAudioSampleRate; std::atomic_int currentAudioSampleRate;

View File

@ -76,7 +76,7 @@ std::vector<DemodulatorInstance *> *DemodulatorMgr::getDemodulatorsAt(long long
long long halfBuffer = bandwidth / 2; 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); foundDemods->push_back(testDemod);
} }
} }
@ -184,11 +184,11 @@ void DemodulatorMgr::setLastBandwidth(int lastBandwidth) {
this->lastBandwidth = lastBandwidth; this->lastBandwidth = lastBandwidth;
} }
int DemodulatorMgr::getLastDemodulatorType() const { std::string DemodulatorMgr::getLastDemodulatorType() const {
return lastDemodType; return lastDemodType;
} }
void DemodulatorMgr::setLastDemodulatorType(int lastDemodType) { void DemodulatorMgr::setLastDemodulatorType(std::string lastDemodType) {
this->lastDemodType = lastDemodType; this->lastDemodType = lastDemodType;
} }

View File

@ -25,8 +25,8 @@ public:
int getLastBandwidth() const; int getLastBandwidth() const;
void setLastBandwidth(int lastBandwidth); void setLastBandwidth(int lastBandwidth);
int getLastDemodulatorType() const; std::string getLastDemodulatorType() const;
void setLastDemodulatorType(int lastDemodType); void setLastDemodulatorType(std::string lastDemodType);
int getLastDemodulatorCons() const; int getLastDemodulatorCons() const;
void setLastDemodulatorCons(int lastDemodCons); void setLastDemodulatorCons(int lastDemodCons);
@ -57,7 +57,7 @@ private:
DemodulatorInstance *activeVisualDemodulator; DemodulatorInstance *activeVisualDemodulator;
int lastBandwidth; int lastBandwidth;
int lastDemodType; std::string lastDemodType;
bool lastDemodLock; bool lastDemodLock;
int lastDemodCons; int lastDemodCons;
bool lastSquelchEnabled; bool lastSquelchEnabled;

View File

@ -8,7 +8,7 @@
#include "DemodulatorPreThread.h" #include "DemodulatorPreThread.h"
#include "CubicSDR.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); initialized.store(false);
@ -272,27 +272,27 @@ void DemodulatorPreThread::run() {
iqResampleRatio = result.iqResampleRatio; iqResampleRatio = result.iqResampleRatio;
} }
if (result.firStereoLeft) { // if (result.firStereoLeft) {
firStereoLeft = result.firStereoLeft; // firStereoLeft = result.firStereoLeft;
} // }
//
if (result.firStereoRight) { // if (result.firStereoRight) {
firStereoRight = result.firStereoRight; // firStereoRight = result.firStereoRight;
} // }
//
if (result.iirStereoPilot) { // if (result.iirStereoPilot) {
iirStereoPilot = result.iirStereoPilot; // iirStereoPilot = result.iirStereoPilot;
} // }
//
if (result.audioResampler) { // if (result.audioResampler) {
audioResampler = result.audioResampler; // audioResampler = result.audioResampler;
audioResampleRatio = result.audioResamplerRatio; // audioResampleRatio = result.audioResamplerRatio;
stereoResampler = result.stereoResampler; // stereoResampler = result.stereoResampler;
} // }
//
if (result.audioSampleRate) { // if (result.audioSampleRate) {
params.audioSampleRate = result.audioSampleRate; // params.audioSampleRate = result.audioSampleRate;
} // }
if (result.bandwidth) { if (result.bandwidth) {
params.bandwidth = result.bandwidth; params.bandwidth = result.bandwidth;

View File

@ -37,13 +37,13 @@ protected:
double iqResampleRatio; double iqResampleRatio;
std::vector<liquid_float_complex> resampledData; std::vector<liquid_float_complex> resampledData;
msresamp_rrrf audioResampler; // msresamp_rrrf audioResampler;
msresamp_rrrf stereoResampler; // msresamp_rrrf stereoResampler;
double audioResampleRatio; // double audioResampleRatio;
firfilt_rrrf firStereoLeft; // firfilt_rrrf firStereoLeft;
firfilt_rrrf firStereoRight; // firfilt_rrrf firStereoRight;
iirfilt_crcf iirStereoPilot; // iirfilt_crcf iirStereoPilot;
DemodulatorThreadParameters params; DemodulatorThreadParameters params;
DemodulatorThreadParameters lastParams; DemodulatorThreadParameters lastParams;

View File

@ -16,7 +16,7 @@ DemodulatorThread::DemodulatorThread() : IOThread(), iqAutoGain(NULL), amOutputC
// stereo.store(false); // stereo.store(false);
muted.store(false); muted.store(false);
agcEnabled.store(false); agcEnabled.store(false);
demodulatorType.store(DEMOD_TYPE_FM); demodulatorType = "FM";
// demodFM = freqdem_create(0.5); // demodFM = freqdem_create(0.5);
// demodAM_USB = ampmodem_create(0.5, 0.0, LIQUID_AMPMODEM_USB, 1); // demodAM_USB = ampmodem_create(0.5, 0.0, LIQUID_AMPMODEM_USB, 1);
@ -965,11 +965,11 @@ float DemodulatorThread::getSquelchLevel() {
return squelchLevel; return squelchLevel;
} }
void DemodulatorThread::setDemodulatorType(int demod_type_in) { void DemodulatorThread::setDemodulatorType(std::string demod_type_in) {
demodulatorType = demod_type_in; demodulatorType = demod_type_in;
} }
int DemodulatorThread::getDemodulatorType() { std::string DemodulatorThread::getDemodulatorType() {
return demodulatorType; return demodulatorType;
} }

View File

@ -34,8 +34,8 @@ public:
void setSquelchLevel(float signal_level_in); void setSquelchLevel(float signal_level_in);
float getSquelchLevel(); float getSquelchLevel();
void setDemodulatorType(int demod_type_in); void setDemodulatorType(std::string demod_type_in);
int getDemodulatorType(); std::string getDemodulatorType();
void setDemodulatorLock(bool demod_lock_in); void setDemodulatorLock(bool demod_lock_in);
int getDemodulatorLock(); int getDemodulatorLock();
@ -140,7 +140,7 @@ protected:
// std::atomic_bool stereo; // std::atomic_bool stereo;
std::atomic_bool muted; std::atomic_bool muted;
std::atomic_bool agcEnabled; std::atomic_bool agcEnabled;
std::atomic_int demodulatorType; std::string demodulatorType;
std::atomic_int demodulatorCons; std::atomic_int demodulatorCons;
int audioSampleRate; int audioSampleRate;

View File

@ -7,6 +7,7 @@
#include "AudioThread.h" #include "AudioThread.h"
#include "ThreadQueue.h" #include "ThreadQueue.h"
#include "CubicSDRDefs.h" #include "CubicSDRDefs.h"
#include "Modem.h"
class DemodulatorWorkerThreadResult { class DemodulatorWorkerThreadResult {
public: public:
@ -15,8 +16,7 @@ public:
}; };
DemodulatorWorkerThreadResult() : DemodulatorWorkerThreadResult() :
cmd(DEMOD_WORKER_THREAD_RESULT_NULL), iqResampler(NULL), iqResampleRatio(0), audioResampler(NULL), stereoResampler(NULL), audioResamplerRatio( cmd(DEMOD_WORKER_THREAD_RESULT_NULL), iqResampler(nullptr), iqResampleRatio(0), sampleRate(0), bandwidth(0), modemKit(nullptr) {
0), firStereoLeft(NULL), firStereoRight(NULL), iirStereoPilot(NULL), sampleRate(0), bandwidth(0), audioSampleRate(0) {
} }
@ -29,20 +29,12 @@ public:
msresamp_crcf iqResampler; msresamp_crcf iqResampler;
double iqResampleRatio; double iqResampleRatio;
msresamp_rrrf audioResampler;
msresamp_rrrf stereoResampler;
double audioResamplerRatio;
firfilt_rrrf firStereoLeft;
firfilt_rrrf firStereoRight;
iirfilt_crcf iirStereoPilot;
DemodulatorThread *demodThread; DemodulatorThread *demodThread;
long long sampleRate; long long sampleRate;
unsigned int bandwidth; unsigned int bandwidth;
unsigned int audioSampleRate; ModemKit *modemKit;
}; };
class DemodulatorWorkerThreadCommand { class DemodulatorWorkerThreadCommand {

View File

@ -155,6 +155,24 @@ void ModeSelectorCanvas::addChoice(int value, std::string label) {
numChoices = selections.size(); 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) { void ModeSelectorCanvas::setSelection(int value) {
for (int i = 0; i < numChoices; i++) { for (int i = 0; i < numChoices; i++) {
if (selections[i].value == value) { if (selections[i].value == value) {

View File

@ -32,6 +32,8 @@ public:
void setHelpTip(std::string tip); void setHelpTip(std::string tip);
void addChoice(int value, std::string label); void addChoice(int value, std::string label);
void setSelection(std::string label);
std::string getSelectionLabel();
void setSelection(int value); void setSelection(int value);
int getSelection(); int getSelection();

View File

@ -87,7 +87,7 @@ void PrimaryGLContext::DrawDemodInfo(DemodulatorInstance *demod, RGBA4f color, l
glColor4f(color.r, color.g, color.b, 0.6); glColor4f(color.r, color.g, color.b, 0.6);
float ofs = ((float) demod->getBandwidth()) / (float) srate; 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 labelHeight = 20.0 / viewHeight;
float hPos = -1.0 + labelHeight; float hPos = -1.0 + labelHeight;
@ -139,9 +139,9 @@ void PrimaryGLContext::DrawDemodInfo(DemodulatorInstance *demod, RGBA4f color, l
demodLabel = std::string("[M] ") + demodLabel; 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); 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); GLFont::getFont(GLFont::GLFONT_SIZE16).drawString(demodLabel, uxPos, hPos, 16, GLFont::GLFONT_ALIGN_RIGHT, GLFont::GLFONT_ALIGN_CENTER);
} else { } else {
GLFont::getFont(GLFont::GLFONT_SIZE16).drawString(demodLabel, uxPos, hPos, 16, GLFont::GLFONT_ALIGN_CENTER, GLFont::GLFONT_ALIGN_CENTER); 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); glColor4f(color.r, color.g, color.b, 0.6);
float ofs = ((float) demod->getBandwidth()) / (float) srate; 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); glBegin(GL_LINES);
glVertex3f((uxPos - 0.5) * 2.0, 1.0, 0.0); 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 = ""; std::string demodStr = "";
GLFont::Align demodAlign = GLFont::GLFONT_ALIGN_CENTER; GLFont::Align demodAlign = GLFont::GLFONT_ALIGN_CENTER;
switch (demod->getDemodulatorType()) { demodStr = demod->getDemodulatorType();
case DEMOD_TYPE_FM:
demodStr = "FM";
demodAlign = GLFont::GLFONT_ALIGN_CENTER; demodAlign = GLFont::GLFONT_ALIGN_CENTER;
break;
case DEMOD_TYPE_AM: if (demodStr == "LSB") {
demodStr = "AM";
demodAlign = GLFont::GLFONT_ALIGN_CENTER;
break;
case DEMOD_TYPE_LSB:
demodStr = "LSB";
demodAlign = GLFont::GLFONT_ALIGN_RIGHT; demodAlign = GLFont::GLFONT_ALIGN_RIGHT;
uxPos -= xOfs; uxPos -= xOfs;
break; } else if (demodStr == "USB") {
case DEMOD_TYPE_USB:
demodStr = "USB";
demodAlign = GLFont::GLFONT_ALIGN_LEFT; demodAlign = GLFont::GLFONT_ALIGN_LEFT;
uxPos += xOfs; 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()); 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; long long bw = 0;
int last_type = wxGetApp().getDemodMgr().getLastDemodulatorType(); std::string last_type = wxGetApp().getDemodMgr().getLastDemodulatorType();
if (!demod) { if (!demod) {
bw = wxGetApp().getDemodMgr().getLastBandwidth(); bw = wxGetApp().getDemodMgr().getLastBandwidth();
@ -337,12 +288,12 @@ void PrimaryGLContext::DrawFreqSelector(float uxPos, RGBA4f color, float w, long
ofs = ((float) bw) / (float) srate; 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);
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);
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; uxPos1=temp;
} }
int last_type = wxGetApp().getDemodMgr().getLastDemodulatorType(); std::string last_type = wxGetApp().getDemodMgr().getLastDemodulatorType();
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);
@ -367,14 +318,14 @@ void PrimaryGLContext::DrawRangeSelector(float uxPos1, float uxPos2, RGBA4f colo
glBlendFunc(GL_SRC_ALPHA, GL_ONE); glBlendFunc(GL_SRC_ALPHA, GL_ONE);
glColor4f(color.r, color.g, color.b, 0.6); 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); glBegin(GL_LINES);
glVertex3f((uxPos1 - 0.5) * 2.0, 1.0, 0.0); glVertex3f((uxPos1 - 0.5) * 2.0, 1.0, 0.0);
glVertex3f((uxPos1 - 0.5) * 2.0, -1.0, 0.0); glVertex3f((uxPos1 - 0.5) * 2.0, -1.0, 0.0);
glEnd(); glEnd();
glLineWidth((last_type == DEMOD_TYPE_LSB)?2.0:1.0); glLineWidth((last_type == "LSB")?2.0:1.0);
glBegin(GL_LINES); glBegin(GL_LINES);
glVertex3f((uxPos2 - 0.5) * 2.0, 1.0, 0.0); glVertex3f((uxPos2 - 0.5) * 2.0, 1.0, 0.0);

View File

@ -253,7 +253,7 @@ void WaterfallCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
long long currentCenterFreq = getCenterFrequency(); long long currentCenterFreq = getCenterFrequency();
ColorTheme *currentTheme = ThemeMgr::mgr.currentTheme; ColorTheme *currentTheme = ThemeMgr::mgr.currentTheme;
int last_type = wxGetApp().getDemodMgr().getLastDemodulatorType(); std::string last_type = wxGetApp().getDemodMgr().getLastDemodulatorType();
if (mouseTracker.mouseInView() || wxGetApp().getDemodMgr().getActiveDemodulator()) { if (mouseTracker.mouseInView() || wxGetApp().getDemodMgr().getActiveDemodulator()) {
hoverAlpha += (1.0f-hoverAlpha)*0.1f; 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); 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(); centerPos = mouseTracker.getMouseX();
glContext->DrawRangeSelector(centerPos, centerPos-width, isNew?currentTheme->waterfallNew:currentTheme->waterfallHover); glContext->DrawRangeSelector(centerPos, centerPos-width, isNew?currentTheme->waterfallNew:currentTheme->waterfallHover);
} else { } else {
@ -534,8 +534,8 @@ void WaterfallCanvas::OnMouseMoved(wxMouseEvent& event) {
double maxDist = ((double)halfBw + bufferBw); double maxDist = ((double)halfBw + bufferBw);
if ((double)dist <= maxDist) { if ((double)dist <= maxDist) {
if ((freqDiff > 0 && demod->getDemodulatorType() == DEMOD_TYPE_USB) || if ((freqDiff > 0 && demod->getDemodulatorType() == "USB") ||
(freqDiff < 0 && demod->getDemodulatorType() == DEMOD_TYPE_LSB)) { (freqDiff < 0 && demod->getDemodulatorType() == "LSB")) {
continue; continue;
} }
@ -565,12 +565,12 @@ void WaterfallCanvas::OnMouseMoved(wxMouseEvent& event) {
if (abs(freqDiff) > (activeDemodulator->getBandwidth() / 3)) { if (abs(freqDiff) > (activeDemodulator->getBandwidth() / 3)) {
if (freqDiff > 0) { if (freqDiff > 0) {
if (activeDemodulator->getDemodulatorType() != DEMOD_TYPE_USB) { if (activeDemodulator->getDemodulatorType() != "USB") {
nextDragState = WF_DRAG_BANDWIDTH_LEFT; nextDragState = WF_DRAG_BANDWIDTH_LEFT;
SetCursor(wxCURSOR_SIZEWE); SetCursor(wxCURSOR_SIZEWE);
} }
} else { } else {
if (activeDemodulator->getDemodulatorType() != DEMOD_TYPE_LSB) { if (activeDemodulator->getDemodulatorType() != "LSB") {
nextDragState = WF_DRAG_BANDWIDTH_RIGHT; nextDragState = WF_DRAG_BANDWIDTH_RIGHT;
SetCursor(wxCURSOR_SIZEWE); SetCursor(wxCURSOR_SIZEWE);
} }
@ -712,9 +712,9 @@ void WaterfallCanvas::OnMouseReleased(wxMouseEvent& event) {
float width = mouseTracker.getOriginDeltaMouseX(); float width = mouseTracker.getOriginDeltaMouseX();
float pos; 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 pos1 = mouseTracker.getOriginMouseX();
float pos2 = mouseTracker.getMouseX(); float pos2 = mouseTracker.getMouseX();
@ -724,7 +724,7 @@ void WaterfallCanvas::OnMouseReleased(wxMouseEvent& event) {
pos2 = tmp; pos2 = tmp;
} }
pos = (last_type == DEMOD_TYPE_LSB)?pos2:pos1; pos = (last_type == "LSB")?pos2:pos1;
width *= 2; width *= 2;
} else { } else {
pos = mouseTracker.getOriginMouseX() + width / 2.0; pos = mouseTracker.getOriginMouseX() + width / 2.0;