mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2025-09-05 06:37:52 -04:00
Demodulator options persist and apply to newly created
This commit is contained in:
parent
b4e4f3017f
commit
524cfbe0df
@ -48,6 +48,7 @@ AppFrame::AppFrame() :
|
|||||||
demodModeSelector->addChoice(DEMOD_TYPE_LSB, "LSB");
|
demodModeSelector->addChoice(DEMOD_TYPE_LSB, "LSB");
|
||||||
demodModeSelector->addChoice(DEMOD_TYPE_USB, "USB");
|
demodModeSelector->addChoice(DEMOD_TYPE_USB, "USB");
|
||||||
demodModeSelector->addChoice(DEMOD_TYPE_DSB, "DSB");
|
demodModeSelector->addChoice(DEMOD_TYPE_DSB, "DSB");
|
||||||
|
demodModeSelector->setSelection(DEMOD_TYPE_FM);
|
||||||
demodTray->Add(demodModeSelector, 2, wxEXPAND | wxALL, 0);
|
demodTray->Add(demodModeSelector, 2, wxEXPAND | wxALL, 0);
|
||||||
|
|
||||||
// demodTray->AddSpacer(2);
|
// demodTray->AddSpacer(2);
|
||||||
@ -209,11 +210,11 @@ AppFrame::AppFrame() :
|
|||||||
devName.append(" (In Use?)");
|
devName.append(" (In Use?)");
|
||||||
}
|
}
|
||||||
|
|
||||||
menu->AppendRadioItem(wxID_DEVICE_ID+p, devName)->Check(wxGetApp().getDevice() == p);
|
menu->AppendRadioItem(wxID_DEVICE_ID + p, devName)->Check(wxGetApp().getDevice() == p);
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
|
|
||||||
menuBar->Append(menu,wxT("&Device"));
|
menuBar->Append(menu, wxT("&Device"));
|
||||||
}
|
}
|
||||||
|
|
||||||
SetMenuBar(menuBar);
|
SetMenuBar(menuBar);
|
||||||
@ -322,8 +323,8 @@ void AppFrame::OnMenu(wxCommandEvent& event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<SDRDeviceInfo *> *devs = wxGetApp().getDevices();
|
std::vector<SDRDeviceInfo *> *devs = wxGetApp().getDevices();
|
||||||
if (event.GetId() >= wxID_DEVICE_ID && event.GetId() <= wxID_DEVICE_ID+devs->size()) {
|
if (event.GetId() >= wxID_DEVICE_ID && event.GetId() <= wxID_DEVICE_ID + devs->size()) {
|
||||||
wxGetApp().setDevice(event.GetId()-wxID_DEVICE_ID);
|
wxGetApp().setDevice(event.GetId() - wxID_DEVICE_ID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -389,6 +390,21 @@ void AppFrame::OnIdle(wxIdleEvent& event) {
|
|||||||
demodGainMeter->setLevel(demodGainMeter->getInputValue());
|
demodGainMeter->setLevel(demodGainMeter->getInputValue());
|
||||||
}
|
}
|
||||||
activeDemodulator = demod;
|
activeDemodulator = demod;
|
||||||
|
} else {
|
||||||
|
DemodulatorMgr *mgr = &wxGetApp().getDemodMgr();
|
||||||
|
|
||||||
|
int dSelection = demodModeSelector->getSelection();
|
||||||
|
if (dSelection != -1 && dSelection != mgr->getLastDemodulatorType()) {
|
||||||
|
mgr->setLastDemodulatorType(dSelection);
|
||||||
|
}
|
||||||
|
demodGainMeter->setLevel(mgr->getLastGain());
|
||||||
|
if (demodSignalMeter->inputChanged()) {
|
||||||
|
mgr->setLastSquelchLevel(demodSignalMeter->getInputValue());
|
||||||
|
}
|
||||||
|
if (demodGainMeter->inputChanged()) {
|
||||||
|
mgr->setLastGain(demodGainMeter->getInputValue());
|
||||||
|
demodGainMeter->setLevel(demodGainMeter->getInputValue());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!waterfallCanvas->HasFocus()) {
|
if (!waterfallCanvas->HasFocus()) {
|
||||||
|
@ -28,6 +28,8 @@ const char filePathSeparator =
|
|||||||
|
|
||||||
#define DEFAULT_FREQ 100000000
|
#define DEFAULT_FREQ 100000000
|
||||||
#define AUDIO_FREQUENCY 44100
|
#define AUDIO_FREQUENCY 44100
|
||||||
|
#define DEFAULT_DEMOD_TYPE 1
|
||||||
|
#define DEFAULT_DEMOD_BW 200000
|
||||||
|
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
|
@ -6,7 +6,8 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
DemodulatorMgr::DemodulatorMgr() :
|
DemodulatorMgr::DemodulatorMgr() :
|
||||||
activeDemodulator(NULL), lastActiveDemodulator(NULL), activeVisualDemodulator(NULL) {
|
activeDemodulator(NULL), lastActiveDemodulator(NULL), activeVisualDemodulator(NULL), lastBandwidth(DEFAULT_DEMOD_BW), lastDemodType(
|
||||||
|
DEFAULT_DEMOD_TYPE), lastGain(1.0), lastSquelch(0), lastSquelchEnabled(false), lastStereo(false) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,6 +92,7 @@ void DemodulatorMgr::setActiveDemodulator(DemodulatorInstance *demod, bool tempo
|
|||||||
} else {
|
} else {
|
||||||
lastActiveDemodulator = demod;
|
lastActiveDemodulator = demod;
|
||||||
}
|
}
|
||||||
|
updateLastState();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (activeVisualDemodulator) {
|
if (activeVisualDemodulator) {
|
||||||
@ -117,9 +119,7 @@ DemodulatorInstance *DemodulatorMgr::getActiveDemodulator() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
DemodulatorInstance *DemodulatorMgr::getLastActiveDemodulator() {
|
DemodulatorInstance *DemodulatorMgr::getLastActiveDemodulator() {
|
||||||
if (std::find(demods.begin(), demods.end(), lastActiveDemodulator) == demods.end()) {
|
updateLastState();
|
||||||
lastActiveDemodulator = activeDemodulator;
|
|
||||||
}
|
|
||||||
|
|
||||||
return lastActiveDemodulator;
|
return lastActiveDemodulator;
|
||||||
}
|
}
|
||||||
@ -142,3 +142,72 @@ void DemodulatorMgr::garbageCollect() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DemodulatorMgr::updateLastState() {
|
||||||
|
if (std::find(demods.begin(), demods.end(), lastActiveDemodulator) == demods.end()) {
|
||||||
|
lastActiveDemodulator = activeDemodulator;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lastActiveDemodulator) {
|
||||||
|
lastBandwidth = lastActiveDemodulator->getBandwidth();
|
||||||
|
lastDemodType = lastActiveDemodulator->getDemodulatorType();
|
||||||
|
lastSquelchEnabled = lastActiveDemodulator->isSquelchEnabled();
|
||||||
|
lastSquelch = lastActiveDemodulator->getSquelchLevel();
|
||||||
|
lastGain = lastActiveDemodulator->getGain();
|
||||||
|
lastStereo = lastActiveDemodulator->isStereo();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int DemodulatorMgr::getLastBandwidth() const {
|
||||||
|
return lastBandwidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DemodulatorMgr::setLastBandwidth(int lastBandwidth) {
|
||||||
|
if (lastBandwidth < 1500) {
|
||||||
|
lastBandwidth = 1500;
|
||||||
|
} else if (lastBandwidth > wxGetApp().getSampleRate()) {
|
||||||
|
lastBandwidth = wxGetApp().getSampleRate();
|
||||||
|
}
|
||||||
|
this->lastBandwidth = lastBandwidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
int DemodulatorMgr::getLastDemodulatorType() const {
|
||||||
|
return lastDemodType;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DemodulatorMgr::setLastDemodulatorType(int lastDemodType) {
|
||||||
|
this->lastDemodType = lastDemodType;
|
||||||
|
}
|
||||||
|
|
||||||
|
float DemodulatorMgr::getLastGain() const {
|
||||||
|
return lastGain;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DemodulatorMgr::setLastGain(float lastGain) {
|
||||||
|
this->lastGain = lastGain;
|
||||||
|
}
|
||||||
|
|
||||||
|
float DemodulatorMgr::getLastSquelchLevel() const {
|
||||||
|
return lastSquelch;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DemodulatorMgr::setLastSquelchLevel(float lastSquelch) {
|
||||||
|
this->lastSquelch = lastSquelch;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DemodulatorMgr::isLastSquelchEnabled() const {
|
||||||
|
return lastSquelchEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DemodulatorMgr::setLastSquelchEnabled(bool lastSquelchEnabled) {
|
||||||
|
this->lastSquelchEnabled = lastSquelchEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DemodulatorMgr::isLastStereo() const {
|
||||||
|
return lastStereo;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DemodulatorMgr::setLastStereo(bool lastStereo) {
|
||||||
|
this->lastStereo = lastStereo;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -22,8 +22,27 @@ public:
|
|||||||
DemodulatorInstance *getActiveDemodulator();
|
DemodulatorInstance *getActiveDemodulator();
|
||||||
DemodulatorInstance *getLastActiveDemodulator();
|
DemodulatorInstance *getLastActiveDemodulator();
|
||||||
|
|
||||||
|
int getLastBandwidth() const;
|
||||||
|
void setLastBandwidth(int lastBandwidth);
|
||||||
|
|
||||||
|
int getLastDemodulatorType() const;
|
||||||
|
void setLastDemodulatorType(int lastDemodType);
|
||||||
|
|
||||||
|
float getLastGain() const;
|
||||||
|
void setLastGain(float lastGain);
|
||||||
|
|
||||||
|
float getLastSquelchLevel() const;
|
||||||
|
void setLastSquelchLevel(float lastSquelch);
|
||||||
|
|
||||||
|
bool isLastSquelchEnabled() const;
|
||||||
|
void setLastSquelchEnabled(bool lastSquelchEnabled);
|
||||||
|
|
||||||
|
bool isLastStereo() const;
|
||||||
|
void setLastStereo(bool lastStereo);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void garbageCollect();
|
void garbageCollect();
|
||||||
|
void updateLastState();
|
||||||
|
|
||||||
std::vector<DemodulatorInstance *> demods;
|
std::vector<DemodulatorInstance *> demods;
|
||||||
std::vector<DemodulatorInstance *> demods_deleted;
|
std::vector<DemodulatorInstance *> demods_deleted;
|
||||||
@ -31,4 +50,10 @@ private:
|
|||||||
DemodulatorInstance *lastActiveDemodulator;
|
DemodulatorInstance *lastActiveDemodulator;
|
||||||
DemodulatorInstance *activeVisualDemodulator;
|
DemodulatorInstance *activeVisualDemodulator;
|
||||||
|
|
||||||
|
int lastBandwidth;
|
||||||
|
int lastDemodType;
|
||||||
|
bool lastSquelchEnabled;
|
||||||
|
float lastSquelch;
|
||||||
|
float lastGain;
|
||||||
|
bool lastStereo;
|
||||||
};
|
};
|
||||||
|
@ -56,7 +56,7 @@ void DemodulatorThread::threadMain() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsigned int h_len = estimate_req_filter_len(ft, As);
|
unsigned int h_len = estimate_req_filter_len(ft, As);
|
||||||
float *h = new float[h_len];
|
float *h = new float[h_len];
|
||||||
liquid_firdes_kaiser(h_len, firStereoCutoff, As, mu, h);
|
liquid_firdes_kaiser(h_len, firStereoCutoff, As, mu, h);
|
||||||
|
|
||||||
firStereoLeft = firfilt_rrrf_create(h, h_len);
|
firStereoLeft = firfilt_rrrf_create(h, h_len);
|
||||||
@ -83,7 +83,7 @@ void DemodulatorThread::threadMain() {
|
|||||||
float ssbAs = 120.0f; // stop-band attenuation [dB]
|
float ssbAs = 120.0f; // stop-band attenuation [dB]
|
||||||
|
|
||||||
h_len = estimate_req_filter_len(ssbFt, ssbAs);
|
h_len = estimate_req_filter_len(ssbFt, ssbAs);
|
||||||
float *ssb_h=new float[h_len];
|
float *ssb_h = new float[h_len];
|
||||||
liquid_firdes_kaiser(h_len, 0.25, ssbAs, 0.0, ssb_h);
|
liquid_firdes_kaiser(h_len, 0.25, ssbAs, 0.0, ssb_h);
|
||||||
|
|
||||||
firfilt_crcf firSSB = firfilt_crcf_create(ssb_h, h_len);
|
firfilt_crcf firSSB = firfilt_crcf_create(ssb_h, h_len);
|
||||||
@ -99,6 +99,23 @@ void DemodulatorThread::threadMain() {
|
|||||||
|
|
||||||
std::cout << "Demodulator thread started.." << std::endl;
|
std::cout << "Demodulator thread started.." << std::endl;
|
||||||
|
|
||||||
|
switch (demodulatorType) {
|
||||||
|
case DEMOD_TYPE_FM:
|
||||||
|
break;
|
||||||
|
case DEMOD_TYPE_LSB:
|
||||||
|
demodAM = demodAM_USB;
|
||||||
|
break;
|
||||||
|
case DEMOD_TYPE_USB:
|
||||||
|
demodAM = demodAM_LSB;
|
||||||
|
break;
|
||||||
|
case DEMOD_TYPE_DSB:
|
||||||
|
demodAM = demodAM_DSB;
|
||||||
|
break;
|
||||||
|
case DEMOD_TYPE_AM:
|
||||||
|
demodAM = demodAM_DSB_CSP;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
terminated = false;
|
terminated = false;
|
||||||
|
|
||||||
while (!terminated) {
|
while (!terminated) {
|
||||||
|
@ -275,7 +275,7 @@ void PrimaryGLContext::DrawFreqSelector(float uxPos, float r, float g, float b,
|
|||||||
long long bw = 0;
|
long long bw = 0;
|
||||||
|
|
||||||
if (!demod) {
|
if (!demod) {
|
||||||
bw = defaultDemodParams.bandwidth;
|
bw = wxGetApp().getDemodMgr().getLastBandwidth();
|
||||||
} else {
|
} else {
|
||||||
bw = demod->getBandwidth();
|
bw = demod->getBandwidth();
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ void TuningCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
|
|||||||
if (activeDemod != NULL) {
|
if (activeDemod != NULL) {
|
||||||
glContext->DrawDemodFreqBw(activeDemod->getFrequency(), activeDemod->getBandwidth(), wxGetApp().getFrequency());
|
glContext->DrawDemodFreqBw(activeDemod->getFrequency(), activeDemod->getBandwidth(), wxGetApp().getFrequency());
|
||||||
} else {
|
} else {
|
||||||
glContext->DrawDemodFreqBw(0, 0, wxGetApp().getFrequency());
|
glContext->DrawDemodFreqBw(0, wxGetApp().getDemodMgr().getLastBandwidth(), wxGetApp().getFrequency());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mouseTracker.mouseDown()) {
|
if (mouseTracker.mouseDown()) {
|
||||||
@ -76,10 +76,17 @@ void TuningCanvas::OnIdle(wxIdleEvent &event) {
|
|||||||
wxGetApp().getFrequency()
|
wxGetApp().getFrequency()
|
||||||
+ (int) (dragAccum * fabs(dragAccum * 10.0) * fabs(dragAccum * 10.0) * (float) wxGetApp().getSampleRate()));
|
+ (int) (dragAccum * fabs(dragAccum * 10.0) * fabs(dragAccum * 10.0) * (float) wxGetApp().getSampleRate()));
|
||||||
} else if (fabs(moveVal) >= 1.0) {
|
} else if (fabs(moveVal) >= 1.0) {
|
||||||
if (uxDown < -0.275 && activeDemod != NULL) {
|
if (uxDown < -0.275) {
|
||||||
activeDemod->setFrequency(activeDemod->getFrequency() + (int) (moveVal * fabs(moveVal) * fabs(moveVal) * fabs(moveVal)));
|
if (activeDemod != NULL) {
|
||||||
} else if (activeDemod != NULL) {
|
activeDemod->setFrequency(activeDemod->getFrequency() + (int) (moveVal * fabs(moveVal) * fabs(moveVal) * fabs(moveVal)));
|
||||||
activeDemod->setBandwidth(activeDemod->getBandwidth() + (int) (moveVal * fabs(moveVal) * fabs(moveVal) * fabs(moveVal)));
|
}
|
||||||
|
} else {
|
||||||
|
int amt = (int) (moveVal * fabs(moveVal) * fabs(moveVal) * fabs(moveVal));
|
||||||
|
if (activeDemod != NULL) {
|
||||||
|
activeDemod->setBandwidth(activeDemod->getBandwidth() + amt);
|
||||||
|
} else {
|
||||||
|
wxGetApp().getDemodMgr().setLastBandwidth(wxGetApp().getDemodMgr().getLastBandwidth() + amt);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ void TuningContext::DrawDemodFreqBw(long long freq, unsigned int bw, long long c
|
|||||||
glColor3f(ThemeMgr::mgr.currentTheme->text.r, ThemeMgr::mgr.currentTheme->text.g, ThemeMgr::mgr.currentTheme->text.b);
|
glColor3f(ThemeMgr::mgr.currentTheme->text.r, ThemeMgr::mgr.currentTheme->text.g, ThemeMgr::mgr.currentTheme->text.b);
|
||||||
|
|
||||||
getFont(fontSize).drawString("Freq: ", -0.75, 0, fontHeight, GLFont::GLFONT_ALIGN_RIGHT, GLFont::GLFONT_ALIGN_CENTER);
|
getFont(fontSize).drawString("Freq: ", -0.75, 0, fontHeight, GLFont::GLFONT_ALIGN_RIGHT, GLFont::GLFONT_ALIGN_CENTER);
|
||||||
if (bw) {
|
if (freq) {
|
||||||
freqStr.str("");
|
freqStr.str("");
|
||||||
freqStr << std::fixed << freq << " Hz";
|
freqStr << std::fixed << freq << " Hz";
|
||||||
} else {
|
} else {
|
||||||
|
@ -753,6 +753,7 @@ void WaterfallCanvas::OnMouseReleased(wxMouseEvent& event) {
|
|||||||
mouseTracker.setHorizDragLock(false);
|
mouseTracker.setHorizDragLock(false);
|
||||||
|
|
||||||
DemodulatorInstance *demod;
|
DemodulatorInstance *demod;
|
||||||
|
DemodulatorMgr *mgr = &wxGetApp().getDemodMgr();
|
||||||
|
|
||||||
if (mouseTracker.getOriginDeltaMouseX() == 0 && mouseTracker.getOriginDeltaMouseY() == 0) {
|
if (mouseTracker.getOriginDeltaMouseX() == 0 && mouseTracker.getOriginDeltaMouseY() == 0) {
|
||||||
float pos = mouseTracker.getMouseX();
|
float pos = mouseTracker.getMouseX();
|
||||||
@ -767,14 +768,12 @@ void WaterfallCanvas::OnMouseReleased(wxMouseEvent& event) {
|
|||||||
demod = wxGetApp().getDemodMgr().newThread();
|
demod = wxGetApp().getDemodMgr().newThread();
|
||||||
demod->setFrequency(freq);
|
demod->setFrequency(freq);
|
||||||
|
|
||||||
if (DemodulatorInstance *last = wxGetApp().getDemodMgr().getLastActiveDemodulator()) {
|
demod->setBandwidth(mgr->getLastBandwidth());
|
||||||
demod->setBandwidth(last->getBandwidth());
|
demod->setDemodulatorType(mgr->getLastDemodulatorType());
|
||||||
demod->setDemodulatorType(last->getDemodulatorType());
|
demod->setSquelchLevel(mgr->getLastSquelchLevel());
|
||||||
demod->setSquelchLevel(last->getSquelchLevel());
|
demod->setSquelchEnabled(mgr->isLastSquelchEnabled());
|
||||||
demod->setSquelchEnabled(last->isSquelchEnabled());
|
demod->setStereo(mgr->isLastStereo());
|
||||||
demod->setStereo(last->isStereo());
|
demod->setGain(mgr->getLastGain());
|
||||||
demod->setGain(last->getGain());
|
|
||||||
}
|
|
||||||
|
|
||||||
demod->run();
|
demod->run();
|
||||||
|
|
||||||
@ -828,13 +827,13 @@ void WaterfallCanvas::OnMouseReleased(wxMouseEvent& event) {
|
|||||||
demod = wxGetApp().getDemodMgr().newThread();
|
demod = wxGetApp().getDemodMgr().newThread();
|
||||||
demod->setFrequency(freq);
|
demod->setFrequency(freq);
|
||||||
demod->setBandwidth(bw);
|
demod->setBandwidth(bw);
|
||||||
if (DemodulatorInstance *last = wxGetApp().getDemodMgr().getLastActiveDemodulator()) {
|
|
||||||
demod->setDemodulatorType(last->getDemodulatorType());
|
demod->setDemodulatorType(mgr->getLastDemodulatorType());
|
||||||
demod->setSquelchLevel(last->getSquelchLevel());
|
demod->setSquelchLevel(mgr->getLastSquelchLevel());
|
||||||
demod->setSquelchEnabled(last->isSquelchEnabled());
|
demod->setSquelchEnabled(mgr->isLastSquelchEnabled());
|
||||||
demod->setStereo(last->isStereo());
|
demod->setStereo(mgr->isLastStereo());
|
||||||
demod->setGain(last->getGain());
|
demod->setGain(mgr->getLastGain());
|
||||||
}
|
|
||||||
demod->run();
|
demod->run();
|
||||||
|
|
||||||
wxGetApp().bindDemodulator(demod);
|
wxGetApp().bindDemodulator(demod);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user