From 68f742fad7fad54f5392b22b97062dc3e15ab483 Mon Sep 17 00:00:00 2001 From: f4exb Date: Sat, 13 May 2017 11:00:02 +0200 Subject: [PATCH] NFM demod: use smootherstep function for squelch attack and decay --- plugins/channelrx/demodnfm/nfmdemod.cpp | 4 ++-- plugins/channelrx/demodnfm/nfmdemod.h | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/plugins/channelrx/demodnfm/nfmdemod.cpp b/plugins/channelrx/demodnfm/nfmdemod.cpp index d2b4aceb6..e2713c884 100644 --- a/plugins/channelrx/demodnfm/nfmdemod.cpp +++ b/plugins/channelrx/demodnfm/nfmdemod.cpp @@ -277,8 +277,8 @@ void NFMDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto } else { - Real squelchFactor = (Real) (m_squelchCount - m_squelchGate) / 480.0f; - sample = demod * m_running.m_volume * squelchFactor * squelchFactor; + Real squelchFactor = smootherstep((Real) (m_squelchCount - m_squelchGate) / 480.0f); + sample = demod * m_running.m_volume * squelchFactor; } } } diff --git a/plugins/channelrx/demodnfm/nfmdemod.h b/plugins/channelrx/demodnfm/nfmdemod.h index 9a02f47e6..ee1a6e24f 100644 --- a/plugins/channelrx/demodnfm/nfmdemod.h +++ b/plugins/channelrx/demodnfm/nfmdemod.h @@ -244,6 +244,15 @@ private: PhaseDiscriminators m_phaseDiscri; void apply(); + + float smootherstep(float x) + { + double x3 = x * x * x; + double x4 = x * x3; + double x5 = x * x4; + + return (float) (6.0*x5 - 15.0*x4 + 10.0*x3); + } }; #endif // INCLUDE_NFMDEMOD_H