From 1915ff980ff8df5ea02df4320551dab07df7fbc5 Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Sat, 30 Jan 2016 17:28:11 -0800 Subject: [PATCH] Add AM processor decim_2. --- firmware/application/analog_audio_app.cpp | 1 + firmware/baseband/proc_am_audio.cpp | 9 +++++++-- firmware/baseband/proc_am_audio.hpp | 1 + firmware/common/dsp_fir_taps.hpp | 2 +- firmware/common/message.hpp | 3 +++ 5 files changed, 13 insertions(+), 3 deletions(-) diff --git a/firmware/application/analog_audio_app.cpp b/firmware/application/analog_audio_app.cpp index affcdcd9..60eaca4e 100644 --- a/firmware/application/analog_audio_app.cpp +++ b/firmware/application/analog_audio_app.cpp @@ -102,6 +102,7 @@ void AnalogAudioModel::configure_am() { const AMConfigureMessage message { taps_6k0_decim_0, taps_6k0_decim_1, + taps_6k0_decim_2, taps_6k0_channel, audio_12k_hpf_300hz_config }; diff --git a/firmware/baseband/proc_am_audio.cpp b/firmware/baseband/proc_am_audio.cpp index 9d8a2341..ad655f54 100644 --- a/firmware/baseband/proc_am_audio.cpp +++ b/firmware/baseband/proc_am_audio.cpp @@ -32,7 +32,8 @@ void NarrowbandAMAudio::execute(const buffer_c8_t& buffer) { const auto decim_0_out = decim_0.execute(buffer, dst_buffer); const auto decim_1_out = decim_1.execute(decim_0_out, dst_buffer); - const auto channel_out = channel_filter.execute(decim_1_out, dst_buffer); + const auto decim_2_out = decim_2.execute(decim_1_out, dst_buffer); + const auto channel_out = channel_filter.execute(decim_2_out, dst_buffer); // TODO: Feed channel_stats post-decimation data? feed_channel_stats(channel_out); @@ -65,11 +66,15 @@ void NarrowbandAMAudio::configure(const AMConfigureMessage& message) { constexpr size_t decim_1_input_fs = decim_0_output_fs; constexpr size_t decim_1_output_fs = decim_1_input_fs / decim_1.decimation_factor; - constexpr size_t channel_filter_input_fs = decim_1_output_fs; + constexpr size_t decim_2_input_fs = decim_1_output_fs; + constexpr size_t decim_2_output_fs = decim_2_input_fs / decim_2_decimation_factor; + + constexpr size_t channel_filter_input_fs = decim_2_output_fs; const size_t channel_filter_output_fs = channel_filter_input_fs / channel_filter_decimation_factor; decim_0.configure(message.decim_0_filter.taps, 33554432); decim_1.configure(message.decim_1_filter.taps, 131072); + decim_2.configure(message.decim_2_filter.taps, decim_2_decimation_factor); channel_filter.configure(message.channel_filter.taps, channel_filter_decimation_factor); 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; diff --git a/firmware/baseband/proc_am_audio.hpp b/firmware/baseband/proc_am_audio.hpp index 569b5a1d..07406aa2 100644 --- a/firmware/baseband/proc_am_audio.hpp +++ b/firmware/baseband/proc_am_audio.hpp @@ -56,6 +56,7 @@ private: dsp::decimate::FIRC8xR16x24FS4Decim8 decim_0; dsp::decimate::FIRC16xR16x32Decim8 decim_1; + dsp::decimate::FIRAndDecimateComplex decim_2; dsp::decimate::FIRAndDecimateComplex channel_filter; uint32_t channel_filter_pass_f = 0; uint32_t channel_filter_stop_f = 0; diff --git a/firmware/common/dsp_fir_taps.hpp b/firmware/common/dsp_fir_taps.hpp index 46c7ca2c..53c7fa5a 100644 --- a/firmware/common/dsp_fir_taps.hpp +++ b/firmware/common/dsp_fir_taps.hpp @@ -178,7 +178,7 @@ constexpr fir_taps_real<32> taps_6k0_decim_1 { }; // Channel filter: fs=48000, pass=3000, stop=6700, decim=1, fout=48000 -constexpr fir_taps_real<32> taps_6k0_channel { +constexpr fir_taps_real<32> taps_6k0_decim_2 { .pass_frequency_normalized = 3000.0f / 48000.0f, .stop_frequency_normalized = 6700.0f / 48000.0f, .taps = { { diff --git a/firmware/common/message.hpp b/firmware/common/message.hpp index 1ee92fd5..dc3385ea 100644 --- a/firmware/common/message.hpp +++ b/firmware/common/message.hpp @@ -376,11 +376,13 @@ public: constexpr AMConfigureMessage( const fir_taps_real<24> decim_0_filter, const fir_taps_real<32> decim_1_filter, + const fir_taps_real<32> decim_2_filter, const fir_taps_real<32> channel_filter, const iir_biquad_config_t audio_hpf_config ) : Message { ID::AMConfigure }, decim_0_filter(decim_0_filter), decim_1_filter(decim_1_filter), + decim_2_filter(decim_2_filter), channel_filter(channel_filter), audio_hpf_config { audio_hpf_config } { @@ -388,6 +390,7 @@ public: const fir_taps_real<24> decim_0_filter; const fir_taps_real<32> decim_1_filter; + const fir_taps_real<32> decim_2_filter; const fir_taps_real<32> channel_filter; const iir_biquad_config_t audio_hpf_config; };