From 9b10ddc6685d2e95c1e427ad16c92d61cec6771c Mon Sep 17 00:00:00 2001 From: f4exb Date: Sun, 19 Jul 2020 11:48:02 +0200 Subject: [PATCH] Channel Analyzer: use complex decimator for decimation by power of two value --- .../channelrx/chanalyzer/chanalyzersink.cpp | 30 +++++++++++++++++-- plugins/channelrx/chanalyzer/chanalyzersink.h | 2 ++ 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/plugins/channelrx/chanalyzer/chanalyzersink.cpp b/plugins/channelrx/chanalyzer/chanalyzersink.cpp index 43295a685..daca343ff 100644 --- a/plugins/channelrx/chanalyzer/chanalyzersink.cpp +++ b/plugins/channelrx/chanalyzer/chanalyzersink.cpp @@ -69,10 +69,19 @@ void ChannelAnalyzerSink::feed(const SampleVector::const_iterator& begin, const } else { - if (m_interpolator.decimate(&m_interpolatorDistanceRemain, c, &ci)) + if (m_settings.m_rationalDownSample) { - processOneSample(ci, sideband); - m_interpolatorDistanceRemain += m_interpolatorDistance; + if (m_interpolator.decimate(&m_interpolatorDistanceRemain, c, &ci)) + { + processOneSample(ci, sideband); + m_interpolatorDistanceRemain += m_interpolatorDistance; + } + } + else + { + if (m_decimator.decimate(c, ci)) { + processOneSample(ci, sideband); + } } } } @@ -153,6 +162,21 @@ void ChannelAnalyzerSink::applyChannelSettings(int channelSampleRate, int sinkSa setFilters(sinkSampleRate, m_settings.m_bandwidth, m_settings.m_lowCutoff); m_pll.setSampleRate(sinkSampleRate); m_fll.setSampleRate(sinkSampleRate); + + int decim = channelSampleRate / sinkSampleRate; + m_decimator.setLog2Decim(0); + + for (int i = 0; i < 7; i++) // find log2 beween 0 and 6 + { + if (decim & 1 == 1) + { + qDebug() << "ChannelAnalyzerSink::applyChannelSettings: log2decim: " << i; + m_decimator.setLog2Decim(i); + break; + } + + decim >>= 1; + } } m_channelSampleRate = channelSampleRate; diff --git a/plugins/channelrx/chanalyzer/chanalyzersink.h b/plugins/channelrx/chanalyzer/chanalyzersink.h index 8014529a6..4f9ca989a 100644 --- a/plugins/channelrx/chanalyzer/chanalyzersink.h +++ b/plugins/channelrx/chanalyzer/chanalyzersink.h @@ -20,6 +20,7 @@ #include "dsp/channelsamplesink.h" #include "dsp/interpolator.h" +#include "dsp/decimatorc.h" #include "dsp/ncof.h" #include "dsp/fftcorr.h" #include "dsp/fftfilt.h" @@ -69,6 +70,7 @@ private: Interpolator m_interpolator; Real m_interpolatorDistance; Real m_interpolatorDistanceRemain; + DecimatorC m_decimator; fftfilt* SSBFilter; fftfilt* DSBFilter;