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);
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++;

View File

@ -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

View File

@ -7,23 +7,23 @@
#include <atomic>
#include <mutex>
#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") {
}

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;
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);

View File

@ -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<std::string *> 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;

View File

@ -76,7 +76,7 @@ std::vector<DemodulatorInstance *> *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;
}

View File

@ -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;

View File

@ -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;

View File

@ -37,13 +37,13 @@ protected:
double iqResampleRatio;
std::vector<liquid_float_complex> 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;

View File

@ -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;
}

View File

@ -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;

View File

@ -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 {

View File

@ -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) {

View File

@ -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();

View File

@ -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);

View File

@ -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;