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