mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-02-22 15:49:57 -05:00
Wideband FM configuration messages from M0.
This commit is contained in:
parent
317ec53638
commit
f2f7032615
@ -35,13 +35,37 @@ AnalogAudioModel::AnalogAudioModel(ReceiverModel::Mode mode) {
|
||||
});
|
||||
receiver_model.set_baseband_bandwidth(1750000);
|
||||
|
||||
if( mode == ReceiverModel::Mode::NarrowbandFMAudio ) {
|
||||
const NBFMConfigureMessage message {
|
||||
taps_4k25_decim_0,
|
||||
taps_4k25_decim_1,
|
||||
taps_4k25_channel,
|
||||
2500,
|
||||
};
|
||||
shared_memory.baseband_queue.push(message);
|
||||
switch(mode) {
|
||||
case ReceiverModel::Mode::NarrowbandFMAudio:
|
||||
configure_nbfm();
|
||||
break;
|
||||
|
||||
case ReceiverModel::Mode::WidebandFMAudio:
|
||||
configure_wfm();
|
||||
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);
|
||||
}
|
||||
|
@ -28,6 +28,10 @@
|
||||
class AnalogAudioModel {
|
||||
public:
|
||||
AnalogAudioModel(ReceiverModel::Mode mode);
|
||||
|
||||
private:
|
||||
void configure_nbfm();
|
||||
void configure_wfm();
|
||||
};
|
||||
|
||||
namespace ui {
|
||||
|
@ -23,26 +23,11 @@
|
||||
|
||||
#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) {
|
||||
if( !configured ) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::array<complex16_t, 512> dst;
|
||||
const buffer_c16_t dst_buffer {
|
||||
dst.data(),
|
||||
@ -94,3 +79,35 @@ void WidebandFMAudio::execute(const buffer_c8_t& buffer) {
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -33,10 +33,10 @@
|
||||
|
||||
class WidebandFMAudio : public BasebandProcessor {
|
||||
public:
|
||||
WidebandFMAudio();
|
||||
|
||||
void execute(const buffer_c8_t& buffer) override;
|
||||
|
||||
void on_message(const Message* const message) override;
|
||||
|
||||
private:
|
||||
dsp::decimate::FIRC8xR16x24FS4Decim4 decim_0;
|
||||
dsp::decimate::FIRC16xR16x16Decim2 decim_1;
|
||||
@ -48,6 +48,9 @@ private:
|
||||
|
||||
IIRBiquadFilter audio_hpf { audio_hpf_30hz_config };
|
||||
IIRBiquadFilter audio_deemph { audio_deemph_2122_6_config };
|
||||
|
||||
bool configured { false };
|
||||
void configure(const WFMConfigureMessage& message);
|
||||
};
|
||||
|
||||
#endif/*__PROC_WFM_AUDIO_H__*/
|
||||
|
@ -53,6 +53,7 @@ public:
|
||||
ERTPacket = 9,
|
||||
UpdateSpectrum = 10,
|
||||
NBFMConfigure = 11,
|
||||
WFMConfigure = 12,
|
||||
MAX
|
||||
};
|
||||
|
||||
@ -292,6 +293,27 @@ public:
|
||||
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 {
|
||||
public:
|
||||
using MessageHandler = std::function<void(Message* const p)>;
|
||||
|
Loading…
x
Reference in New Issue
Block a user