Browse Source

Fixed some AGC issues

chirpmodem-v8.0.0
f4exb 3 years ago
parent
commit
f98800702c
  1. 7
      sdrbase/dsp/agc.cpp
  2. 3
      sdrbase/dsp/agc.h

7
sdrbase/dsp/agc.cpp

@ -63,7 +63,6 @@ MagAGC::MagAGC(int historySize, double R, double threshold) : @@ -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() @@ -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)

3
sdrbase/dsp/agc.h

@ -39,7 +39,7 @@ protected: @@ -39,7 +39,7 @@ protected:
double m_u0; //!< AGC factor
double m_R; //!< ordered magnitude
MovingAverage<double> 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: @@ -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);

Loading…
Cancel
Save