From aa607767950b1e86891a71d4fdadd3a41c14c127 Mon Sep 17 00:00:00 2001 From: f4exb Date: Fri, 3 May 2019 00:23:38 +0200 Subject: [PATCH] Down channelizer: fixed sample saturation in 16 bit mode --- sdrbase/dsp/downchannelizer.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sdrbase/dsp/downchannelizer.cpp b/sdrbase/dsp/downchannelizer.cpp index eca3c074d..3b76144d1 100644 --- a/sdrbase/dsp/downchannelizer.cpp +++ b/sdrbase/dsp/downchannelizer.cpp @@ -79,6 +79,10 @@ void DownChannelizer::feed(const SampleVector::const_iterator& begin, const Samp for (; stage != m_filterStages.end(); ++stage) { +#ifndef SDR_RX_SAMPLE_24BIT + s.m_real /= 2; // avoid saturation on 16 bit samples + s.m_imag /= 2; +#endif if(!(*stage)->work(&s)) { break; @@ -87,8 +91,10 @@ void DownChannelizer::feed(const SampleVector::const_iterator& begin, const Samp if(stage == m_filterStages.end()) { - s.m_real /= (1<<(m_filterStages.size())); +#ifdef SDR_RX_SAMPLE_24BIT + s.m_real /= (1<<(m_filterStages.size())); // on 32 bit samples there is enough headroom to just divide the final result s.m_imag /= (1<<(m_filterStages.size())); +#endif m_sampleBuffer.push_back(s); } }