mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2024-12-25 02:18:30 +01:00
Added persistant setting sto demodulator of radio module
This commit is contained in:
parent
fc9e155481
commit
80badebb37
@ -164,7 +164,6 @@ void windowInit() {
|
||||
// Have a good directory system on both linux and windows
|
||||
// Switch to double buffering (should fix occassional underruns)
|
||||
// Fix gain not updated on startup, soapysdr
|
||||
// Fix memory leak when enabling and disabling repeatedly
|
||||
|
||||
// TODO for 0.2.6
|
||||
// Add a module add/remove/change order menu
|
||||
|
@ -5,20 +5,38 @@
|
||||
#include <dsp/filter.h>
|
||||
#include <dsp/audio.h>
|
||||
#include <string>
|
||||
#include <config.h>
|
||||
#include <imgui.h>
|
||||
|
||||
class AMDemodulator : public Demodulator {
|
||||
public:
|
||||
AMDemodulator() {}
|
||||
AMDemodulator(std::string prefix, VFOManager::VFO* vfo, float audioSampleRate, float bandWidth) {
|
||||
init(prefix, vfo, audioSampleRate, bandWidth);
|
||||
AMDemodulator(std::string prefix, VFOManager::VFO* vfo, float audioSampleRate, float bandWidth, ConfigManager* config) {
|
||||
init(prefix, vfo, audioSampleRate, bandWidth, config);
|
||||
}
|
||||
|
||||
void init(std::string prefix, VFOManager::VFO* vfo, float audioSampleRate, float bandWidth) {
|
||||
void init(std::string prefix, VFOManager::VFO* vfo, float audioSampleRate, float bandWidth, ConfigManager* config) {
|
||||
uiPrefix = prefix;
|
||||
_vfo = vfo;
|
||||
audioSampRate = audioSampleRate;
|
||||
bw = bandWidth;
|
||||
_config = config;
|
||||
|
||||
_config->aquire();
|
||||
if(_config->conf.contains(prefix)) {
|
||||
if(!_config->conf[prefix].contains("AM")) {
|
||||
_config->conf[prefix]["AM"]["bandwidth"] = bw;
|
||||
_config->conf[prefix]["AM"]["snapInterval"] = snapInterval;
|
||||
}
|
||||
json conf = _config->conf[prefix]["AM"];
|
||||
bw = conf["bandwidth"];
|
||||
snapInterval = conf["snapInterval"];
|
||||
}
|
||||
else {
|
||||
_config->conf[prefix]["AM"]["bandwidth"] = bw;
|
||||
_config->conf[prefix]["AM"]["snapInterval"] = snapInterval;
|
||||
}
|
||||
_config->release(true);
|
||||
|
||||
demod.init(_vfo->output);
|
||||
|
||||
@ -99,6 +117,9 @@ public:
|
||||
if (ImGui::InputFloat(("##_radio_am_bw_" + uiPrefix).c_str(), &bw, 1, 100, 0)) {
|
||||
bw = std::clamp<float>(bw, bwMin, bwMax);
|
||||
setBandwidth(bw);
|
||||
_config->aquire();
|
||||
_config->conf[uiPrefix]["AM"]["bandwidth"] = bw;
|
||||
_config->release(true);
|
||||
}
|
||||
|
||||
ImGui::Text("Snap Interval");
|
||||
@ -106,6 +127,9 @@ public:
|
||||
ImGui::SetNextItemWidth(menuWidth - ImGui::GetCursorPosX());
|
||||
if (ImGui::InputFloat(("##_radio_am_snap_" + uiPrefix).c_str(), &snapInterval, 1, 100, 0)) {
|
||||
setSnapInterval(snapInterval);
|
||||
_config->aquire();
|
||||
_config->conf[uiPrefix]["AM"]["snapInterval"] = snapInterval;
|
||||
_config->release(true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -137,4 +161,6 @@ private:
|
||||
dsp::PolyphaseResampler<float> resamp;
|
||||
dsp::MonoToStereo m2s;
|
||||
|
||||
ConfigManager* _config;
|
||||
|
||||
};
|
@ -8,20 +8,38 @@
|
||||
#include <dsp/math.h>
|
||||
#include <dsp/audio.h>
|
||||
#include <string>
|
||||
#include <config.h>
|
||||
#include <imgui.h>
|
||||
|
||||
class CWDemodulator : public Demodulator {
|
||||
public:
|
||||
CWDemodulator() {}
|
||||
CWDemodulator(std::string prefix, VFOManager::VFO* vfo, float audioSampleRate, float bandWidth) {
|
||||
init(prefix, vfo, audioSampleRate, bandWidth);
|
||||
CWDemodulator(std::string prefix, VFOManager::VFO* vfo, float audioSampleRate, float bandWidth, ConfigManager* config) {
|
||||
init(prefix, vfo, audioSampleRate, bandWidth, config);
|
||||
}
|
||||
|
||||
void init(std::string prefix, VFOManager::VFO* vfo, float audioSampleRate, float bandWidth) {
|
||||
void init(std::string prefix, VFOManager::VFO* vfo, float audioSampleRate, float bandWidth, ConfigManager* config) {
|
||||
uiPrefix = prefix;
|
||||
_vfo = vfo;
|
||||
audioSampRate = audioSampleRate;
|
||||
bw = bandWidth;
|
||||
_config = config;
|
||||
|
||||
_config->aquire();
|
||||
if(_config->conf.contains(prefix)) {
|
||||
if(!_config->conf[prefix].contains("CW")) {
|
||||
_config->conf[prefix]["CW"]["bandwidth"] = bw;
|
||||
_config->conf[prefix]["CW"]["snapInterval"] = snapInterval;
|
||||
}
|
||||
json conf = _config->conf[prefix]["CW"];
|
||||
bw = conf["bandwidth"];
|
||||
snapInterval = conf["snapInterval"];
|
||||
}
|
||||
else {
|
||||
_config->conf[prefix]["CW"]["bandwidth"] = bw;
|
||||
_config->conf[prefix]["CW"]["snapInterval"] = snapInterval;
|
||||
}
|
||||
_config->release(true);
|
||||
|
||||
float audioBW = std::min<float>(audioSampRate / 2.0f, bw / 2.0f);
|
||||
win.init(audioBW, audioBW, bbSampRate);
|
||||
@ -109,6 +127,9 @@ public:
|
||||
if (ImGui::InputFloat(("##_radio_cw_bw_" + uiPrefix).c_str(), &bw, 1, 100, 0)) {
|
||||
bw = std::clamp<float>(bw, bwMin, bwMax);
|
||||
setBandwidth(bw);
|
||||
_config->aquire();
|
||||
_config->conf[uiPrefix]["CW"]["bandwidth"] = bw;
|
||||
_config->release(true);
|
||||
}
|
||||
|
||||
ImGui::Text("Snap Interval");
|
||||
@ -116,6 +137,9 @@ public:
|
||||
ImGui::SetNextItemWidth(menuWidth - ImGui::GetCursorPosX());
|
||||
if (ImGui::InputFloat(("##_radio_cw_snap_" + uiPrefix).c_str(), &snapInterval, 1, 100, 0)) {
|
||||
setSnapInterval(snapInterval);
|
||||
_config->aquire();
|
||||
_config->conf[uiPrefix]["CW"]["snapInterval"] = snapInterval;
|
||||
_config->release(true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -148,4 +172,6 @@ private:
|
||||
dsp::AGC agc;
|
||||
dsp::MonoToStereo m2s;
|
||||
|
||||
ConfigManager* _config;
|
||||
|
||||
};
|
@ -5,20 +5,38 @@
|
||||
#include <dsp/filter.h>
|
||||
#include <dsp/audio.h>
|
||||
#include <string>
|
||||
#include <config.h>
|
||||
#include <imgui.h>
|
||||
|
||||
class DSBDemodulator : public Demodulator {
|
||||
public:
|
||||
DSBDemodulator() {}
|
||||
DSBDemodulator(std::string prefix, VFOManager::VFO* vfo, float audioSampleRate, float bandWidth) {
|
||||
init(prefix, vfo, audioSampleRate, bandWidth);
|
||||
DSBDemodulator(std::string prefix, VFOManager::VFO* vfo, float audioSampleRate, float bandWidth, ConfigManager* config) {
|
||||
init(prefix, vfo, audioSampleRate, bandWidth, config);
|
||||
}
|
||||
|
||||
void init(std::string prefix, VFOManager::VFO* vfo, float audioSampleRate, float bandWidth) {
|
||||
void init(std::string prefix, VFOManager::VFO* vfo, float audioSampleRate, float bandWidth, ConfigManager* config) {
|
||||
uiPrefix = prefix;
|
||||
_vfo = vfo;
|
||||
audioSampRate = audioSampleRate;
|
||||
bw = bandWidth;
|
||||
_config = config;
|
||||
|
||||
_config->aquire();
|
||||
if(_config->conf.contains(prefix)) {
|
||||
if(!_config->conf[prefix].contains("DSB")) {
|
||||
_config->conf[prefix]["DSB"]["bandwidth"] = bw;
|
||||
_config->conf[prefix]["DSB"]["snapInterval"] = snapInterval;
|
||||
}
|
||||
json conf = _config->conf[prefix]["DSB"];
|
||||
bw = conf["bandwidth"];
|
||||
snapInterval = conf["snapInterval"];
|
||||
}
|
||||
else {
|
||||
_config->conf[prefix]["DSB"]["bandwidth"] = bw;
|
||||
_config->conf[prefix]["DSB"]["snapInterval"] = snapInterval;
|
||||
}
|
||||
_config->release(true);
|
||||
|
||||
demod.init(_vfo->output, bbSampRate, bandWidth, dsp::SSBDemod::MODE_DSB);
|
||||
|
||||
@ -99,6 +117,9 @@ public:
|
||||
if (ImGui::InputFloat(("##_radio_dsb_bw_" + uiPrefix).c_str(), &bw, 1, 100, 0)) {
|
||||
bw = std::clamp<float>(bw, bwMin, bwMax);
|
||||
setBandwidth(bw);
|
||||
_config->aquire();
|
||||
_config->conf[uiPrefix]["DSB"]["bandwidth"] = bw;
|
||||
_config->release(true);
|
||||
}
|
||||
|
||||
ImGui::Text("Snap Interval");
|
||||
@ -106,6 +127,9 @@ public:
|
||||
ImGui::SetNextItemWidth(menuWidth - ImGui::GetCursorPosX());
|
||||
if (ImGui::InputFloat(("##_radio_dsb_snap_" + uiPrefix).c_str(), &snapInterval, 1, 100, 0)) {
|
||||
setSnapInterval(snapInterval);
|
||||
_config->aquire();
|
||||
_config->conf[uiPrefix]["DSB"]["snapInterval"] = snapInterval;
|
||||
_config->release(true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -137,4 +161,6 @@ private:
|
||||
dsp::PolyphaseResampler<float> resamp;
|
||||
dsp::MonoToStereo m2s;
|
||||
|
||||
ConfigManager* _config;
|
||||
|
||||
};
|
@ -5,20 +5,38 @@
|
||||
#include <dsp/filter.h>
|
||||
#include <dsp/audio.h>
|
||||
#include <string>
|
||||
#include <config.h>
|
||||
#include <imgui.h>
|
||||
|
||||
class FMDemodulator : public Demodulator {
|
||||
public:
|
||||
FMDemodulator() {}
|
||||
FMDemodulator(std::string prefix, VFOManager::VFO* vfo, float audioSampleRate, float bandWidth) {
|
||||
init(prefix, vfo, audioSampleRate, bandWidth);
|
||||
FMDemodulator(std::string prefix, VFOManager::VFO* vfo, float audioSampleRate, float bandWidth, ConfigManager* config) {
|
||||
init(prefix, vfo, audioSampleRate, bandWidth, config);
|
||||
}
|
||||
|
||||
void init(std::string prefix, VFOManager::VFO* vfo, float audioSampleRate, float bandWidth) {
|
||||
void init(std::string prefix, VFOManager::VFO* vfo, float audioSampleRate, float bandWidth, ConfigManager* config) {
|
||||
uiPrefix = prefix;
|
||||
_vfo = vfo;
|
||||
audioSampRate = audioSampleRate;
|
||||
bw = bandWidth;
|
||||
_config = config;
|
||||
|
||||
_config->aquire();
|
||||
if(_config->conf.contains(prefix)) {
|
||||
if(!_config->conf[prefix].contains("FM")) {
|
||||
_config->conf[prefix]["FM"]["bandwidth"] = bw;
|
||||
_config->conf[prefix]["FM"]["snapInterval"] = snapInterval;
|
||||
}
|
||||
json conf = _config->conf[prefix]["FM"];
|
||||
bw = conf["bandwidth"];
|
||||
snapInterval = conf["snapInterval"];
|
||||
}
|
||||
else {
|
||||
_config->conf[prefix]["FM"]["bandwidth"] = bw;
|
||||
_config->conf[prefix]["FM"]["snapInterval"] = snapInterval;
|
||||
}
|
||||
_config->release(true);
|
||||
|
||||
demod.init(_vfo->output, bbSampRate, bandWidth / 2.0f);
|
||||
|
||||
@ -95,6 +113,9 @@ public:
|
||||
if (ImGui::InputFloat(("##_radio_fm_bw_" + uiPrefix).c_str(), &bw, 1, 100, 0)) {
|
||||
bw = std::clamp<float>(bw, bwMin, bwMax);
|
||||
setBandwidth(bw);
|
||||
_config->aquire();
|
||||
_config->conf[uiPrefix]["FM"]["bandwidth"] = bw;
|
||||
_config->release(true);
|
||||
}
|
||||
|
||||
ImGui::Text("Snap Interval");
|
||||
@ -102,6 +123,9 @@ public:
|
||||
ImGui::SetNextItemWidth(menuWidth - ImGui::GetCursorPosX());
|
||||
if (ImGui::InputFloat(("##_radio_fm_snap_" + uiPrefix).c_str(), &snapInterval, 1, 100, 0)) {
|
||||
setSnapInterval(snapInterval);
|
||||
_config->aquire();
|
||||
_config->conf[uiPrefix]["FM"]["snapInterval"] = snapInterval;
|
||||
_config->release(true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -133,4 +157,6 @@ private:
|
||||
dsp::PolyphaseResampler<float> resamp;
|
||||
dsp::MonoToStereo m2s;
|
||||
|
||||
ConfigManager* _config;
|
||||
|
||||
};
|
@ -5,20 +5,38 @@
|
||||
#include <dsp/filter.h>
|
||||
#include <dsp/audio.h>
|
||||
#include <string>
|
||||
#include <config.h>
|
||||
#include <imgui.h>
|
||||
|
||||
class LSBDemodulator : public Demodulator {
|
||||
public:
|
||||
LSBDemodulator() {}
|
||||
LSBDemodulator(std::string prefix, VFOManager::VFO* vfo, float audioSampleRate, float bandWidth) {
|
||||
init(prefix, vfo, audioSampleRate, bandWidth);
|
||||
LSBDemodulator(std::string prefix, VFOManager::VFO* vfo, float audioSampleRate, float bandWidth, ConfigManager* config) {
|
||||
init(prefix, vfo, audioSampleRate, bandWidth, config);
|
||||
}
|
||||
|
||||
void init(std::string prefix, VFOManager::VFO* vfo, float audioSampleRate, float bandWidth) {
|
||||
void init(std::string prefix, VFOManager::VFO* vfo, float audioSampleRate, float bandWidth, ConfigManager* config) {
|
||||
uiPrefix = prefix;
|
||||
_vfo = vfo;
|
||||
audioSampRate = audioSampleRate;
|
||||
bw = bandWidth;
|
||||
_config = config;
|
||||
|
||||
_config->aquire();
|
||||
if(_config->conf.contains(prefix)) {
|
||||
if(!_config->conf[prefix].contains("LSB")) {
|
||||
_config->conf[prefix]["LSB"]["bandwidth"] = bw;
|
||||
_config->conf[prefix]["LSB"]["snapInterval"] = snapInterval;
|
||||
}
|
||||
json conf = _config->conf[prefix]["LSB"];
|
||||
bw = conf["bandwidth"];
|
||||
snapInterval = conf["snapInterval"];
|
||||
}
|
||||
else {
|
||||
_config->conf[prefix]["LSB"]["bandwidth"] = bw;
|
||||
_config->conf[prefix]["LSB"]["snapInterval"] = snapInterval;
|
||||
}
|
||||
_config->release(true);
|
||||
|
||||
demod.init(_vfo->output, bbSampRate, bandWidth, dsp::SSBDemod::MODE_LSB);
|
||||
|
||||
@ -99,6 +117,9 @@ public:
|
||||
if (ImGui::InputFloat(("##_radio_lsb_bw_" + uiPrefix).c_str(), &bw, 1, 100, 0)) {
|
||||
bw = std::clamp<float>(bw, bwMin, bwMax);
|
||||
setBandwidth(bw);
|
||||
_config->aquire();
|
||||
_config->conf[uiPrefix]["LSB"]["bandwidth"] = bw;
|
||||
_config->release(true);
|
||||
}
|
||||
|
||||
ImGui::Text("Snap Interval");
|
||||
@ -106,6 +127,9 @@ public:
|
||||
ImGui::SetNextItemWidth(menuWidth - ImGui::GetCursorPosX());
|
||||
if (ImGui::InputFloat(("##_radio_lsb_snap_" + uiPrefix).c_str(), &snapInterval, 1, 100, 0)) {
|
||||
setSnapInterval(snapInterval);
|
||||
_config->aquire();
|
||||
_config->conf[uiPrefix]["LSB"]["snapInterval"] = snapInterval;
|
||||
_config->release(true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -137,4 +161,6 @@ private:
|
||||
dsp::PolyphaseResampler<float> resamp;
|
||||
dsp::MonoToStereo m2s;
|
||||
|
||||
ConfigManager* _config;
|
||||
|
||||
};
|
@ -25,6 +25,8 @@ SDRPP_MOD_INFO {
|
||||
/* Max instances */ -1
|
||||
};
|
||||
|
||||
static ConfigManager config;
|
||||
|
||||
class RadioModule : public ModuleManager::Instance {
|
||||
public:
|
||||
RadioModule(std::string name) {
|
||||
@ -34,14 +36,21 @@ public:
|
||||
|
||||
ns.init(vfo->output);
|
||||
|
||||
wfmDemod.init(name, vfo, audioSampRate, 200000);
|
||||
fmDemod.init(name, vfo, audioSampRate, 12500);
|
||||
amDemod.init(name, vfo, audioSampRate, 12500);
|
||||
usbDemod.init(name, vfo, audioSampRate, 3000);
|
||||
lsbDemod.init(name, vfo, audioSampRate, 3000);
|
||||
dsbDemod.init(name, vfo, audioSampRate, 6000);
|
||||
rawDemod.init(name, vfo, audioSampRate, audioSampRate);
|
||||
cwDemod.init(name, vfo, audioSampRate, 200);
|
||||
config.aquire();
|
||||
if (!config.conf.contains(name)) {
|
||||
config.conf[name]["selectedDemodId"] = 1;
|
||||
}
|
||||
demodId = config.conf[name]["selectedDemodId"];
|
||||
config.release(true);
|
||||
|
||||
wfmDemod.init(name, vfo, audioSampRate, 200000, &config);
|
||||
fmDemod.init(name, vfo, audioSampRate, 12500, &config);
|
||||
amDemod.init(name, vfo, audioSampRate, 12500, &config);
|
||||
usbDemod.init(name, vfo, audioSampRate, 3000, &config);
|
||||
lsbDemod.init(name, vfo, audioSampRate, 3000, &config);
|
||||
dsbDemod.init(name, vfo, audioSampRate, 6000, &config);
|
||||
rawDemod.init(name, vfo, audioSampRate, audioSampRate, &config);
|
||||
cwDemod.init(name, vfo, audioSampRate, 200, &config);
|
||||
|
||||
srChangeHandler.ctx = this;
|
||||
srChangeHandler.handler = sampleRateChangeHandler;
|
||||
@ -52,6 +61,9 @@ public:
|
||||
demodId = 1;
|
||||
selectDemod(&wfmDemod);
|
||||
|
||||
// TODO: Remove the two above lines when implemented
|
||||
// selectDemodulatorByID(demodId);
|
||||
|
||||
stream.start();
|
||||
|
||||
gui::menu.registerEntry(name, menuHandler, this, this);
|
||||
@ -157,6 +169,10 @@ private:
|
||||
currentDemod->start();
|
||||
}
|
||||
|
||||
void selectDemodByID(int id) {
|
||||
// TODO: Implement
|
||||
}
|
||||
|
||||
std::string name;
|
||||
bool enabled = true;
|
||||
int demodId = 0;
|
||||
@ -182,7 +198,10 @@ private:
|
||||
};
|
||||
|
||||
MOD_EXPORT void _INIT_() {
|
||||
// Do your one time init here
|
||||
json def = json({});
|
||||
config.setPath(ROOT_DIR "/radio_config.json");
|
||||
config.load(def);
|
||||
config.enableAutoSave();
|
||||
}
|
||||
|
||||
MOD_EXPORT ModuleManager::Instance* _CREATE_INSTANCE_(std::string name) {
|
||||
@ -194,5 +213,6 @@ MOD_EXPORT void _DELETE_INSTANCE_(void* instance) {
|
||||
}
|
||||
|
||||
MOD_EXPORT void _END_() {
|
||||
// Do your one shutdown here
|
||||
config.disableAutoSave();
|
||||
config.save();
|
||||
}
|
@ -5,20 +5,35 @@
|
||||
#include <dsp/filter.h>
|
||||
#include <dsp/audio.h>
|
||||
#include <string>
|
||||
#include <config.h>
|
||||
#include <imgui.h>
|
||||
|
||||
class RAWDemodulator : public Demodulator {
|
||||
public:
|
||||
RAWDemodulator() {}
|
||||
RAWDemodulator(std::string prefix, VFOManager::VFO* vfo, float audioSampleRate, float bandWidth) {
|
||||
init(prefix, vfo, audioSampleRate, bandWidth);
|
||||
RAWDemodulator(std::string prefix, VFOManager::VFO* vfo, float audioSampleRate, float bandWidth, ConfigManager* config) {
|
||||
init(prefix, vfo, audioSampleRate, bandWidth, config);
|
||||
}
|
||||
|
||||
void init(std::string prefix, VFOManager::VFO* vfo, float audioSampleRate, float bandWidth) {
|
||||
void init(std::string prefix, VFOManager::VFO* vfo, float audioSampleRate, float bandWidth, ConfigManager* config) {
|
||||
uiPrefix = prefix;
|
||||
_vfo = vfo;
|
||||
audioSampRate = audioSampleRate;
|
||||
bw = bandWidth;
|
||||
_config = config;
|
||||
|
||||
_config->aquire();
|
||||
if(_config->conf.contains(prefix)) {
|
||||
if(!_config->conf[prefix].contains("RAW")) {
|
||||
_config->conf[prefix]["RAW"]["snapInterval"] = snapInterval;
|
||||
}
|
||||
json conf = _config->conf[prefix]["RAW"];
|
||||
snapInterval = conf["snapInterval"];
|
||||
}
|
||||
else {
|
||||
_config->conf[prefix]["RAW"]["snapInterval"] = snapInterval;
|
||||
}
|
||||
_config->release(true);
|
||||
|
||||
c2s.init(_vfo->output);
|
||||
}
|
||||
@ -75,6 +90,9 @@ public:
|
||||
ImGui::SetNextItemWidth(menuWidth - ImGui::GetCursorPosX());
|
||||
if (ImGui::InputFloat(("##_radio_raw_snap_" + uiPrefix).c_str(), &snapInterval, 1, 100, 0)) {
|
||||
setSnapInterval(snapInterval);
|
||||
_config->aquire();
|
||||
_config->conf[uiPrefix]["RAW"]["snapInterval"] = snapInterval;
|
||||
_config->release(true);
|
||||
}
|
||||
|
||||
// TODO: Allow selection of the bandwidth
|
||||
@ -95,4 +113,6 @@ private:
|
||||
VFOManager::VFO* _vfo;
|
||||
dsp::ComplexToStereo c2s;
|
||||
|
||||
ConfigManager* _config;
|
||||
|
||||
};
|
@ -5,20 +5,38 @@
|
||||
#include <dsp/filter.h>
|
||||
#include <dsp/audio.h>
|
||||
#include <string>
|
||||
#include <config.h>
|
||||
#include <imgui.h>
|
||||
|
||||
class USBDemodulator : public Demodulator {
|
||||
public:
|
||||
USBDemodulator() {}
|
||||
USBDemodulator(std::string prefix, VFOManager::VFO* vfo, float audioSampleRate, float bandWidth) {
|
||||
init(prefix, vfo, audioSampleRate, bandWidth);
|
||||
USBDemodulator(std::string prefix, VFOManager::VFO* vfo, float audioSampleRate, float bandWidth, ConfigManager* config) {
|
||||
init(prefix, vfo, audioSampleRate, bandWidth, config);
|
||||
}
|
||||
|
||||
void init(std::string prefix, VFOManager::VFO* vfo, float audioSampleRate, float bandWidth) {
|
||||
void init(std::string prefix, VFOManager::VFO* vfo, float audioSampleRate, float bandWidth, ConfigManager* config) {
|
||||
uiPrefix = prefix;
|
||||
_vfo = vfo;
|
||||
audioSampRate = audioSampleRate;
|
||||
bw = bandWidth;
|
||||
_config = config;
|
||||
|
||||
_config->aquire();
|
||||
if(_config->conf.contains(prefix)) {
|
||||
if(!_config->conf[prefix].contains("USB")) {
|
||||
_config->conf[prefix]["USB"]["bandwidth"] = bw;
|
||||
_config->conf[prefix]["USB"]["snapInterval"] = snapInterval;
|
||||
}
|
||||
json conf = _config->conf[prefix]["USB"];
|
||||
bw = conf["bandwidth"];
|
||||
snapInterval = conf["snapInterval"];
|
||||
}
|
||||
else {
|
||||
_config->conf[prefix]["USB"]["bandwidth"] = bw;
|
||||
_config->conf[prefix]["USB"]["snapInterval"] = snapInterval;
|
||||
}
|
||||
_config->release(true);
|
||||
|
||||
demod.init(_vfo->output, bbSampRate, bandWidth, dsp::SSBDemod::MODE_USB);
|
||||
|
||||
@ -99,6 +117,9 @@ public:
|
||||
if (ImGui::InputFloat(("##_radio_usb_bw_" + uiPrefix).c_str(), &bw, 1, 100, 0)) {
|
||||
bw = std::clamp<float>(bw, bwMin, bwMax);
|
||||
setBandwidth(bw);
|
||||
_config->aquire();
|
||||
_config->conf[uiPrefix]["USB"]["bandwidth"] = bw;
|
||||
_config->release(true);
|
||||
}
|
||||
|
||||
ImGui::Text("Snap Interval");
|
||||
@ -106,6 +127,9 @@ public:
|
||||
ImGui::SetNextItemWidth(menuWidth - ImGui::GetCursorPosX());
|
||||
if (ImGui::InputFloat(("##_radio_usb_snap_" + uiPrefix).c_str(), &snapInterval, 1, 100, 0)) {
|
||||
setSnapInterval(snapInterval);
|
||||
_config->aquire();
|
||||
_config->conf[uiPrefix]["USB"]["snapInterval"] = snapInterval;
|
||||
_config->release(true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -137,4 +161,6 @@ private:
|
||||
dsp::PolyphaseResampler<float> resamp;
|
||||
dsp::MonoToStereo m2s;
|
||||
|
||||
ConfigManager* _config;
|
||||
|
||||
};
|
@ -5,20 +5,42 @@
|
||||
#include <dsp/filter.h>
|
||||
#include <dsp/audio.h>
|
||||
#include <string>
|
||||
#include <config.h>
|
||||
#include <imgui.h>
|
||||
|
||||
class WFMDemodulator : public Demodulator {
|
||||
public:
|
||||
WFMDemodulator() {}
|
||||
WFMDemodulator(std::string prefix, VFOManager::VFO* vfo, float audioSampleRate, float bandWidth) {
|
||||
init(prefix, vfo, audioSampleRate, bandWidth);
|
||||
WFMDemodulator(std::string prefix, VFOManager::VFO* vfo, float audioSampleRate, float bandWidth, ConfigManager* config) {
|
||||
init(prefix, vfo, audioSampleRate, bandWidth, config);
|
||||
}
|
||||
|
||||
void init(std::string prefix, VFOManager::VFO* vfo, float audioSampleRate, float bandWidth) {
|
||||
void init(std::string prefix, VFOManager::VFO* vfo, float audioSampleRate, float bandWidth, ConfigManager* config) {
|
||||
uiPrefix = prefix;
|
||||
_vfo = vfo;
|
||||
audioSampRate = audioSampleRate;
|
||||
bw = bandWidth;
|
||||
_config = config;
|
||||
|
||||
_config->aquire();
|
||||
if(_config->conf.contains(prefix)) {
|
||||
if(!_config->conf[prefix].contains("WFM")) {
|
||||
_config->conf[prefix]["WFM"]["bandwidth"] = bw;
|
||||
_config->conf[prefix]["WFM"]["snapInterval"] = snapInterval;
|
||||
_config->conf[prefix]["WFM"]["deempMode"] = deempId;
|
||||
}
|
||||
json conf = _config->conf[prefix]["WFM"];
|
||||
bw = conf["bandwidth"];
|
||||
snapInterval = conf["snapInterval"];
|
||||
deempId = conf["deempMode"];
|
||||
}
|
||||
else {
|
||||
_config->conf[prefix]["WFM"]["bandwidth"] = bw;
|
||||
_config->conf[prefix]["WFM"]["snapInterval"] = snapInterval;
|
||||
_config->conf[prefix]["WFM"]["deempMode"] = deempId;
|
||||
}
|
||||
_config->release(true);
|
||||
|
||||
|
||||
demod.init(_vfo->output, bbSampRate, bandWidth / 2.0f);
|
||||
|
||||
@ -102,6 +124,9 @@ public:
|
||||
if (ImGui::InputFloat(("##_radio_wfm_bw_" + uiPrefix).c_str(), &bw, 1, 100, 0)) {
|
||||
bw = std::clamp<float>(bw, bwMin, bwMax);
|
||||
setBandwidth(bw);
|
||||
_config->aquire();
|
||||
_config->conf[uiPrefix]["WFM"]["bandwidth"] = bw;
|
||||
_config->release(true);
|
||||
}
|
||||
|
||||
ImGui::Text("Snap Interval");
|
||||
@ -109,6 +134,9 @@ public:
|
||||
ImGui::SetNextItemWidth(menuWidth - ImGui::GetCursorPosX());
|
||||
if (ImGui::InputFloat(("##_radio_wfm_snap_" + uiPrefix).c_str(), &snapInterval, 1, 100, 0)) {
|
||||
setSnapInterval(snapInterval);
|
||||
_config->aquire();
|
||||
_config->conf[uiPrefix]["WFM"]["snapInterval"] = snapInterval;
|
||||
_config->release(true);
|
||||
}
|
||||
|
||||
|
||||
@ -117,6 +145,9 @@ public:
|
||||
ImGui::SetNextItemWidth(menuWidth - ImGui::GetCursorPosX());
|
||||
if (ImGui::Combo(("##_radio_wfm_deemp_" + uiPrefix).c_str(), &deempId, deempModes)) {
|
||||
setDeempIndex(deempId);
|
||||
_config->aquire();
|
||||
_config->conf[uiPrefix]["WFM"]["deempMode"] = deempId;
|
||||
_config->release(true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -162,4 +193,6 @@ private:
|
||||
dsp::BFMDeemp deemp;
|
||||
dsp::MonoToStereo m2s;
|
||||
|
||||
ConfigManager* _config;
|
||||
|
||||
};
|
@ -1,9 +1,9 @@
|
||||
{
|
||||
"bandPlan": "General",
|
||||
"bandPlanEnabled": true,
|
||||
"centerTuning": false,
|
||||
"centerTuning": true,
|
||||
"fftHeight": 300,
|
||||
"frequency": 100485981,
|
||||
"frequency": 100100000,
|
||||
"max": 0.0,
|
||||
"maximized": false,
|
||||
"menuOrder": [
|
||||
|
@ -1,5 +1,37 @@
|
||||
{
|
||||
"Radio 1": {
|
||||
"demodulator":1
|
||||
}
|
||||
{
|
||||
"Radio": {
|
||||
"AM": {
|
||||
"bandwidth": 12500.0,
|
||||
"snapInterval": 1000.0
|
||||
},
|
||||
"CW": {
|
||||
"bandwidth": 200.0,
|
||||
"snapInterval": 10.0
|
||||
},
|
||||
"DSB": {
|
||||
"bandwidth": 6000.0,
|
||||
"snapInterval": 100.0
|
||||
},
|
||||
"FM": {
|
||||
"bandwidth": 12500.0,
|
||||
"snapInterval": 10000.0
|
||||
},
|
||||
"LSB": {
|
||||
"bandwidth": 3000.0,
|
||||
"snapInterval": 100.0
|
||||
},
|
||||
"RAW": {
|
||||
"snapInterval": 10000.0
|
||||
},
|
||||
"USB": {
|
||||
"bandwidth": 3000.0,
|
||||
"snapInterval": 100.0
|
||||
},
|
||||
"WFM": {
|
||||
"bandwidth": 200000.0,
|
||||
"deempMode": 0,
|
||||
"snapInterval": 100000.0
|
||||
},
|
||||
"selectedDemodId": 1
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user