1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-13 20:01:46 -05:00

AM demod: fixed volume AGC

This commit is contained in:
f4exb 2018-02-16 00:43:21 +01:00
parent 64044e521e
commit b680b11206

View File

@ -70,43 +70,46 @@ template<uint32_t AvgSize>
class SimpleAGC class SimpleAGC
{ {
public: public:
SimpleAGC(Real cutoff=0, Real clip=0) : SimpleAGC(Real initial, Real cutoff=0, Real clip=0) :
m_squelchOpen(false),
m_cutoff(cutoff), m_cutoff(cutoff),
m_clip(clip) m_clip(clip),
{} m_moving_average(AvgSize, initial)
{
}
void resize(Real cutoff=0, Real clip=0) void resize(Real initial, Real cutoff=0, Real clip=0)
{ {
m_cutoff = cutoff; m_cutoff = cutoff;
m_clip = clip; m_clip = clip;
m_moving_average.resize(AvgSize, initial);
}
void fill(double value)
{
m_moving_average.fill(value);
} }
Real getValue() Real getValue()
{ {
if ((Real) m_moving_average > m_clip) if ((Real) m_moving_average.average() > m_clip) {
{ return (Real) m_moving_average.average();
return (Real) m_moving_average; } else {
} else
{
return m_clip; return m_clip;
} }
} }
void feed(Real value) void feed(Real value)
{ {
if (value > m_cutoff) if (value > m_cutoff) {
{ m_moving_average.feed(value);
m_moving_average(value);
} }
} }
private: private:
bool m_squelchOpen; // open for processing
Real m_cutoff; // consider samples only above this level Real m_cutoff; // consider samples only above this level
Real m_clip; // never go below this level Real m_clip; // never go below this level
//MovingAverage<double> m_moving_average; // Averaging engine. The stack length conditions the smoothness of AGC. MovingAverage<double> m_moving_average; // Averaging engine. The stack length conditions the smoothness of AGC.
MovingAverageUtil<Real, double, AvgSize> m_moving_average; //MovingAverageUtil<Real, double, AvgSize> m_moving_average;
}; };
#endif /* INCLUDE_GPL_DSP_AGC_H_ */ #endif /* INCLUDE_GPL_DSP_AGC_H_ */