From fe1de4bed9ee9e91ad60c6b9d9d941be004b1007 Mon Sep 17 00:00:00 2001 From: Ryzerth Date: Sun, 6 Dec 2020 19:51:56 +0100 Subject: [PATCH] Fixed SSB demod bug --- audio_sink/src/main.cpp | 2 -- core/src/dsp/demodulator.h | 11 ++++++++--- radio/src/lsb_demod.h | 4 ++-- radio/src/usb_demod.h | 4 ++-- root_dev/config.json | 6 +++--- 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/audio_sink/src/main.cpp b/audio_sink/src/main.cpp index 86c29540..dc7a8ee0 100644 --- a/audio_sink/src/main.cpp +++ b/audio_sink/src/main.cpp @@ -145,8 +145,6 @@ private: float sampleRate = dev->sampleRates[dev->srId]; int bufferSize = sampleRate / 60.0f; - spdlog::warn("Audio SamplRate: {0}", sampleRate); - if (dev->channels == 2) { stereoRB.data.setMaxLatency(bufferSize * 2); stereoRB.start(); diff --git a/core/src/dsp/demodulator.h b/core/src/dsp/demodulator.h index a7f87b13..feb2aba1 100644 --- a/core/src/dsp/demodulator.h +++ b/core/src/dsp/demodulator.h @@ -166,7 +166,10 @@ namespace dsp { SSBDemod(stream* in, float sampleRate, float bandWidth, int mode) { init(in, sampleRate, bandWidth, mode); } - ~SSBDemod() { generic_block::stop(); } + ~SSBDemod() { + generic_block::stop(); + delete[] buffer; + } enum { MODE_USB, @@ -191,6 +194,7 @@ namespace dsp { phaseDelta = lv_cmake(1.0f, 0.0f); break; } + buffer = new lv_32fc_t[STREAM_BUFFER_SIZE]; generic_block::registerInput(_in); generic_block::registerOutput(&out); } @@ -256,8 +260,8 @@ namespace dsp { if (count < 0) { return -1; } if (out.aquire() < 0) { return -1; } - volk_32fc_s32fc_x2_rotator_32fc((lv_32fc_t*)out.data, (lv_32fc_t*)_in->data, phaseDelta, &phase, count); - volk_32fc_deinterleave_real_32f(out.data, (lv_32fc_t*)_in->data, count); + volk_32fc_s32fc_x2_rotator_32fc(buffer, (lv_32fc_t*)_in->data, phaseDelta, &phase, count); + volk_32fc_deinterleave_real_32f(out.data, buffer, count); _in->flush(); out.write(count); @@ -271,6 +275,7 @@ namespace dsp { int _mode; float _sampleRate, _bandWidth; stream* _in; + lv_32fc_t* buffer; lv_32fc_t phase; lv_32fc_t phaseDelta; diff --git a/radio/src/lsb_demod.h b/radio/src/lsb_demod.h index 014fc6b9..6b181897 100644 --- a/radio/src/lsb_demod.h +++ b/radio/src/lsb_demod.h @@ -24,7 +24,7 @@ public: agc.init(&demod.out, 1.0f / 125.0f); - float audioBW = std::min(audioSampRate / 2.0f, bw / 2.0f); + float audioBW = std::min(audioSampRate / 2.0f, bw); win.init(audioBW, audioBW, bbSampRate); resamp.init(&agc.out, &win, bbSampRate, audioSampRate); win.setSampleRate(bbSampRate * resamp.getInterpolation()); @@ -73,7 +73,7 @@ public: resamp.stop(); } audioSampRate = sampleRate; - float audioBW = std::min(audioSampRate / 2.0f, bw / 2.0f); + float audioBW = std::min(audioSampRate / 2.0f, bw); resamp.setOutSampleRate(audioSampRate); win.setSampleRate(bbSampRate * resamp.getInterpolation()); win.setCutoff(audioBW); diff --git a/radio/src/usb_demod.h b/radio/src/usb_demod.h index acfe0717..12af6350 100644 --- a/radio/src/usb_demod.h +++ b/radio/src/usb_demod.h @@ -24,7 +24,7 @@ public: agc.init(&demod.out, 1.0f / 125.0f); - float audioBW = std::min(audioSampRate / 2.0f, bw / 2.0f); + float audioBW = std::min(audioSampRate / 2.0f, bw); win.init(audioBW, audioBW, bbSampRate); resamp.init(&agc.out, &win, bbSampRate, audioSampRate); win.setSampleRate(bbSampRate * resamp.getInterpolation()); @@ -73,7 +73,7 @@ public: resamp.stop(); } audioSampRate = sampleRate; - float audioBW = std::min(audioSampRate / 2.0f, bw / 2.0f); + float audioBW = std::min(audioSampRate / 2.0f, bw); resamp.setOutSampleRate(audioSampRate); win.setSampleRate(bbSampRate * resamp.getInterpolation()); win.setCutoff(audioBW); diff --git a/root_dev/config.json b/root_dev/config.json index efb91670..e7991a42 100644 --- a/root_dev/config.json +++ b/root_dev/config.json @@ -19,7 +19,7 @@ "bandPlan": "General", "bandPlanEnabled": true, "fftHeight": 296, - "frequency": 96400000, + "frequency": 95000000, "max": 0.0, "maximized": false, "menuOrder": [ @@ -33,7 +33,7 @@ "Display" ], "menuWidth": 300, - "min": -72.05882263183594, + "min": -54.41176986694336, "offset": 0.0, "showWaterfall": true, "source": "SoapySDR", @@ -42,7 +42,7 @@ "Radio": { "muted": false, "sink": "Audio", - "volume": 0.6858407258987427 + "volume": 0.831632673740387 }, "Radio 1": { "muted": true,