From 7c65a2d65017e5f34274a63c2982f643af1ec0fa Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Fri, 29 Jan 2016 16:11:00 -0800 Subject: [PATCH] Clean up baseband processor statics. --- firmware/baseband/proc_am_audio.cpp | 9 ++------- firmware/baseband/proc_am_audio.hpp | 5 ++++- firmware/baseband/proc_nfm_audio.cpp | 9 ++------- firmware/baseband/proc_nfm_audio.hpp | 5 ++++- firmware/baseband/proc_wfm_audio.cpp | 9 ++------- firmware/baseband/proc_wfm_audio.hpp | 3 +++ 6 files changed, 17 insertions(+), 23 deletions(-) diff --git a/firmware/baseband/proc_am_audio.cpp b/firmware/baseband/proc_am_audio.cpp index 3ce9f2e5..b3ff0ba9 100644 --- a/firmware/baseband/proc_am_audio.cpp +++ b/firmware/baseband/proc_am_audio.cpp @@ -63,18 +63,13 @@ void NarrowbandAMAudio::on_message(const Message* const message) { } void NarrowbandAMAudio::configure(const AMConfigureMessage& message) { - constexpr size_t baseband_fs = 3072000; - constexpr size_t decim_0_input_fs = baseband_fs; - constexpr size_t decim_0_decimation_factor = 8; - constexpr size_t decim_0_output_fs = decim_0_input_fs / decim_0_decimation_factor; + constexpr size_t decim_0_output_fs = decim_0_input_fs / decim_0.decimation_factor; constexpr size_t decim_1_input_fs = decim_0_output_fs; - constexpr size_t decim_1_decimation_factor = 8; - constexpr size_t decim_1_output_fs = decim_1_input_fs / decim_1_decimation_factor; + 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 channel_filter_decimation_factor = 1; constexpr size_t channel_filter_output_fs = channel_filter_input_fs / channel_filter_decimation_factor; decim_0.configure(message.decim_0_filter.taps, 33554432); diff --git a/firmware/baseband/proc_am_audio.hpp b/firmware/baseband/proc_am_audio.hpp index ef1b442a..2035c40c 100644 --- a/firmware/baseband/proc_am_audio.hpp +++ b/firmware/baseband/proc_am_audio.hpp @@ -39,6 +39,10 @@ public: void on_message(const Message* const message) override; private: + static constexpr size_t baseband_fs = 3072000; + static constexpr size_t channel_filter_decimation_factor = 1; + static constexpr size_t post_channel_decimation_factor = 6; + std::array dst; const buffer_c16_t dst_buffer { dst.data(), @@ -56,7 +60,6 @@ private: uint32_t channel_filter_pass_f; uint32_t channel_filter_stop_f; - static constexpr size_t post_channel_decimation_factor = 6; BlockDecimator<32> channel_block_buffer { post_channel_decimation_factor }; dsp::demodulate::AM demod; diff --git a/firmware/baseband/proc_nfm_audio.cpp b/firmware/baseband/proc_nfm_audio.cpp index 8893fa30..60e56039 100644 --- a/firmware/baseband/proc_nfm_audio.cpp +++ b/firmware/baseband/proc_nfm_audio.cpp @@ -63,18 +63,13 @@ void NarrowbandFMAudio::on_message(const Message* const message) { } void NarrowbandFMAudio::configure(const NBFMConfigureMessage& message) { - constexpr size_t baseband_fs = 3072000; - constexpr size_t decim_0_input_fs = baseband_fs; - constexpr size_t decim_0_decimation_factor = 8; - constexpr size_t decim_0_output_fs = decim_0_input_fs / decim_0_decimation_factor; + constexpr size_t decim_0_output_fs = decim_0_input_fs / decim_0.decimation_factor; constexpr size_t decim_1_input_fs = decim_0_output_fs; - constexpr size_t decim_1_decimation_factor = 8; - constexpr size_t decim_1_output_fs = decim_1_input_fs / decim_1_decimation_factor; + 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 channel_filter_decimation_factor = 1; constexpr size_t channel_filter_output_fs = channel_filter_input_fs / channel_filter_decimation_factor; constexpr size_t demod_input_fs = channel_filter_output_fs / post_channel_decimation_factor; diff --git a/firmware/baseband/proc_nfm_audio.hpp b/firmware/baseband/proc_nfm_audio.hpp index 190b7f98..0b2c806d 100644 --- a/firmware/baseband/proc_nfm_audio.hpp +++ b/firmware/baseband/proc_nfm_audio.hpp @@ -37,6 +37,10 @@ public: void on_message(const Message* const message) override; private: + static constexpr size_t baseband_fs = 3072000; + static constexpr size_t channel_filter_decimation_factor = 1; + static constexpr size_t post_channel_decimation_factor = 3; + std::array dst; const buffer_c16_t dst_buffer { dst.data(), @@ -55,7 +59,6 @@ private: uint32_t channel_filter_pass_f = 0; uint32_t channel_filter_stop_f = 0; - static constexpr size_t post_channel_decimation_factor = 3; BlockDecimator<32> channel_block_buffer { post_channel_decimation_factor }; dsp::demodulate::FM demod; diff --git a/firmware/baseband/proc_wfm_audio.cpp b/firmware/baseband/proc_wfm_audio.cpp index ae11abdb..4246a555 100644 --- a/firmware/baseband/proc_wfm_audio.cpp +++ b/firmware/baseband/proc_wfm_audio.cpp @@ -87,19 +87,14 @@ void WidebandFMAudio::on_message(const Message* const message) { } void WidebandFMAudio::configure(const WFMConfigureMessage& message) { - constexpr size_t baseband_fs = 3072000; - constexpr size_t decim_0_input_fs = baseband_fs; - constexpr size_t decim_0_decimation_factor = 4; - constexpr size_t decim_0_output_fs = decim_0_input_fs / decim_0_decimation_factor; + constexpr size_t decim_0_output_fs = decim_0_input_fs / decim_0.decimation_factor; constexpr size_t decim_1_input_fs = decim_0_output_fs; - constexpr size_t decim_1_decimation_factor = 2; - constexpr size_t decim_1_output_fs = decim_1_input_fs / decim_1_decimation_factor; + constexpr size_t decim_1_output_fs = decim_1_input_fs / decim_1.decimation_factor; constexpr size_t demod_input_fs = decim_1_output_fs; - constexpr auto spectrum_rate_hz = 50.0f; spectrum_interval_samples = decim_1_output_fs / spectrum_rate_hz; spectrum_samples = 0; diff --git a/firmware/baseband/proc_wfm_audio.hpp b/firmware/baseband/proc_wfm_audio.hpp index 5c30c2e9..15f5bf36 100644 --- a/firmware/baseband/proc_wfm_audio.hpp +++ b/firmware/baseband/proc_wfm_audio.hpp @@ -37,6 +37,9 @@ public: void on_message(const Message* const message) override; private: + static constexpr size_t baseband_fs = 3072000; + static constexpr auto spectrum_rate_hz = 50.0f; + std::array dst; const buffer_c16_t dst_buffer { dst.data(),