bunch of stuff idk i'm tired

This commit is contained in:
Ryzerth 2021-04-22 05:38:25 +02:00
parent 72cbf741b3
commit a4c25280b3
10 changed files with 67 additions and 32 deletions

View File

@ -30,6 +30,10 @@ void VFOManager::VFO::setOffset(double offset) {
dspVFO->setOffset(wtfVFO->centerOffset); dspVFO->setOffset(wtfVFO->centerOffset);
} }
double VFOManager::VFO::getOffset() {
return wtfVFO->generalOffset;
}
void VFOManager::VFO::setCenterOffset(double offset) { void VFOManager::VFO::setCenterOffset(double offset) {
wtfVFO->setCenterOffset(offset); wtfVFO->setCenterOffset(offset);
dspVFO->setOffset(offset); dspVFO->setOffset(offset);
@ -104,6 +108,13 @@ void VFOManager::setOffset(std::string name, double offset) {
vfos[name]->setOffset(offset); vfos[name]->setOffset(offset);
} }
double VFOManager::getOffset(std::string name) {
if (vfos.find(name) == vfos.end()) {
return 0;
}
return vfos[name]->getOffset();
}
void VFOManager::setCenterOffset(std::string name, double offset) { void VFOManager::setCenterOffset(std::string name, double offset) {
if (vfos.find(name) == vfos.end()) { if (vfos.find(name) == vfos.end()) {
return; return;

View File

@ -13,6 +13,7 @@ public:
~VFO(); ~VFO();
void setOffset(double offset); void setOffset(double offset);
double getOffset();
void setCenterOffset(double offset); void setCenterOffset(double offset);
void setBandwidth(double bandwidth, bool updateWaterfall = true); void setBandwidth(double bandwidth, bool updateWaterfall = true);
void setSampleRate(double sampleRate, double bandwidth); void setSampleRate(double sampleRate, double bandwidth);
@ -37,6 +38,7 @@ public:
void deleteVFO(VFOManager::VFO* vfo); void deleteVFO(VFOManager::VFO* vfo);
void setOffset(std::string name, double offset); void setOffset(std::string name, double offset);
double getOffset(std::string name);
void setCenterOffset(std::string name, double offset); void setCenterOffset(std::string name, double offset);
void setBandwidth(std::string name, double bandwidth, bool updateWaterfall = true); void setBandwidth(std::string name, double bandwidth, bool updateWaterfall = true);
void setSampleRate(std::string name, double sampleRate, double bandwidth); void setSampleRate(std::string name, double sampleRate, double bandwidth);

View File

@ -26,16 +26,19 @@ public:
_config->aquire(); _config->aquire();
if(_config->conf.contains(prefix)) { if(_config->conf.contains(prefix)) {
if(!_config->conf[prefix].contains("AM")) { if(!_config->conf[prefix].contains("AM")) {
if (!_config->conf[prefix]["AM"].contains("bandwidth")) { _config->conf[prefix]["AM"]["bandwidth"] = bw; } _config->conf[prefix]["AM"]["bandwidth"] = bw;
if (!_config->conf[prefix]["AM"].contains("snapInterval")) { _config->conf[prefix]["AM"]["snapInterval"] = snapInterval; } _config->conf[prefix]["AM"]["snapInterval"] = snapInterval;
_config->conf[prefix]["AM"]["squelchLevel"] = squelchLevel;
} }
json conf = _config->conf[prefix]["AM"]; json conf = _config->conf[prefix]["AM"];
bw = conf["bandwidth"]; if (conf.contains("bandwidth")) { bw = conf["bandwidth"]; }
snapInterval = conf["snapInterval"]; if (conf.contains("snapInterval")) { snapInterval = conf["snapInterval"]; }
if (conf.contains("squelchLevel")) { squelchLevel = conf["squelchLevel"]; }
} }
else { else {
_config->conf[prefix]["AM"]["bandwidth"] = bw; _config->conf[prefix]["AM"]["bandwidth"] = bw;
_config->conf[prefix]["AM"]["snapInterval"] = snapInterval; _config->conf[prefix]["AM"]["snapInterval"] = snapInterval;
_config->conf[prefix]["AM"]["squelchLevel"] = squelchLevel;
} }
_config->release(true); _config->release(true);

View File

@ -29,16 +29,19 @@ public:
_config->aquire(); _config->aquire();
if(_config->conf.contains(prefix)) { if(_config->conf.contains(prefix)) {
if(!_config->conf[prefix].contains("CW")) { if(!_config->conf[prefix].contains("CW")) {
if (!_config->conf[prefix]["CW"].contains("bandwidth")) { _config->conf[prefix]["CW"]["bandwidth"] = bw; } _config->conf[prefix]["CW"]["bandwidth"] = bw;
if (!_config->conf[prefix]["CW"].contains("snapInterval")) { _config->conf[prefix]["CW"]["snapInterval"] = snapInterval; } _config->conf[prefix]["CW"]["snapInterval"] = snapInterval;
_config->conf[prefix]["CW"]["squelchLevel"] = squelchLevel;
} }
json conf = _config->conf[prefix]["CW"]; json conf = _config->conf[prefix]["CW"];
bw = conf["bandwidth"]; if (conf.contains("bandwidth")) { bw = conf["bandwidth"]; }
snapInterval = conf["snapInterval"]; if (conf.contains("snapInterval")) { snapInterval = conf["snapInterval"]; }
if (conf.contains("squelchLevel")) { squelchLevel = conf["squelchLevel"]; }
} }
else { else {
_config->conf[prefix]["CW"]["bandwidth"] = bw; _config->conf[prefix]["CW"]["bandwidth"] = bw;
_config->conf[prefix]["CW"]["snapInterval"] = snapInterval; _config->conf[prefix]["CW"]["snapInterval"] = snapInterval;
_config->conf[prefix]["CW"]["squelchLevel"] = squelchLevel;
} }
_config->release(true); _config->release(true);

View File

@ -26,16 +26,19 @@ public:
_config->aquire(); _config->aquire();
if(_config->conf.contains(prefix)) { if(_config->conf.contains(prefix)) {
if(!_config->conf[prefix].contains("DSB")) { if(!_config->conf[prefix].contains("DSB")) {
if (!_config->conf[prefix]["DSB"].contains("bandwidth")) { _config->conf[prefix]["DSB"]["bandwidth"] = bw; } _config->conf[prefix]["DSB"]["bandwidth"] = bw;
if (!_config->conf[prefix]["DSB"].contains("snapInterval")) { _config->conf[prefix]["DSB"]["snapInterval"] = snapInterval; } _config->conf[prefix]["DSB"]["snapInterval"] = snapInterval;
_config->conf[prefix]["DSB"]["squelchLevel"] = squelchLevel;
} }
json conf = _config->conf[prefix]["DSB"]; json conf = _config->conf[prefix]["DSB"];
bw = conf["bandwidth"]; if (conf.contains("bandwidth")) { bw = conf["bandwidth"]; }
snapInterval = conf["snapInterval"]; if (conf.contains("snapInterval")) { snapInterval = conf["snapInterval"]; }
if (conf.contains("squelchLevel")) { squelchLevel = conf["squelchLevel"]; }
} }
else { else {
_config->conf[prefix]["DSB"]["bandwidth"] = bw; _config->conf[prefix]["DSB"]["bandwidth"] = bw;
_config->conf[prefix]["DSB"]["snapInterval"] = snapInterval; _config->conf[prefix]["DSB"]["snapInterval"] = snapInterval;
_config->conf[prefix]["DSB"]["squelchLevel"] = squelchLevel;
} }
_config->release(true); _config->release(true);

View File

@ -26,16 +26,19 @@ public:
_config->aquire(); _config->aquire();
if(_config->conf.contains(prefix)) { if(_config->conf.contains(prefix)) {
if(!_config->conf[prefix].contains("FM")) { if(!_config->conf[prefix].contains("FM")) {
if (!_config->conf[prefix]["FM"].contains("bandwidth")) { _config->conf[prefix]["FM"]["bandwidth"] = bw; } _config->conf[prefix]["FM"]["bandwidth"] = bw;
if (!_config->conf[prefix]["FM"].contains("snapInterval")) { _config->conf[prefix]["FM"]["snapInterval"] = snapInterval; } _config->conf[prefix]["FM"]["snapInterval"] = snapInterval;
_config->conf[prefix]["FM"]["squelchLevel"] = squelchLevel;
} }
json conf = _config->conf[prefix]["FM"]; json conf = _config->conf[prefix]["FM"];
bw = conf["bandwidth"]; if (conf.contains("bandwidth")) { bw = conf["bandwidth"]; }
snapInterval = conf["snapInterval"]; if (conf.contains("snapInterval")) { snapInterval = conf["snapInterval"]; }
if (conf.contains("squelchLevel")) { squelchLevel = conf["squelchLevel"]; }
} }
else { else {
_config->conf[prefix]["FM"]["bandwidth"] = bw; _config->conf[prefix]["FM"]["bandwidth"] = bw;
_config->conf[prefix]["FM"]["snapInterval"] = snapInterval; _config->conf[prefix]["FM"]["snapInterval"] = snapInterval;
_config->conf[prefix]["FM"]["squelchLevel"] = squelchLevel;
} }
_config->release(true); _config->release(true);

View File

@ -26,16 +26,19 @@ public:
_config->aquire(); _config->aquire();
if(_config->conf.contains(prefix)) { if(_config->conf.contains(prefix)) {
if(!_config->conf[prefix].contains("LSB")) { if(!_config->conf[prefix].contains("LSB")) {
if (!_config->conf[prefix]["LSB"].contains("bandwidth")) { _config->conf[prefix]["LSB"]["bandwidth"] = bw; } _config->conf[prefix]["LSB"]["bandwidth"] = bw;
if (!_config->conf[prefix]["LSB"].contains("snapInterval")) { _config->conf[prefix]["LSB"]["snapInterval"] = snapInterval; } _config->conf[prefix]["LSB"]["snapInterval"] = snapInterval;
_config->conf[prefix]["LSB"]["squelchLevel"] = squelchLevel;
} }
json conf = _config->conf[prefix]["LSB"]; json conf = _config->conf[prefix]["LSB"];
bw = conf["bandwidth"]; if (conf.contains("bandwidth")) { bw = conf["bandwidth"]; }
snapInterval = conf["snapInterval"]; if (conf.contains("snapInterval")) { snapInterval = conf["snapInterval"]; }
if (conf.contains("squelchLevel")) { squelchLevel = conf["squelchLevel"]; }
} }
else { else {
_config->conf[prefix]["LSB"]["bandwidth"] = bw; _config->conf[prefix]["LSB"]["bandwidth"] = bw;
_config->conf[prefix]["LSB"]["snapInterval"] = snapInterval; _config->conf[prefix]["LSB"]["snapInterval"] = snapInterval;
_config->conf[prefix]["LSB"]["squelchLevel"] = squelchLevel;
} }
_config->release(true); _config->release(true);

View File

@ -73,7 +73,8 @@ public:
} }
void enable() { void enable() {
vfo = sigpath::vfoManager.createVFO(name, ImGui::WaterfallVFO::REF_CENTER, 0, 200000, 200000, 50000, 200000, false); double bw = gui::waterfall.getBandwidth();
vfo = sigpath::vfoManager.createVFO(name, ImGui::WaterfallVFO::REF_CENTER, std::clamp<double>(savedOffset, -bw/2.0, bw/2.0), 200000, 200000, 50000, 200000, false);
wfmDemod.setVFO(vfo); wfmDemod.setVFO(vfo);
fmDemod.setVFO(vfo); fmDemod.setVFO(vfo);
@ -91,9 +92,8 @@ public:
void disable() { void disable() {
currentDemod->stop(); currentDemod->stop();
savedOffset = vfo->getOffset();
sigpath::vfoManager.deleteVFO(vfo); sigpath::vfoManager.deleteVFO(vfo);
//ns.setInput(vfo->output);
//ns.start();
enabled = false; enabled = false;
} }
@ -194,6 +194,7 @@ private:
bool enabled = true; bool enabled = true;
int demodId = 0; int demodId = 0;
float audioSampRate = 48000; float audioSampRate = 48000;
double savedOffset;
Demodulator* currentDemod = NULL; Demodulator* currentDemod = NULL;
VFOManager::VFO* vfo; VFOManager::VFO* vfo;

View File

@ -25,14 +25,17 @@ public:
_config->aquire(); _config->aquire();
if(_config->conf.contains(prefix)) { if(_config->conf.contains(prefix)) {
if(!_config->conf[prefix].contains("RAW")) { if(!_config->conf[prefix].contains("CW")) {
if (!_config->conf[prefix]["RAW"].contains("snapInterval")) { _config->conf[prefix]["RAW"]["snapInterval"] = snapInterval; } _config->conf[prefix]["CW"]["snapInterval"] = snapInterval;
_config->conf[prefix]["CW"]["squelchLevel"] = squelchLevel;
} }
json conf = _config->conf[prefix]["RAW"]; json conf = _config->conf[prefix]["CW"];
snapInterval = conf["snapInterval"]; if (conf.contains("snapInterval")) { snapInterval = conf["snapInterval"]; }
if (conf.contains("squelchLevel")) { squelchLevel = conf["squelchLevel"]; }
} }
else { else {
_config->conf[prefix]["RAW"]["snapInterval"] = snapInterval; _config->conf[prefix]["CW"]["snapInterval"] = snapInterval;
_config->conf[prefix]["CW"]["squelchLevel"] = squelchLevel;
} }
_config->release(true); _config->release(true);

View File

@ -26,16 +26,19 @@ public:
_config->aquire(); _config->aquire();
if(_config->conf.contains(prefix)) { if(_config->conf.contains(prefix)) {
if(!_config->conf[prefix].contains("USB")) { if(!_config->conf[prefix].contains("USB")) {
if (!_config->conf[prefix]["USB"].contains("bandwidth")) { _config->conf[prefix]["USB"]["bandwidth"] = bw; } _config->conf[prefix]["USB"]["bandwidth"] = bw;
if (!_config->conf[prefix]["USB"].contains("snapInterval")) { _config->conf[prefix]["USB"]["snapInterval"] = snapInterval; } _config->conf[prefix]["USB"]["snapInterval"] = snapInterval;
_config->conf[prefix]["USB"]["squelchLevel"] = squelchLevel;
} }
json conf = _config->conf[prefix]["USB"]; json conf = _config->conf[prefix]["USB"];
bw = conf["bandwidth"]; if (conf.contains("bandwidth")) { bw = conf["bandwidth"]; }
snapInterval = conf["snapInterval"]; if (conf.contains("snapInterval")) { snapInterval = conf["snapInterval"]; }
if (conf.contains("squelchLevel")) { squelchLevel = conf["squelchLevel"]; }
} }
else { else {
_config->conf[prefix]["USB"]["bandwidth"] = bw; _config->conf[prefix]["USB"]["bandwidth"] = bw;
_config->conf[prefix]["USB"]["snapInterval"] = snapInterval; _config->conf[prefix]["USB"]["snapInterval"] = snapInterval;
_config->conf[prefix]["USB"]["squelchLevel"] = squelchLevel;
} }
_config->release(true); _config->release(true);