From ae624053442a8f6489f5b45b3825df3858a045c0 Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Tue, 21 Jul 2015 10:33:40 -0700 Subject: [PATCH] Simplify audio muting. Zero out the audio buffer instead of muting the codec. The HPF (and other downstream signal processing) can continue running, not produce discontinuities from being effectively halted during mute. --- firmware/baseband/main.cpp | 41 +++++++++++--------------------------- 1 file changed, 12 insertions(+), 29 deletions(-) diff --git a/firmware/baseband/main.cpp b/firmware/baseband/main.cpp index 5b3d9436..3b1f9a28 100755 --- a/firmware/baseband/main.cpp +++ b/firmware/baseband/main.cpp @@ -429,17 +429,6 @@ protected: feed_audio_stats(audio); } - void mute_audio_buffer() { - auto audio_buffer = audio::dma::tx_empty_buffer();; - for(size_t i=0; i channel_spectrum_decimator { 4 }; @@ -474,16 +463,6 @@ private: ); } - void mute_audio_stats(const size_t count, const size_t sampling_rate) { - audio_stats.mute( - count, - sampling_rate, - [this](const AudioStatistics statistics) { - this->post_audio_stats_message(statistics); - } - ); - } - void post_audio_stats_message(const AudioStatistics statistics) { if( audio_stats_message.is_free() ) { audio_stats_message.statistics = statistics; @@ -572,15 +551,19 @@ public: auto audio = demod.execute(channel, work_audio_buffer); static uint64_t audio_present_history = 0; - const auto audio_present = squelch.execute(audio); - audio_present_history = (audio_present_history << 1) | (audio_present ? 1 : 0); + const auto audio_present_now = squelch.execute(audio); + audio_present_history = (audio_present_history << 1) | (audio_present_now ? 1 : 0); + const bool audio_present = (audio_present_history != 0); - if( audio_present_history ) { - audio_hpf.execute_in_place(audio); - fill_audio_buffer(audio); - } else { - mute_audio_buffer(); + if( !audio_present ) { + // Zero audio buffer. + for(size_t i=0; i