1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-12-23 10:05:46 -05:00

SSB demod: further optimize AGC steep transitions mitigation

This commit is contained in:
f4exb 2023-12-01 17:24:28 +01:00
parent f2db907677
commit 2f5cbd1092
2 changed files with 6 additions and 4 deletions

View File

@ -177,11 +177,12 @@ void SSBDemodSink::processOneSample(Complex &ci)
m_audioActive = delayedSample.real() != 0.0; m_audioActive = delayedSample.real() != 0.0;
m_magsqCur = std::norm(sideband[i]*agcVal); m_magsqCur = std::norm(sideband[i]*agcVal);
// Prevent overload if squared magnitude variation is 90% full scale (0.9*.0.9 = 0.81) // Prevent overload based on squared magnitude variation
// Only if AGC is active // Only if AGC is active
if (m_agcActive && (m_magsqCur - m_magsqPrev > m_agcTarget*m_agcTarget*8.1)) if (m_agcActive && (std::abs(m_magsqCur - m_magsqPrev) > m_agcTarget*m_agcTarget*5.0))
{ {
m_agc.reset(m_agcTarget*100.0); // Quench AGC at -20dB the target m_agc.reset(m_agcTarget*100.0); // Quench AGC at -20dB the target
m_agc.resetStepCounters();
m_squelchDelayLine.write(sideband[i]); m_squelchDelayLine.write(sideband[i]);
} }
else else
@ -198,7 +199,8 @@ void SSBDemodSink::processOneSample(Complex &ci)
} }
else else
{ {
fftfilt::cmplx z = m_agcActive ? delayedSample * m_agc.getStepValue() : delayedSample; // fftfilt::cmplx z = m_agcActive ? delayedSample * m_agc.getStepValue() : delayedSample;
fftfilt::cmplx& z = delayedSample;
if (m_audioBinaual) if (m_audioBinaual)
{ {
@ -503,4 +505,3 @@ void SSBDemodSink::applySettings(const SSBDemodSettings& settings, bool force)
m_agcActive = settings.m_agc; m_agcActive = settings.m_agc;
m_settings = settings; m_settings = settings;
} }

View File

@ -64,6 +64,7 @@ public:
int getStepDownDelay() const { return m_stepDownDelay; } int getStepDownDelay() const { return m_stepDownDelay; }
float getStepValue() const; float getStepValue() const;
void setHardLimiting(bool hardLimiting) { m_hardLimiting = hardLimiting; } void setHardLimiting(bool hardLimiting) { m_hardLimiting = hardLimiting; }
void resetStepCounters() { m_stepUpCounter = 0; m_stepDownCounter = 0; }
private: private:
bool m_squared; //!< use squared magnitude (power) to compute AGC value bool m_squared; //!< use squared magnitude (power) to compute AGC value