From f98800702cdd64697c088122ed991971ae146141 Mon Sep 17 00:00:00 2001 From: f4exb Date: Mon, 11 Dec 2023 01:12:03 +0100 Subject: [PATCH] Fixed some AGC issues --- sdrbase/dsp/agc.cpp | 7 ++----- sdrbase/dsp/agc.h | 3 +-- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/sdrbase/dsp/agc.cpp b/sdrbase/dsp/agc.cpp index 1941481ec..905edc7bd 100644 --- a/sdrbase/dsp/agc.cpp +++ b/sdrbase/dsp/agc.cpp @@ -63,7 +63,6 @@ MagAGC::MagAGC(int historySize, double R, double threshold) : m_stepDownCounter(0), m_gateCounter(0), m_stepDownDelay(historySize), - m_R2(R*R), m_hardLimiting(false) {} @@ -72,20 +71,18 @@ MagAGC::~MagAGC() void MagAGC::resize(int historySize, int stepLength, Real R) { - m_R2 = R*R; m_stepLength = stepLength; m_stepDelta = 1.0 / m_stepLength; m_stepUpCounter = 0; m_stepDownCounter = 0; AGC::resize(historySize, R); - m_moving_average.fill(0); + m_moving_average.fill(m_squared ? R : R*R); } void MagAGC::setOrder(double R) { - m_R2 = R*R; AGC::setOrder(R); - m_moving_average.fill(0); + m_moving_average.fill(m_squared ? R : R*R); } void MagAGC::setThresholdEnable(bool enable) diff --git a/sdrbase/dsp/agc.h b/sdrbase/dsp/agc.h index 62f3e3ebd..2a288139e 100644 --- a/sdrbase/dsp/agc.h +++ b/sdrbase/dsp/agc.h @@ -39,7 +39,7 @@ protected: double m_u0; //!< AGC factor double m_R; //!< ordered magnitude MovingAverage m_moving_average; //!< Averaging engine. The stack length conditions the smoothness of AGC. - int m_historySize; //!< Averaging length (attack) + int m_historySize; //!< Averaging length (the longer the slower the AGC) int m_count; //!< Samples counter }; @@ -76,7 +76,6 @@ private: int m_stepDownCounter; //!< step down transition samples counter int m_gateCounter; //!< threshold gate samples counter int m_stepDownDelay; //!< delay in samples before cutoff (release) - double m_R2; //!< square of ordered magnitude bool m_hardLimiting; //!< hard limit multiplier so that resulting sample magnitude does not exceed 1.0 double hardLimiter(double multiplier, double magsq);