From a78997b5e79274d157ddf821954bcda1333a847b Mon Sep 17 00:00:00 2001 From: f4exb Date: Thu, 25 Jan 2018 00:48:11 +0100 Subject: [PATCH] 24 bit DSP build: corrected IQ imbalance calculation for any sample size --- sdrbase/dsp/dspdevicesourceengine.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sdrbase/dsp/dspdevicesourceengine.cpp b/sdrbase/dsp/dspdevicesourceengine.cpp index 6cc6086c6..4899dce82 100644 --- a/sdrbase/dsp/dspdevicesourceengine.cpp +++ b/sdrbase/dsp/dspdevicesourceengine.cpp @@ -232,14 +232,14 @@ void DSPDeviceSourceEngine::imbalance(SampleVector::iterator begin, SampleVector m_iRange = (m_iRange * 15 + (iMax - iMin)) >> 4; m_qRange = (m_qRange * 15 + (qMax - qMin)) >> 4; - // calculate imbalance as Q15.16 + // calculate imbalance on 32 bit full scale if(m_qRange != 0) { - m_imbalance = ((uint)m_iRange << 16) / (uint)m_qRange; + m_imbalance = ((uint)m_iRange << (32-SDR_RX_SAMP_SZ)) / (uint)m_qRange; } - // correct imbalance and convert back to signed int 16 + // correct imbalance and convert back to sample size for(SampleVector::iterator it = begin; it < end; it++) { - it->m_imag = (it->m_imag * m_imbalance) >> 16; + it->m_imag = (it->m_imag * m_imbalance) >> (32-SDR_RX_SAMP_SZ); } }