From 8adaddac5ffb90514fd337754dcc988ad62222ae Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Sun, 3 Jan 2016 17:03:16 -0800 Subject: [PATCH] Make FM squelch runtime-configurable. --- firmware/baseband/dsp_squelch.cpp | 4 ++++ firmware/baseband/dsp_squelch.hpp | 4 +++- firmware/baseband/proc_nfm_audio.cpp | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/firmware/baseband/dsp_squelch.cpp b/firmware/baseband/dsp_squelch.cpp index d9d39591..6420a087 100644 --- a/firmware/baseband/dsp_squelch.cpp +++ b/firmware/baseband/dsp_squelch.cpp @@ -43,3 +43,7 @@ bool FMSquelch::execute(buffer_s16_t audio) { return (max_squared < threshold_squared); } + +void FMSquelch::set_threshold(const uint32_t new_value) { + threshold_squared = new_value * new_value; +} diff --git a/firmware/baseband/dsp_squelch.hpp b/firmware/baseband/dsp_squelch.hpp index 8d1923c6..cd8e841d 100644 --- a/firmware/baseband/dsp_squelch.hpp +++ b/firmware/baseband/dsp_squelch.hpp @@ -33,9 +33,11 @@ class FMSquelch { public: bool execute(buffer_s16_t audio); + void set_threshold(const uint32_t new_value); + private: static constexpr size_t N = 32; - static constexpr uint32_t threshold_squared = 8192 * 8192; + uint32_t threshold_squared { 0 }; IIRBiquadFilter non_audio_hpf { non_audio_hpf_config }; }; diff --git a/firmware/baseband/proc_nfm_audio.cpp b/firmware/baseband/proc_nfm_audio.cpp index 5f420440..7742f65f 100644 --- a/firmware/baseband/proc_nfm_audio.cpp +++ b/firmware/baseband/proc_nfm_audio.cpp @@ -106,6 +106,7 @@ void NarrowbandFMAudio::configure(const NBFMConfigureMessage& message) { channel_filter_pass_f = message.channel_filter.pass_frequency_normalized * channel_filter_input_fs; channel_filter_stop_f = message.channel_filter.stop_frequency_normalized * channel_filter_input_fs; channel_spectrum.set_decimation_factor(std::floor((channel_filter_output_fs / 2) / ((channel_filter_pass_f + channel_filter_stop_f) / 2))); + squelch.set_threshold(8192); configured = true; }