From 2b98bc9d8a99a92b9522e0c992cd1546a9ee75d7 Mon Sep 17 00:00:00 2001 From: f4exb Date: Sat, 26 Dec 2015 04:04:22 +0100 Subject: [PATCH] SSB demod: continuous sum for SSB downsampling --- plugins/channel/ssb/ssbdemod.cpp | 13 +++++++------ plugins/channel/ssb/ssbdemod.h | 1 + 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/plugins/channel/ssb/ssbdemod.cpp b/plugins/channel/ssb/ssbdemod.cpp index 920c3bf9c..b40bf5a51 100644 --- a/plugins/channel/ssb/ssbdemod.cpp +++ b/plugins/channel/ssb/ssbdemod.cpp @@ -50,6 +50,7 @@ SSBDemod::SSBDemod(SampleSink* sampleSink) : m_audioBuffer.resize(1<<9); m_audioBufferFill = 0; m_undersampleCount = 0; + m_sum = 0; m_usb = true; m_magsq = 0.0f; @@ -83,7 +84,7 @@ void SSBDemod::configure(MessageQueue* messageQueue, void SSBDemod::feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly) { Complex ci; - fftfilt::cmplx *sideband, sum; + fftfilt::cmplx *sideband; Real avg; int n_out; @@ -113,18 +114,18 @@ void SSBDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto // Downsample by 2^(m_scaleLog2 - 1) for SSB band spectrum display // smart decimation with bit gain using float arithmetic (23 bits significand) - sum += sideband[i]; + m_sum += sideband[i]; if (!(m_undersampleCount++ & decim_mask)) { - Real avgr = sum.real() / decim; - Real avgi = sum.imag() / decim; + Real avgr = m_sum.real() / decim; + Real avgi = m_sum.imag() / decim; m_magsq = (avgr * avgr + avgi * avgi) / (1<<30); //avg = (sum.real() + sum.imag()) * 0.7 * 32768.0 / decim; avg = (avgr + avgi) * 0.7; m_sampleBuffer.push_back(Sample(avg, 0.0)); - sum.real() = 0.0; - sum.imag() = 0.0; + m_sum.real() = 0.0; + m_sum.imag() = 0.0; } if (m_audioBinaual) diff --git a/plugins/channel/ssb/ssbdemod.h b/plugins/channel/ssb/ssbdemod.h index c00117273..74bd5bba4 100644 --- a/plugins/channel/ssb/ssbdemod.h +++ b/plugins/channel/ssb/ssbdemod.h @@ -112,6 +112,7 @@ private: Real m_LowCutoff; Real m_volume; int m_spanLog2; + fftfilt::cmplx m_sum; int m_undersampleCount; int m_sampleRate; int m_frequency;