From 07fc282d89bdca63382b65a5d65c45c774935e22 Mon Sep 17 00:00:00 2001 From: f4exb Date: Fri, 12 May 2017 10:45:18 +0200 Subject: [PATCH] NFM demod: quadrature squelch attack and decay --- plugins/channelrx/demodnfm/nfmdemod.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/plugins/channelrx/demodnfm/nfmdemod.cpp b/plugins/channelrx/demodnfm/nfmdemod.cpp index bb90e9907..32f200651 100644 --- a/plugins/channelrx/demodnfm/nfmdemod.cpp +++ b/plugins/channelrx/demodnfm/nfmdemod.cpp @@ -183,25 +183,21 @@ void NFMDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto if ( (m_running.m_deltaSquelch && ((deviation > m_squelchLevel) || (deviation < -m_squelchLevel))) || (!m_running.m_deltaSquelch && (m_movingAverage.average() < m_squelchLevel)) ) { - if (m_squelchCount < m_squelchGate) + if (m_squelchCount > 0) { - m_squelchCount = 0; // return to 0 - } - else - { - m_squelchCount--; // grace period + m_squelchCount--; } } else { - if (m_squelchCount < m_squelchGate + 2) + if (m_squelchCount < m_squelchGate + 480) { m_squelchCount++; } } //squelchOpen = (getMag() > m_squelchLevel); - m_squelchOpen = m_squelchCount >= m_squelchGate; // wait for AGC to stabilize + m_squelchOpen = (m_squelchCount > m_squelchGate); /* if (m_afSquelch.analyze(demod)) @@ -248,8 +244,9 @@ void NFMDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto } else { + Real squelchFactor = (Real) (m_squelchCount - m_squelchGate) / 480.0f; demod = m_bandpass.filter(demod); - sample = demod * m_running.m_volume; + sample = demod * m_running.m_volume * squelchFactor * squelchFactor; } } else