diff --git a/firmware/application/analog_audio_app.cpp b/firmware/application/analog_audio_app.cpp index 082dbae4..e333b7c2 100644 --- a/firmware/application/analog_audio_app.cpp +++ b/firmware/application/analog_audio_app.cpp @@ -104,6 +104,7 @@ void AnalogAudioModel::configure_am() { taps_6k0_decim_1, taps_6k0_decim_2, taps_2k8_usb_channel, + AMConfigureMessage::Modulation::SSB, audio_12k_hpf_300hz_config }; shared_memory.baseband_queue.push(message); diff --git a/firmware/baseband/proc_am_audio.cpp b/firmware/baseband/proc_am_audio.cpp index dc94b7b1..3a073db4 100644 --- a/firmware/baseband/proc_am_audio.cpp +++ b/firmware/baseband/proc_am_audio.cpp @@ -39,12 +39,15 @@ void NarrowbandAMAudio::execute(const buffer_c8_t& buffer) { feed_channel_stats(channel_out); channel_spectrum.feed(channel_out, channel_filter_pass_f, channel_filter_stop_f); - if( false ) { - auto audio = demod_am.execute(channel_out, audio_buffer); - audio_output.write(audio); + auto audio = demodulate(channel_out); + audio_output.write(audio); +} + +buffer_f32_t NarrowbandAMAudio::demodulate(const buffer_c16_t& channel) { + if( modulation_ssb ) { + return demod_ssb.execute(channel, audio_buffer); } else { - auto audio = demod_ssb.execute(channel_out, audio_buffer); - audio_output.write(audio); + return demod_am.execute(channel, audio_buffer); } } @@ -84,6 +87,7 @@ void NarrowbandAMAudio::configure(const AMConfigureMessage& 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))); + modulation_ssb = (message.modulation == AMConfigureMessage::Modulation::SSB); audio_output.configure(message.audio_hpf_config); configured = true; diff --git a/firmware/baseband/proc_am_audio.hpp b/firmware/baseband/proc_am_audio.hpp index a695df3d..226720e2 100644 --- a/firmware/baseband/proc_am_audio.hpp +++ b/firmware/baseband/proc_am_audio.hpp @@ -61,6 +61,7 @@ private: uint32_t channel_filter_pass_f = 0; uint32_t channel_filter_stop_f = 0; + bool modulation_ssb = false; dsp::demodulate::AM demod_am; dsp::demodulate::SSB demod_ssb; @@ -70,6 +71,8 @@ private: bool configured { false }; void configure(const AMConfigureMessage& message); + + buffer_f32_t demodulate(const buffer_c16_t& channel); }; #endif/*__PROC_AM_AUDIO_H__*/ diff --git a/firmware/common/message.hpp b/firmware/common/message.hpp index 79e51267..cf8454e5 100644 --- a/firmware/common/message.hpp +++ b/firmware/common/message.hpp @@ -373,17 +373,24 @@ public: class AMConfigureMessage : public Message { public: + enum class Modulation : int32_t { + AM = 0, + SSB = 1, + }; + 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_complex<64> channel_filter, + const Modulation modulation, 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), + modulation { modulation }, audio_hpf_config { audio_hpf_config } { } @@ -392,6 +399,7 @@ public: const fir_taps_real<32> decim_1_filter; const fir_taps_real<32> decim_2_filter; const fir_taps_complex<64> channel_filter; + const Modulation modulation; const iir_biquad_config_t audio_hpf_config; };