mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2024-11-06 18:57:39 +01:00
Fixed CW demodulator
This commit is contained in:
parent
09e332a8d1
commit
0d7f1265da
@ -3,9 +3,6 @@
|
||||
#include <dsp/demodulator.h>
|
||||
#include <dsp/resampling.h>
|
||||
#include <dsp/filter.h>
|
||||
#include <dsp/convertion.h>
|
||||
#include <dsp/processing.h>
|
||||
#include <dsp/math.h>
|
||||
#include <dsp/audio.h>
|
||||
#include <string>
|
||||
#include <config.h>
|
||||
@ -28,56 +25,56 @@ public:
|
||||
|
||||
_config->acquire();
|
||||
if(_config->conf.contains(prefix)) {
|
||||
if(!_config->conf[prefix].contains("CW")) {
|
||||
_config->conf[prefix]["CW"]["bandwidth"] = bw;
|
||||
_config->conf[prefix]["CW"]["snapInterval"] = snapInterval;
|
||||
_config->conf[prefix]["CW"]["squelchLevel"] = squelchLevel;
|
||||
if(!_config->conf[prefix].contains("USB")) {
|
||||
_config->conf[prefix]["USB"]["bandwidth"] = bw;
|
||||
_config->conf[prefix]["USB"]["snapInterval"] = snapInterval;
|
||||
_config->conf[prefix]["USB"]["squelchLevel"] = squelchLevel;
|
||||
}
|
||||
json conf = _config->conf[prefix]["CW"];
|
||||
json conf = _config->conf[prefix]["USB"];
|
||||
if (conf.contains("bandwidth")) { bw = conf["bandwidth"]; }
|
||||
if (conf.contains("snapInterval")) { snapInterval = conf["snapInterval"]; }
|
||||
if (conf.contains("squelchLevel")) { squelchLevel = conf["squelchLevel"]; }
|
||||
}
|
||||
else {
|
||||
_config->conf[prefix]["CW"]["bandwidth"] = bw;
|
||||
_config->conf[prefix]["CW"]["snapInterval"] = snapInterval;
|
||||
_config->conf[prefix]["CW"]["squelchLevel"] = squelchLevel;
|
||||
_config->conf[prefix]["USB"]["bandwidth"] = bw;
|
||||
_config->conf[prefix]["USB"]["snapInterval"] = snapInterval;
|
||||
_config->conf[prefix]["USB"]["squelchLevel"] = squelchLevel;
|
||||
}
|
||||
_config->release(true);
|
||||
|
||||
squelch.init(_vfo->output, squelchLevel);
|
||||
|
||||
xlator.init(&squelch.out, bbSampRate, 1000.0f);
|
||||
|
||||
float audioBW = std::min<float>(audioSampRate / 2.0f, bw / 2.0f);
|
||||
c2r.init(&xlator.out);
|
||||
|
||||
agc.init(&c2r.out, 20.0f, bbSampRate);
|
||||
|
||||
float audioBW = std::min<float>(audioSampRate / 2.0f, (bw / 2.0f) + 1000.0f);
|
||||
win.init(audioBW, audioBW, bbSampRate);
|
||||
resamp.init(&squelch.out, &win, bbSampRate, audioSampRate);
|
||||
resamp.init(&agc.out, &win, bbSampRate, audioSampRate);
|
||||
win.setSampleRate(bbSampRate * resamp.getInterpolation());
|
||||
resamp.updateWindow(&win);
|
||||
|
||||
xlator.init(&resamp.out, audioSampleRate, 1000);
|
||||
|
||||
c2r.init(&xlator.out);
|
||||
|
||||
agc.init(&c2r.out, 20.0f, audioSampRate);
|
||||
|
||||
m2s.init(&agc.out);
|
||||
m2s.init(&resamp.out);
|
||||
}
|
||||
|
||||
void start() {
|
||||
squelch.start();
|
||||
resamp.start();
|
||||
xlator.start();
|
||||
c2r.start();
|
||||
agc.start();
|
||||
resamp.start();
|
||||
m2s.start();
|
||||
running = true;
|
||||
}
|
||||
|
||||
void stop() {
|
||||
squelch.stop();
|
||||
resamp.stop();
|
||||
xlator.stop();
|
||||
c2r.stop();
|
||||
agc.stop();
|
||||
resamp.stop();
|
||||
m2s.stop();
|
||||
running = false;
|
||||
}
|
||||
@ -105,17 +102,16 @@ public:
|
||||
void setAudioSampleRate(float sampleRate) {
|
||||
if (running) {
|
||||
resamp.stop();
|
||||
xlator.stop();
|
||||
}
|
||||
audioSampRate = sampleRate;
|
||||
agc.setSampleRate(audioSampRate);
|
||||
float audioBW = std::min<float>(audioSampRate / 2.0f, (bw / 2.0f) + 1000.0f);
|
||||
resamp.setOutSampleRate(audioSampRate);
|
||||
win.setSampleRate(bbSampRate * resamp.getInterpolation());
|
||||
win.setCutoff(audioBW);
|
||||
win.setTransWidth(audioBW);
|
||||
resamp.updateWindow(&win);
|
||||
xlator.setSampleRate(audioSampRate);
|
||||
if (running) {
|
||||
resamp.start();
|
||||
xlator.start();
|
||||
}
|
||||
}
|
||||
|
||||
@ -131,18 +127,18 @@ public:
|
||||
float menuWidth = ImGui::GetContentRegionAvailWidth();
|
||||
|
||||
ImGui::SetNextItemWidth(menuWidth);
|
||||
if (ImGui::InputFloat(("##_radio_cw_bw_" + uiPrefix).c_str(), &bw, 1, 100, "%.0f", 0)) {
|
||||
if (ImGui::InputFloat(("##_radio_usb_bw_" + uiPrefix).c_str(), &bw, 1, 100, "%.0f", 0)) {
|
||||
bw = std::clamp<float>(bw, bwMin, bwMax);
|
||||
setBandwidth(bw);
|
||||
_config->acquire();
|
||||
_config->conf[uiPrefix]["CW"]["bandwidth"] = bw;
|
||||
_config->conf[uiPrefix]["USB"]["bandwidth"] = bw;
|
||||
_config->release(true);
|
||||
}if (running) {
|
||||
if (_vfo->getBandwidthChanged()) {
|
||||
bw = _vfo->getBandwidth();
|
||||
setBandwidth(bw, false);
|
||||
_config->acquire();
|
||||
_config->conf[uiPrefix]["CW"]["bandwidth"] = bw;
|
||||
_config->conf[uiPrefix]["USB"]["bandwidth"] = bw;
|
||||
_config->release(true);
|
||||
}
|
||||
}
|
||||
@ -150,21 +146,21 @@ public:
|
||||
ImGui::Text("Snap Interval");
|
||||
ImGui::SameLine();
|
||||
ImGui::SetNextItemWidth(menuWidth - ImGui::GetCursorPosX());
|
||||
if (ImGui::InputFloat(("##_radio_cw_snap_" + uiPrefix).c_str(), &snapInterval, 1, 100, "%.0f", 0)) {
|
||||
if (ImGui::InputFloat(("##_radio_usb_snap_" + uiPrefix).c_str(), &snapInterval, 1, 100, "%.0f", 0)) {
|
||||
if (snapInterval < 1) { snapInterval = 1; }
|
||||
setSnapInterval(snapInterval);
|
||||
_config->acquire();
|
||||
_config->conf[uiPrefix]["CW"]["snapInterval"] = snapInterval;
|
||||
_config->conf[uiPrefix]["USB"]["snapInterval"] = snapInterval;
|
||||
_config->release(true);
|
||||
}
|
||||
|
||||
ImGui::Text("Squelch");
|
||||
ImGui::SameLine();
|
||||
ImGui::SetNextItemWidth(menuWidth - ImGui::GetCursorPosX());
|
||||
if (ImGui::SliderFloat(("##_radio_cw_squelch_" + uiPrefix).c_str(), &squelchLevel, -100.0f, 0.0f, "%.3fdB")) {
|
||||
if (ImGui::SliderFloat(("##_radio_usb_squelch_" + uiPrefix).c_str(), &squelchLevel, -100.0f, 0.0f, "%.3fdB")) {
|
||||
squelch.setLevel(squelchLevel);
|
||||
_config->acquire();
|
||||
_config->conf[uiPrefix]["CW"]["squelchLevel"] = squelchLevel;
|
||||
_config->conf[uiPrefix]["USB"]["squelchLevel"] = squelchLevel;
|
||||
_config->release(true);
|
||||
}
|
||||
}
|
||||
@ -173,6 +169,11 @@ public:
|
||||
bandWidth = std::clamp<float>(bandWidth, bwMin, bwMax);
|
||||
bw = bandWidth;
|
||||
_vfo->setBandwidth(bw, updateWaterfall);
|
||||
float audioBW = std::min<float>(audioSampRate / 2.0f, (bw / 2.0f) + 1000.0f);
|
||||
win.setSampleRate(bbSampRate * resamp.getInterpolation());
|
||||
win.setCutoff(audioBW);
|
||||
win.setTransWidth(audioBW);
|
||||
resamp.updateWindow(&win);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -182,23 +183,23 @@ private:
|
||||
}
|
||||
|
||||
const float bwMax = 500;
|
||||
const float bwMin = 100;
|
||||
const float bbSampRate = 500;
|
||||
const float bwMin = 50;
|
||||
const float bbSampRate = 3000;
|
||||
|
||||
std::string uiPrefix;
|
||||
float snapInterval = 10;
|
||||
float audioSampRate = 48000;
|
||||
float bw = 200;
|
||||
float bw = 500;
|
||||
bool running = false;
|
||||
float squelchLevel = -100.0f;
|
||||
|
||||
VFOManager::VFO* _vfo;
|
||||
dsp::Squelch squelch;
|
||||
dsp::filter_window::BlackmanWindow win;
|
||||
dsp::PolyphaseResampler<dsp::complex_t> resamp;
|
||||
dsp::FrequencyXlator<dsp::complex_t> xlator;
|
||||
dsp::ComplexToReal c2r;
|
||||
dsp::AGC agc;
|
||||
dsp::filter_window::BlackmanWindow win;
|
||||
dsp::PolyphaseResampler<float> resamp;
|
||||
dsp::MonoToStereo m2s;
|
||||
|
||||
ConfigManager* _config;
|
||||
|
Loading…
Reference in New Issue
Block a user