Removed useless AGC clamping

This commit is contained in:
f4exb 2023-12-09 13:23:41 +01:00
parent aee055e883
commit 4e25f4d678
5 changed files with 2 additions and 39 deletions

View File

@ -90,7 +90,6 @@ FT8DemodSink::FT8DemodSink() :
m_magsqCount = 0;
m_agc.setThresholdEnable(false); // no squelch
m_agc.setClamping(false); // no clamping
SSBFilter = new fftfilt(m_LowCutoff / FT8DemodSettings::m_ft8SampleRate, m_Bandwidth / FT8DemodSettings::m_ft8SampleRate, m_ssbFftLen);

View File

@ -76,9 +76,6 @@ SSBDemodSink::SSBDemodSink() :
m_magsqCur = 0.0;
m_magsqPrev = 0.0;
m_agc.setClampMax(SDR_RX_SCALED/100.0);
m_agc.setClamping(m_agcClamping);
SSBFilter = new fftfilt(m_LowCutoff / m_audioSampleRate, m_Bandwidth / m_audioSampleRate, m_ssbFftLen);
DSBFilter = new fftfilt((2.0f * m_Bandwidth) / m_audioSampleRate, 2 * m_ssbFftLen);
@ -473,7 +470,6 @@ void SSBDemodSink::applySettings(const SSBDemodSettings& settings, bool force)
if (m_agcClamping != agcClamping)
{
m_agc.setClamping(agcClamping);
m_agcClamping = agcClamping;
}

View File

@ -91,9 +91,6 @@ UDPSinkSink::UDPSinkSink() :
qWarning("UDPSinkSink::UDPSinkSink: cannot bind audio port");
}
m_agc.setClampMax(SDR_RX_SCALED*SDR_RX_SCALED);
m_agc.setClamping(true);
//DSPEngine::instance()->addAudioSink(&m_audioFifo);
applyChannelSettings(m_channelSampleRate, m_channelFrequencyOffset, true);
@ -338,7 +335,7 @@ void UDPSinkSink::audioReadyRead()
uint res = m_audioFifo.write((const quint8*)&m_audioBuffer[0], m_audioBufferFill);
if (res != m_audioBufferFill) {
qDebug("UDPSinkSink::audioReadyRead: (mono) lost %u samples", m_audioBufferFill - res);
qDebug("UDPSinkSink::audioReadyRead: (mono) lost %lu samples", m_audioBufferFill - res);
}
m_audioBufferFill = 0;

View File

@ -63,9 +63,7 @@ MagAGC::MagAGC(int historySize, double R, double threshold) :
m_stepDownCounter(0),
m_gateCounter(0),
m_stepDownDelay(historySize),
m_clamping(false),
m_R2(R*R),
m_clampMax(1.0),
m_hardLimiting(false)
{}
@ -119,30 +117,7 @@ double MagAGC::feedAndGetValue(const Complex& ci)
{
m_magsq = ci.real()*ci.real() + ci.imag()*ci.imag();
m_moving_average.feed(m_magsq);
if (m_clamping)
{
if (m_squared)
{
if (m_magsq > m_clampMax) {
m_u0 = m_clampMax / m_magsq;
} else {
m_u0 = m_R / m_moving_average.average();
}
}
else
{
if (sqrt(m_magsq) > m_clampMax) {
m_u0 = m_clampMax / sqrt(m_magsq);
} else {
m_u0 = m_R / sqrt(m_moving_average.average());
}
}
}
else
{
m_u0 = m_R / (m_squared ? m_moving_average.average() : sqrt(m_moving_average.average()));
}
m_u0 = m_R / (m_squared ? m_moving_average.average() : sqrt(m_moving_average.average()));
if (m_thresholdEnable)
{

View File

@ -59,8 +59,6 @@ public:
void setThresholdEnable(bool enable);
void setGate(int gate) { m_gate = gate; m_gateCounter = 0; m_count = 0; }
void setStepDownDelay(int stepDownDelay) { m_stepDownDelay = stepDownDelay; m_gateCounter = 0; m_count = 0; }
void setClamping(bool clamping) { m_clamping = clamping; }
void setClampMax(double clampMax) { m_clampMax = clampMax; }
int getStepDownDelay() const { return m_stepDownDelay; }
float getStepValue() const;
void setHardLimiting(bool hardLimiting) { m_hardLimiting = hardLimiting; }
@ -78,9 +76,7 @@ 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)
bool m_clamping; //!< clamping active
double m_R2; //!< square of ordered magnitude
double m_clampMax; //!< maximum to clamp to as power value
bool m_hardLimiting; //!< hard limit multiplier so that resulting sample magnitude does not exceed 1.0
double hardLimiter(double multiplier, double magsq);