diff --git a/plugins/channelrx/chanalyzerng/chanalyzerng.cpp b/plugins/channelrx/chanalyzerng/chanalyzerng.cpp index 74172b0ad..5a8e0f91e 100644 --- a/plugins/channelrx/chanalyzerng/chanalyzerng.cpp +++ b/plugins/channelrx/chanalyzerng/chanalyzerng.cpp @@ -33,6 +33,7 @@ ChannelAnalyzerNG::ChannelAnalyzerNG(BasebandSampleSink* sampleSink) : m_sum = 0; m_usb = true; m_magsq = 0; + m_useInterpolator = false; m_interpolatorDistance = 1.0f; m_interpolatorDistanceRemain = 0.0f; SSBFilter = new fftfilt(m_config.m_LowCutoff / m_config.m_inputSampleRate, m_config.m_Bandwidth / m_config.m_inputSampleRate, ssbFftLen); @@ -60,21 +61,30 @@ void ChannelAnalyzerNG::configure(MessageQueue* messageQueue, void ChannelAnalyzerNG::feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly) { fftfilt::cmplx *sideband; - int n_out; - int decim = 1<real() / 32768.0f, it->imag() / 32768.0f); Complex c(it->real(), it->imag()); c *= m_nco.nextIQ(); - processOneSample(c, sideband); + + if (m_useInterpolator) + { + if (m_interpolator.decimate(&m_interpolatorDistanceRemain, c, &ci)) + { + processOneSample(ci, sideband); + m_interpolatorDistanceRemain += m_interpolatorDistance; + } + } + else + { + processOneSample(c, sideband); + } } - if(m_sampleSink != NULL) + if(m_sampleSink != 0) { m_sampleSink->feed(m_sampleBuffer.begin(), m_sampleBuffer.end(), m_running.m_ssb); // m_ssb = positive only } @@ -162,6 +172,7 @@ void ChannelAnalyzerNG::apply(bool force) m_interpolator.create(16, m_config.m_inputSampleRate, m_config.m_inputSampleRate / 2.2); m_interpolatorDistanceRemain = 0.0f; m_interpolatorDistance = (Real) m_config.m_inputSampleRate / (Real) m_config.m_channelSampleRate; + m_useInterpolator = (m_config.m_inputSampleRate != m_config.m_channelSampleRate); // optim m_settingsMutex.unlock(); } diff --git a/plugins/channelrx/chanalyzerng/chanalyzerng.h b/plugins/channelrx/chanalyzerng/chanalyzerng.h index b9a62f58c..359655859 100644 --- a/plugins/channelrx/chanalyzerng/chanalyzerng.h +++ b/plugins/channelrx/chanalyzerng/chanalyzerng.h @@ -121,6 +121,7 @@ private: fftfilt::cmplx m_sum; bool m_usb; Real m_magsq; + bool m_useInterpolator; NCOF m_nco; Interpolator m_interpolator; @@ -157,7 +158,7 @@ private: m_sum += sideband[i]; - if (!(m_undersampleCount++ & (decim - 1))) + if (!(m_undersampleCount++ & (decim - 1))) // counter LSB bit mask for decimation by 2^(m_scaleLog2 - 1) { m_sum /= decim; m_magsq = (m_sum.real() * m_sum.real() + m_sum.imag() * m_sum.imag())/ (1<<30);