Skip to content

Commit

Permalink
SSB demod: further optimize AGC steep transitions mitigation
Browse files Browse the repository at this point in the history
  • Loading branch information
f4exb committed Dec 1, 2023
1 parent f2db907 commit 2f5cbd1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
9 changes: 5 additions & 4 deletions plugins/channelrx/demodssb/ssbdemodsink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,12 @@ void SSBDemodSink::processOneSample(Complex &ci)
m_audioActive = delayedSample.real() != 0.0;
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
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.resetStepCounters();
m_squelchDelayLine.write(sideband[i]);
}
else
Expand All @@ -198,7 +199,8 @@ void SSBDemodSink::processOneSample(Complex &ci)
}
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)
{
Expand Down Expand Up @@ -503,4 +505,3 @@ void SSBDemodSink::applySettings(const SSBDemodSettings& settings, bool force)
m_agcActive = settings.m_agc;
m_settings = settings;
}

1 change: 1 addition & 0 deletions sdrbase/dsp/agc.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class SDRBASE_API MagAGC : public AGC
int getStepDownDelay() const { return m_stepDownDelay; }
float getStepValue() const;
void setHardLimiting(bool hardLimiting) { m_hardLimiting = hardLimiting; }
void resetStepCounters() { m_stepUpCounter = 0; m_stepDownCounter = 0; }

private:
bool m_squared; //!< use squared magnitude (power) to compute AGC value
Expand Down

0 comments on commit 2f5cbd1

Please sign in to comment.