From f2ec2c9f1d78583cbd095b7d54f8573b839790fd Mon Sep 17 00:00:00 2001 From: f4exb Date: Wed, 1 Mar 2017 05:45:53 +0100 Subject: [PATCH] Channel Analyzer NG: isolate one sample processing --- .../channelrx/chanalyzerng/chanalyzerng.cpp | 37 +--------------- plugins/channelrx/chanalyzerng/chanalyzerng.h | 42 +++++++++++++++++++ 2 files changed, 43 insertions(+), 36 deletions(-) diff --git a/plugins/channelrx/chanalyzerng/chanalyzerng.cpp b/plugins/channelrx/chanalyzerng/chanalyzerng.cpp index 6e3ee3d7c..74172b0ad 100644 --- a/plugins/channelrx/chanalyzerng/chanalyzerng.cpp +++ b/plugins/channelrx/chanalyzerng/chanalyzerng.cpp @@ -71,42 +71,7 @@ void ChannelAnalyzerNG::feed(const SampleVector::const_iterator& begin, const Sa //Complex c(it->real() / 32768.0f, it->imag() / 32768.0f); Complex c(it->real(), it->imag()); c *= m_nco.nextIQ(); - - if (m_running.m_ssb) - { - n_out = SSBFilter->runSSB(c, &sideband, m_usb); - } - else - { - n_out = DSBFilter->runDSB(c, &sideband); - } - - for (int i = 0; i < n_out; i++) - { - // Downsample by 2^(m_scaleLog2 - 1) for SSB band spectrum display - // smart decimation with bit gain using float arithmetic (23 bits significand) - - m_sum += sideband[i]; - - if (!(m_undersampleCount++ & decim_mask)) - { - m_sum /= decim; - m_magsq = (m_sum.real() * m_sum.real() + m_sum.imag() * m_sum.imag())/ (1<<30); - - if (m_running.m_ssb & !m_usb) - { // invert spectrum for LSB - //m_sampleBuffer.push_back(Sample(m_sum.imag() * 32768.0, m_sum.real() * 32768.0)); - m_sampleBuffer.push_back(Sample(m_sum.imag(), m_sum.real())); - } - else - { - //m_sampleBuffer.push_back(Sample(m_sum.real() * 32768.0, m_sum.imag() * 32768.0)); - m_sampleBuffer.push_back(Sample(m_sum.real(), m_sum.imag())); - } - - m_sum = 0; - } - } + processOneSample(c, sideband); } if(m_sampleSink != NULL) diff --git a/plugins/channelrx/chanalyzerng/chanalyzerng.h b/plugins/channelrx/chanalyzerng/chanalyzerng.h index f2b5ac2de..b9a62f58c 100644 --- a/plugins/channelrx/chanalyzerng/chanalyzerng.h +++ b/plugins/channelrx/chanalyzerng/chanalyzerng.h @@ -135,6 +135,48 @@ private: QMutex m_settingsMutex; void apply(bool force = false); + + void processOneSample(Complex& c, fftfilt::cmplx *sideband) + { + int n_out; + int decim = 1<runSSB(c, &sideband, m_usb); + } + else + { + n_out = DSBFilter->runDSB(c, &sideband); + } + + for (int i = 0; i < n_out; i++) + { + // Downsample by 2^(m_scaleLog2 - 1) for SSB band spectrum display + // smart decimation with bit gain using float arithmetic (23 bits significand) + + m_sum += sideband[i]; + + if (!(m_undersampleCount++ & (decim - 1))) + { + m_sum /= decim; + m_magsq = (m_sum.real() * m_sum.real() + m_sum.imag() * m_sum.imag())/ (1<<30); + + if (m_running.m_ssb & !m_usb) + { // invert spectrum for LSB + //m_sampleBuffer.push_back(Sample(m_sum.imag() * 32768.0, m_sum.real() * 32768.0)); + m_sampleBuffer.push_back(Sample(m_sum.imag(), m_sum.real())); + } + else + { + //m_sampleBuffer.push_back(Sample(m_sum.real() * 32768.0, m_sum.imag() * 32768.0)); + m_sampleBuffer.push_back(Sample(m_sum.real(), m_sum.imag())); + } + + m_sum = 0; + } + } + } }; #endif // INCLUDE_CHANALYZERNG_H