Implement AMConfigureMessage from M0 to M4.

This commit is contained in:
Jared Boone 2016-01-03 14:31:39 -08:00
parent f2f7032615
commit b5aa2b205f
5 changed files with 75 additions and 27 deletions

View File

@ -44,6 +44,10 @@ AnalogAudioModel::AnalogAudioModel(ReceiverModel::Mode mode) {
configure_wfm();
break;
case ReceiverModel::Mode::AMAudio:
configure_am();
break;
default:
break;
}
@ -69,3 +73,12 @@ void AnalogAudioModel::configure_wfm() {
};
shared_memory.baseband_queue.push(message);
}
void AnalogAudioModel::configure_am() {
const AMConfigureMessage message {
taps_6k0_decim_0,
taps_6k0_decim_1,
taps_6k0_channel,
};
shared_memory.baseband_queue.push(message);
}

View File

@ -32,6 +32,7 @@ public:
private:
void configure_nbfm();
void configure_wfm();
void configure_am();
};
namespace ui {

View File

@ -21,31 +21,11 @@
#include "proc_am_audio.hpp"
NarrowbandAMAudio::NarrowbandAMAudio() {
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_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 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(taps_6k0_decim_0.taps, 33554432);
decim_1.configure(taps_6k0_decim_1.taps, 131072);
channel_filter.configure(taps_6k0_channel.taps, channel_filter_decimation_factor);
channel_filter_pass_f = taps_6k0_channel.pass_frequency_normalized * channel_filter_input_fs;
channel_filter_stop_f = taps_6k0_channel.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)));
}
void NarrowbandAMAudio::execute(const buffer_c8_t& buffer) {
if( !configured ) {
return;
}
std::array<complex16_t, 512> dst;
const buffer_c16_t dst_buffer {
dst.data(),
@ -73,7 +53,41 @@ void NarrowbandAMAudio::execute(const buffer_c8_t& buffer) {
}
void NarrowbandAMAudio::on_message(const Message* const message) {
if( message->id == Message::ID::UpdateSpectrum ) {
switch(message->id) {
case Message::ID::UpdateSpectrum:
channel_spectrum.update();
break;
case Message::ID::AMConfigure:
configure(*reinterpret_cast<const AMConfigureMessage*>(message));
break;
default:
break;
}
}
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_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 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);
decim_1.configure(message.decim_1_filter.taps, 131072);
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;
channel_spectrum.set_decimation_factor(std::floor((channel_filter_output_fs / 2) / ((channel_filter_pass_f + channel_filter_stop_f) / 2)));
configured = true;
}

View File

@ -38,8 +38,6 @@
class NarrowbandAMAudio : public BasebandProcessor {
public:
NarrowbandAMAudio();
void execute(const buffer_c8_t& buffer) override;
void on_message(const Message* const message) override;
@ -56,6 +54,9 @@ private:
IIRBiquadFilter audio_hpf { audio_hpf_300hz_config };
SpectrumCollector channel_spectrum;
bool configured { false };
void configure(const AMConfigureMessage& message);
};
#endif/*__PROC_AM_AUDIO_H__*/

View File

@ -54,6 +54,7 @@ public:
UpdateSpectrum = 10,
NBFMConfigure = 11,
WFMConfigure = 12,
AMConfigure = 13,
MAX
};
@ -314,6 +315,24 @@ public:
const size_t deviation;
};
class AMConfigureMessage : public Message {
public:
constexpr AMConfigureMessage(
const fir_taps_real<24>& decim_0_filter,
const fir_taps_real<32>& decim_1_filter,
const fir_taps_real<32>& channel_filter
) : Message { ID::AMConfigure },
decim_0_filter { decim_0_filter },
decim_1_filter { decim_1_filter },
channel_filter { channel_filter }
{
}
const fir_taps_real<24> decim_0_filter;
const fir_taps_real<32> decim_1_filter;
const fir_taps_real<32> channel_filter;
};
class MessageHandlerMap {
public:
using MessageHandler = std::function<void(Message* const p)>;