From 8ca7dbbd4e846c4bebd07311ab442de5f1b74b26 Mon Sep 17 00:00:00 2001 From: f4exb Date: Sun, 15 Oct 2023 11:50:31 +0200 Subject: [PATCH] Change order of sub-band matching in the Downchannelizer. Fixes possible aliasing issues. Fixes #1846 --- sdrbase/dsp/downchannelizer.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/sdrbase/dsp/downchannelizer.cpp b/sdrbase/dsp/downchannelizer.cpp index e21ac2061..06b9b49cd 100644 --- a/sdrbase/dsp/downchannelizer.cpp +++ b/sdrbase/dsp/downchannelizer.cpp @@ -233,12 +233,20 @@ Real DownChannelizer::createFilterChain(Real sigStart, Real sigEnd, Real chanSta Real sigBw = sigEnd - sigStart; Real rot = sigBw / 4; - //qDebug("DownChannelizer::createFilterChain: Signal [%.1f, %.1f] (BW %.1f), Channel [%.1f, %.1f], Rot %.1f", sigStart, sigEnd, sigBw, chanStart, chanEnd, rot); + qDebug("DownChannelizer::createFilterChain: Signal [%.1f, %.1f] (BW %.1f), Channel [%.1f, %.1f], Rot %.1f", sigStart, sigEnd, sigBw, chanStart, chanEnd, rot); + + // check if it fits into the center + if(signalContainsChannel(sigStart + rot, sigEnd - rot, chanStart, chanEnd)) + { + qDebug("DownChannelizer::createFilterChain: -> take center half (decimate by 2)"); + m_filterStages.push_back(new FilterStage(FilterStage::ModeCenter)); + return createFilterChain(sigStart + rot, sigEnd - rot, chanStart, chanEnd); + } // check if it fits into the left half if(signalContainsChannel(sigStart, sigStart + sigBw / 2.0, chanStart, chanEnd)) { - //qDebug("DownChannelizer::createFilterChain: -> take left half (rotate by +1/4 and decimate by 2)"); + qDebug("DownChannelizer::createFilterChain: -> take left half (rotate by +1/4 and decimate by 2)"); m_filterStages.push_back(new FilterStage(FilterStage::ModeLowerHalf)); return createFilterChain(sigStart, sigStart + sigBw / 2.0, chanStart, chanEnd); } @@ -246,21 +254,13 @@ Real DownChannelizer::createFilterChain(Real sigStart, Real sigEnd, Real chanSta // check if it fits into the right half if(signalContainsChannel(sigEnd - sigBw / 2.0f, sigEnd, chanStart, chanEnd)) { - //qDebug("DownChannelizer::createFilterChain: -> take right half (rotate by -1/4 and decimate by 2)"); + qDebug("DownChannelizer::createFilterChain: -> take right half (rotate by -1/4 and decimate by 2)"); m_filterStages.push_back(new FilterStage(FilterStage::ModeUpperHalf)); return createFilterChain(sigEnd - sigBw / 2.0f, sigEnd, chanStart, chanEnd); } - // check if it fits into the center - if(signalContainsChannel(sigStart + rot, sigEnd - rot, chanStart, chanEnd)) - { - //qDebug("DownChannelizer::createFilterChain: -> take center half (decimate by 2)"); - m_filterStages.push_back(new FilterStage(FilterStage::ModeCenter)); - return createFilterChain(sigStart + rot, sigEnd - rot, chanStart, chanEnd); - } - Real ofs = ((chanEnd - chanStart) / 2.0 + chanStart) - ((sigEnd - sigStart) / 2.0 + sigStart); - //qDebug("DownChannelizer::createFilterChain: -> complete (final BW %.1f, frequency offset %.1f)", sigBw, ofs); + qDebug("DownChannelizer::createFilterChain: -> complete (final BW %.1f, frequency offset %.1f)", sigBw, ofs); return ofs; }