From 681863b2a294c895b32144324a9cc2d5f9e45f16 Mon Sep 17 00:00:00 2001 From: f4exb Date: Sun, 25 Oct 2015 14:47:28 +0100 Subject: [PATCH] Fixed NFM squelch --- plugins/channel/nfm/nfmdemod.cpp | 19 +++++++++++++++++-- plugins/channel/nfm/nfmdemod.h | 2 ++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/plugins/channel/nfm/nfmdemod.cpp b/plugins/channel/nfm/nfmdemod.cpp index 1d00df606..eb5797a7f 100644 --- a/plugins/channel/nfm/nfmdemod.cpp +++ b/plugins/channel/nfm/nfmdemod.cpp @@ -33,6 +33,8 @@ MESSAGE_CLASS_DEFINITION(NFMDemod::MsgConfigureNFMDemod, Message) NFMDemod::NFMDemod() : m_ctcssIndex(0), m_sampleCount(0), + m_squelchCount(0), + m_agcAttack(2400), m_afSquelch(2, afSqTones), m_audioFifo(4, 48000), m_settingsMutex(QMutex::Recursive) @@ -54,7 +56,7 @@ NFMDemod::NFMDemod() : m_audioBufferFill = 0; m_agcLevel = 1.0; - m_AGC.resize(240, m_agcLevel); + m_AGC.resize(m_agcAttack, m_agcLevel); m_magsq = 0; m_ctcssDetector.setCoefficients(3000, 6000.0); // 0.5s / 2 Hz resolution @@ -173,7 +175,20 @@ void NFMDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto // AF processing - squelchOpen = (getMag() > m_squelchLevel); + if (getMag() > m_squelchLevel) + { + if (m_squelchCount < m_agcAttack) + { + m_squelchCount++; + } + } + else + { + m_squelchCount = 0; + } + + //squelchOpen = (getMag() > m_squelchLevel); + squelchOpen = m_squelchCount == m_agcAttack; // wait for AGC to stabilize /* if (m_afSquelch.analyze(demod)) diff --git a/plugins/channel/nfm/nfmdemod.h b/plugins/channel/nfm/nfmdemod.h index 2c3c33a61..3a12096bc 100644 --- a/plugins/channel/nfm/nfmdemod.h +++ b/plugins/channel/nfm/nfmdemod.h @@ -155,6 +155,8 @@ private: int m_ctcssIndex; // 0 for nothing detected int m_ctcssIndexSelected; int m_sampleCount; + int m_squelchCount; + int m_agcAttack; double m_squelchLevel;