Wideband FM configuration messages from M0.

This commit is contained in:
Jared Boone 2016-01-03 13:38:55 -08:00
parent 317ec53638
commit f2f7032615
5 changed files with 99 additions and 29 deletions

View File

@ -35,13 +35,37 @@ AnalogAudioModel::AnalogAudioModel(ReceiverModel::Mode mode) {
}); });
receiver_model.set_baseband_bandwidth(1750000); receiver_model.set_baseband_bandwidth(1750000);
if( mode == ReceiverModel::Mode::NarrowbandFMAudio ) { switch(mode) {
const NBFMConfigureMessage message { case ReceiverModel::Mode::NarrowbandFMAudio:
taps_4k25_decim_0, configure_nbfm();
taps_4k25_decim_1, break;
taps_4k25_channel,
2500, case ReceiverModel::Mode::WidebandFMAudio:
}; configure_wfm();
shared_memory.baseband_queue.push(message); break;
default:
break;
} }
}
void AnalogAudioModel::configure_nbfm() {
const NBFMConfigureMessage message {
taps_4k25_decim_0,
taps_4k25_decim_1,
taps_4k25_channel,
2500,
};
shared_memory.baseband_queue.push(message);
}
void AnalogAudioModel::configure_wfm() {
const WFMConfigureMessage message {
taps_200k_wfm_decim_0,
taps_200k_wfm_decim_1,
taps_64_lp_156_198,
75000,
};
shared_memory.baseband_queue.push(message);
} }

View File

@ -28,6 +28,10 @@
class AnalogAudioModel { class AnalogAudioModel {
public: public:
AnalogAudioModel(ReceiverModel::Mode mode); AnalogAudioModel(ReceiverModel::Mode mode);
private:
void configure_nbfm();
void configure_wfm();
}; };
namespace ui { namespace ui {

View File

@ -23,26 +23,11 @@
#include <cstdint> #include <cstdint>
WidebandFMAudio::WidebandFMAudio() {
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_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 demod_input_fs = decim_1_output_fs;
decim_0.configure(taps_200k_wfm_decim_0.taps, 33554432);
decim_1.configure(taps_200k_wfm_decim_1.taps, 131072);
demod.configure(demod_input_fs, 75000);
audio_filter.configure(taps_64_lp_156_198.taps);
}
void WidebandFMAudio::execute(const buffer_c8_t& buffer) { void WidebandFMAudio::execute(const buffer_c8_t& buffer) {
if( !configured ) {
return;
}
std::array<complex16_t, 512> dst; std::array<complex16_t, 512> dst;
const buffer_c16_t dst_buffer { const buffer_c16_t dst_buffer {
dst.data(), dst.data(),
@ -94,3 +79,35 @@ void WidebandFMAudio::execute(const buffer_c8_t& buffer) {
fill_audio_buffer(audio); fill_audio_buffer(audio);
} }
void WidebandFMAudio::on_message(const Message* const message) {
switch(message->id) {
case Message::ID::WFMConfigure:
configure(*reinterpret_cast<const WFMConfigureMessage*>(message));
break;
default:
break;
}
}
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_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 demod_input_fs = decim_1_output_fs;
decim_0.configure(message.decim_0_filter.taps, 33554432);
decim_1.configure(message.decim_1_filter.taps, 131072);
demod.configure(demod_input_fs, message.deviation);
audio_filter.configure(message.audio_filter.taps);
configured = true;
}

View File

@ -33,10 +33,10 @@
class WidebandFMAudio : public BasebandProcessor { class WidebandFMAudio : public BasebandProcessor {
public: public:
WidebandFMAudio();
void execute(const buffer_c8_t& buffer) override; void execute(const buffer_c8_t& buffer) override;
void on_message(const Message* const message) override;
private: private:
dsp::decimate::FIRC8xR16x24FS4Decim4 decim_0; dsp::decimate::FIRC8xR16x24FS4Decim4 decim_0;
dsp::decimate::FIRC16xR16x16Decim2 decim_1; dsp::decimate::FIRC16xR16x16Decim2 decim_1;
@ -48,6 +48,9 @@ private:
IIRBiquadFilter audio_hpf { audio_hpf_30hz_config }; IIRBiquadFilter audio_hpf { audio_hpf_30hz_config };
IIRBiquadFilter audio_deemph { audio_deemph_2122_6_config }; IIRBiquadFilter audio_deemph { audio_deemph_2122_6_config };
bool configured { false };
void configure(const WFMConfigureMessage& message);
}; };
#endif/*__PROC_WFM_AUDIO_H__*/ #endif/*__PROC_WFM_AUDIO_H__*/

View File

@ -53,6 +53,7 @@ public:
ERTPacket = 9, ERTPacket = 9,
UpdateSpectrum = 10, UpdateSpectrum = 10,
NBFMConfigure = 11, NBFMConfigure = 11,
WFMConfigure = 12,
MAX MAX
}; };
@ -292,6 +293,27 @@ public:
const size_t deviation; const size_t deviation;
}; };
class WFMConfigureMessage : public Message {
public:
constexpr WFMConfigureMessage(
const fir_taps_real<24>& decim_0_filter,
const fir_taps_real<16>& decim_1_filter,
const fir_taps_real<64>& audio_filter,
const size_t deviation
) : Message { ID::WFMConfigure },
decim_0_filter { decim_0_filter },
decim_1_filter { decim_1_filter },
audio_filter { audio_filter },
deviation { deviation }
{
}
const fir_taps_real<24> decim_0_filter;
const fir_taps_real<16> decim_1_filter;
const fir_taps_real<64> audio_filter;
const size_t deviation;
};
class MessageHandlerMap { class MessageHandlerMap {
public: public:
using MessageHandler = std::function<void(Message* const p)>; using MessageHandler = std::function<void(Message* const p)>;