1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-14 20:31:53 -05:00

SSB demod: clamp AGC value

This commit is contained in:
f4exb 2017-08-06 00:02:16 +02:00
parent 428d22579d
commit 8a5668a186
3 changed files with 9 additions and 4 deletions

View File

@ -68,6 +68,9 @@ SSBDemod::SSBDemod(BasebandSampleSink* sampleSink) :
m_magsqPeak = 0.0f; m_magsqPeak = 0.0f;
m_magsqCount = 0; m_magsqCount = 0;
m_agc.setClampMax(32768.0*32768.0);
m_agc.setClamping(true);
SSBFilter = new fftfilt(m_LowCutoff / m_audioSampleRate, m_Bandwidth / m_audioSampleRate, ssbFftLen); SSBFilter = new fftfilt(m_LowCutoff / m_audioSampleRate, m_Bandwidth / m_audioSampleRate, ssbFftLen);
DSBFilter = new fftfilt((2.0f * m_Bandwidth) / m_audioSampleRate, 2 * ssbFftLen); DSBFilter = new fftfilt((2.0f * m_Bandwidth) / m_audioSampleRate, 2 * ssbFftLen);

View File

@ -71,12 +71,14 @@ void MagAGC::resize(int historySize, Real R)
m_stepUpCounter = 0; m_stepUpCounter = 0;
m_stepDownCounter = m_stepLength; m_stepDownCounter = m_stepLength;
AGC::resize(historySize, R); AGC::resize(historySize, R);
m_moving_average.fill(0);
} }
void MagAGC::setOrder(double R) void MagAGC::setOrder(double R)
{ {
m_R2 = R*R; m_R2 = R*R;
AGC::setOrder(R); AGC::setOrder(R);
m_moving_average.fill(0);
} }
void MagAGC::setThresholdEnable(bool enable) void MagAGC::setThresholdEnable(bool enable)
@ -110,7 +112,7 @@ double MagAGC::feedAndGetValue(const Complex& ci)
else else
{ {
double u02 = m_R2 / m_moving_average.average(); double u02 = m_R2 / m_moving_average.average();
m_u0 = (u02 * m_magsq > m_clampMax) ? m_clampMax / sqrt(m_magsq) : sqrt(u02); m_u0 = (u02 * m_magsq > m_clampMax) ? sqrt(m_clampMax / m_magsq) : sqrt(u02);
} }
} }
else else

View File

@ -24,7 +24,7 @@ public:
protected: protected:
double m_u0; //!< AGC factor double m_u0; //!< AGC factor
double m_R; //!< objective mag double m_R; //!< ordered magnitude
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.
int m_historySize; //!< Averaging length (attack) int m_historySize; //!< Averaging length (attack)
int m_count; //!< Samples counter int m_count; //!< Samples counter
@ -61,8 +61,8 @@ private:
int m_gateCounter; //!< threshold gate samples counter int m_gateCounter; //!< threshold gate samples counter
int m_stepDownDelay; //!< delay in samples before cutoff (release) int m_stepDownDelay; //!< delay in samples before cutoff (release)
bool m_clamping; //!< clamping active bool m_clamping; //!< clamping active
double m_R2; //!< square of objective magnitude double m_R2; //!< square of ordered magnitude
double m_clampMax; //!< maximum to clamp to double m_clampMax; //!< maximum to clamp to as power value
}; };