Fixed SSB demod bug

This commit is contained in:
Ryzerth 2020-12-06 19:51:56 +01:00
parent c612620ca5
commit fe1de4bed9
5 changed files with 15 additions and 12 deletions

View File

@ -145,8 +145,6 @@ private:
float sampleRate = dev->sampleRates[dev->srId]; float sampleRate = dev->sampleRates[dev->srId];
int bufferSize = sampleRate / 60.0f; int bufferSize = sampleRate / 60.0f;
spdlog::warn("Audio SamplRate: {0}", sampleRate);
if (dev->channels == 2) { if (dev->channels == 2) {
stereoRB.data.setMaxLatency(bufferSize * 2); stereoRB.data.setMaxLatency(bufferSize * 2);
stereoRB.start(); stereoRB.start();

View File

@ -166,7 +166,10 @@ namespace dsp {
SSBDemod(stream<complex_t>* in, float sampleRate, float bandWidth, int mode) { init(in, sampleRate, bandWidth, mode); } SSBDemod(stream<complex_t>* in, float sampleRate, float bandWidth, int mode) { init(in, sampleRate, bandWidth, mode); }
~SSBDemod() { generic_block<SSBDemod>::stop(); } ~SSBDemod() {
generic_block<SSBDemod>::stop();
delete[] buffer;
}
enum { enum {
MODE_USB, MODE_USB,
@ -191,6 +194,7 @@ namespace dsp {
phaseDelta = lv_cmake(1.0f, 0.0f); phaseDelta = lv_cmake(1.0f, 0.0f);
break; break;
} }
buffer = new lv_32fc_t[STREAM_BUFFER_SIZE];
generic_block<SSBDemod>::registerInput(_in); generic_block<SSBDemod>::registerInput(_in);
generic_block<SSBDemod>::registerOutput(&out); generic_block<SSBDemod>::registerOutput(&out);
} }
@ -256,8 +260,8 @@ namespace dsp {
if (count < 0) { return -1; } if (count < 0) { return -1; }
if (out.aquire() < 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_s32fc_x2_rotator_32fc(buffer, (lv_32fc_t*)_in->data, phaseDelta, &phase, count);
volk_32fc_deinterleave_real_32f(out.data, (lv_32fc_t*)_in->data, count); volk_32fc_deinterleave_real_32f(out.data, buffer, count);
_in->flush(); _in->flush();
out.write(count); out.write(count);
@ -271,6 +275,7 @@ namespace dsp {
int _mode; int _mode;
float _sampleRate, _bandWidth; float _sampleRate, _bandWidth;
stream<complex_t>* _in; stream<complex_t>* _in;
lv_32fc_t* buffer;
lv_32fc_t phase; lv_32fc_t phase;
lv_32fc_t phaseDelta; lv_32fc_t phaseDelta;

View File

@ -24,7 +24,7 @@ public:
agc.init(&demod.out, 1.0f / 125.0f); agc.init(&demod.out, 1.0f / 125.0f);
float audioBW = std::min<float>(audioSampRate / 2.0f, bw / 2.0f); float audioBW = std::min<float>(audioSampRate / 2.0f, bw);
win.init(audioBW, audioBW, bbSampRate); win.init(audioBW, audioBW, bbSampRate);
resamp.init(&agc.out, &win, bbSampRate, audioSampRate); resamp.init(&agc.out, &win, bbSampRate, audioSampRate);
win.setSampleRate(bbSampRate * resamp.getInterpolation()); win.setSampleRate(bbSampRate * resamp.getInterpolation());
@ -73,7 +73,7 @@ public:
resamp.stop(); resamp.stop();
} }
audioSampRate = sampleRate; audioSampRate = sampleRate;
float audioBW = std::min<float>(audioSampRate / 2.0f, bw / 2.0f); float audioBW = std::min<float>(audioSampRate / 2.0f, bw);
resamp.setOutSampleRate(audioSampRate); resamp.setOutSampleRate(audioSampRate);
win.setSampleRate(bbSampRate * resamp.getInterpolation()); win.setSampleRate(bbSampRate * resamp.getInterpolation());
win.setCutoff(audioBW); win.setCutoff(audioBW);

View File

@ -24,7 +24,7 @@ public:
agc.init(&demod.out, 1.0f / 125.0f); agc.init(&demod.out, 1.0f / 125.0f);
float audioBW = std::min<float>(audioSampRate / 2.0f, bw / 2.0f); float audioBW = std::min<float>(audioSampRate / 2.0f, bw);
win.init(audioBW, audioBW, bbSampRate); win.init(audioBW, audioBW, bbSampRate);
resamp.init(&agc.out, &win, bbSampRate, audioSampRate); resamp.init(&agc.out, &win, bbSampRate, audioSampRate);
win.setSampleRate(bbSampRate * resamp.getInterpolation()); win.setSampleRate(bbSampRate * resamp.getInterpolation());
@ -73,7 +73,7 @@ public:
resamp.stop(); resamp.stop();
} }
audioSampRate = sampleRate; audioSampRate = sampleRate;
float audioBW = std::min<float>(audioSampRate / 2.0f, bw / 2.0f); float audioBW = std::min<float>(audioSampRate / 2.0f, bw);
resamp.setOutSampleRate(audioSampRate); resamp.setOutSampleRate(audioSampRate);
win.setSampleRate(bbSampRate * resamp.getInterpolation()); win.setSampleRate(bbSampRate * resamp.getInterpolation());
win.setCutoff(audioBW); win.setCutoff(audioBW);

View File

@ -19,7 +19,7 @@
"bandPlan": "General", "bandPlan": "General",
"bandPlanEnabled": true, "bandPlanEnabled": true,
"fftHeight": 296, "fftHeight": 296,
"frequency": 96400000, "frequency": 95000000,
"max": 0.0, "max": 0.0,
"maximized": false, "maximized": false,
"menuOrder": [ "menuOrder": [
@ -33,7 +33,7 @@
"Display" "Display"
], ],
"menuWidth": 300, "menuWidth": 300,
"min": -72.05882263183594, "min": -54.41176986694336,
"offset": 0.0, "offset": 0.0,
"showWaterfall": true, "showWaterfall": true,
"source": "SoapySDR", "source": "SoapySDR",
@ -42,7 +42,7 @@
"Radio": { "Radio": {
"muted": false, "muted": false,
"sink": "Audio", "sink": "Audio",
"volume": 0.6858407258987427 "volume": 0.831632673740387
}, },
"Radio 1": { "Radio 1": {
"muted": true, "muted": true,