mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-10-01 01:26:06 -04:00
Reorganize analog audio configs structures.
This commit is contained in:
parent
ee67948a63
commit
cbaa04ff07
@ -25,32 +25,30 @@
|
||||
#include "portapack_shared_memory.hpp"
|
||||
using namespace portapack;
|
||||
|
||||
#include "dsp_fir_taps.hpp"
|
||||
#include "dsp_iir_config.hpp"
|
||||
|
||||
#include "utility.hpp"
|
||||
|
||||
struct NBFMMode {
|
||||
const fir_taps_real<24> decim_0;
|
||||
const fir_taps_real<32> decim_1;
|
||||
const fir_taps_real<32> channel;
|
||||
const size_t deviation;
|
||||
};
|
||||
#include "dsp_iir_config.hpp"
|
||||
|
||||
static constexpr std::array<NBFMMode, 3> nbfm_mode_configs { {
|
||||
{ taps_4k25_decim_0, taps_4k25_decim_1, taps_4k25_channel, 2500 },
|
||||
{ taps_11k0_decim_0, taps_11k0_decim_1, taps_11k0_channel, 2500 },
|
||||
{ taps_16k0_decim_0, taps_16k0_decim_1, taps_16k0_channel, 5000 },
|
||||
} };
|
||||
void AMConfig::apply() const {
|
||||
const AMConfigureMessage message {
|
||||
taps_6k0_decim_0,
|
||||
taps_6k0_decim_1,
|
||||
taps_6k0_decim_2,
|
||||
channel,
|
||||
modulation,
|
||||
audio_12k_hpf_300hz_config
|
||||
};
|
||||
shared_memory.baseband_queue.push(message);
|
||||
clock_manager.set_base_audio_clock_divider(4);
|
||||
}
|
||||
|
||||
void AnalogAudioModel::configure_nbfm(const size_t index) {
|
||||
const auto config = nbfm_mode_configs[index];
|
||||
void NBFMConfig::apply() const {
|
||||
const NBFMConfigureMessage message {
|
||||
config.decim_0,
|
||||
config.decim_1,
|
||||
config.channel,
|
||||
decim_0,
|
||||
decim_1,
|
||||
channel,
|
||||
2,
|
||||
config.deviation,
|
||||
deviation,
|
||||
audio_24k_hpf_300hz_config,
|
||||
audio_24k_deemph_300_6_config
|
||||
};
|
||||
@ -58,7 +56,7 @@ void AnalogAudioModel::configure_nbfm(const size_t index) {
|
||||
clock_manager.set_base_audio_clock_divider(2);
|
||||
}
|
||||
|
||||
void AnalogAudioModel::configure_wfm() {
|
||||
void WFMConfig::apply() const {
|
||||
const WFMConfigureMessage message {
|
||||
taps_200k_wfm_decim_0,
|
||||
taps_200k_wfm_decim_1,
|
||||
@ -71,30 +69,21 @@ void AnalogAudioModel::configure_wfm() {
|
||||
clock_manager.set_base_audio_clock_divider(1);
|
||||
}
|
||||
|
||||
struct AMMode {
|
||||
const fir_taps_complex<64> channel;
|
||||
const AMConfigureMessage::Modulation modulation;
|
||||
};
|
||||
|
||||
static constexpr std::array<AMMode, 3> am_mode_configs { {
|
||||
static constexpr std::array<AMConfig, 3> am_configs { {
|
||||
{ taps_6k0_dsb_channel, AMConfigureMessage::Modulation::DSB },
|
||||
{ taps_2k8_usb_channel, AMConfigureMessage::Modulation::SSB },
|
||||
{ taps_2k8_lsb_channel, AMConfigureMessage::Modulation::SSB },
|
||||
} };
|
||||
|
||||
void AnalogAudioModel::configure_am(const size_t index) {
|
||||
const auto config = am_mode_configs[index];
|
||||
const AMConfigureMessage message {
|
||||
taps_6k0_decim_0,
|
||||
taps_6k0_decim_1,
|
||||
taps_6k0_decim_2,
|
||||
config.channel,
|
||||
config.modulation,
|
||||
audio_12k_hpf_300hz_config
|
||||
};
|
||||
shared_memory.baseband_queue.push(message);
|
||||
clock_manager.set_base_audio_clock_divider(4);
|
||||
}
|
||||
static constexpr std::array<NBFMConfig, 3> nbfm_configs { {
|
||||
{ taps_4k25_decim_0, taps_4k25_decim_1, taps_4k25_channel, 2500 },
|
||||
{ taps_11k0_decim_0, taps_11k0_decim_1, taps_11k0_channel, 2500 },
|
||||
{ taps_16k0_decim_0, taps_16k0_decim_1, taps_16k0_channel, 5000 },
|
||||
} };
|
||||
|
||||
static constexpr std::array<WFMConfig, 1> wfm_configs { {
|
||||
{ },
|
||||
} };
|
||||
|
||||
namespace ui {
|
||||
|
||||
@ -239,15 +228,15 @@ void AnalogAudioView::on_modulation_changed(const ReceiverModel::Mode mode) {
|
||||
switch(mode) {
|
||||
default:
|
||||
case ReceiverModel::Mode::AMAudio:
|
||||
model.configure_am(0);
|
||||
update_am_config();
|
||||
break;
|
||||
|
||||
case ReceiverModel::Mode::NarrowbandFMAudio:
|
||||
model.configure_nbfm(0);
|
||||
update_nbfm_config();
|
||||
break;
|
||||
|
||||
case ReceiverModel::Mode::WidebandFMAudio:
|
||||
model.configure_wfm();
|
||||
update_wfm_config();
|
||||
break;
|
||||
|
||||
case ReceiverModel::Mode::SpectrumAnalysis:
|
||||
@ -287,4 +276,30 @@ void AnalogAudioView::on_headphone_volume_changed(int32_t v) {
|
||||
receiver_model.set_headphone_volume(new_volume);
|
||||
}
|
||||
|
||||
void AnalogAudioView::on_am_config_index_changed(size_t n) {
|
||||
if( n < am_configs.size() ) {
|
||||
am_config_index = n;
|
||||
update_am_config();
|
||||
}
|
||||
}
|
||||
|
||||
void AnalogAudioView::on_nbfm_config_index_changed(size_t n) {
|
||||
if( n < nbfm_configs.size() ) {
|
||||
nbfm_config_index = n;
|
||||
update_nbfm_config();
|
||||
}
|
||||
}
|
||||
|
||||
void AnalogAudioView::update_am_config() {
|
||||
am_configs[am_config_index].apply();
|
||||
}
|
||||
|
||||
void AnalogAudioView::update_nbfm_config() {
|
||||
nbfm_configs[nbfm_config_index].apply();
|
||||
}
|
||||
|
||||
void AnalogAudioView::update_wfm_config() {
|
||||
wfm_configs[wfm_config_index].apply();
|
||||
}
|
||||
|
||||
} /* namespace ui */
|
||||
|
@ -29,11 +29,27 @@
|
||||
|
||||
#include "ui_font_fixed_8x16.hpp"
|
||||
|
||||
class AnalogAudioModel {
|
||||
public:
|
||||
void configure_nbfm(const size_t index);
|
||||
void configure_wfm();
|
||||
void configure_am(const size_t index);
|
||||
#include "dsp_fir_taps.hpp"
|
||||
#include "dsp_iir.hpp"
|
||||
|
||||
struct AMConfig {
|
||||
const fir_taps_complex<64> channel;
|
||||
const AMConfigureMessage::Modulation modulation;
|
||||
|
||||
void apply() const;
|
||||
};
|
||||
|
||||
struct NBFMConfig {
|
||||
const fir_taps_real<24> decim_0;
|
||||
const fir_taps_real<32> decim_1;
|
||||
const fir_taps_real<32> channel;
|
||||
const size_t deviation;
|
||||
|
||||
void apply() const;
|
||||
};
|
||||
|
||||
struct WFMConfig {
|
||||
void apply() const;
|
||||
};
|
||||
|
||||
namespace ui {
|
||||
@ -56,8 +72,6 @@ public:
|
||||
void focus() override;
|
||||
|
||||
private:
|
||||
AnalogAudioModel model;
|
||||
|
||||
static constexpr ui::Dim header_height = 2 * 16;
|
||||
|
||||
RSSI rssi {
|
||||
@ -129,6 +143,10 @@ private:
|
||||
*/
|
||||
spectrum::WaterfallWidget waterfall;
|
||||
|
||||
size_t am_config_index = 0;
|
||||
size_t nbfm_config_index = 0;
|
||||
static constexpr size_t wfm_config_index = 0;
|
||||
|
||||
void on_tuning_frequency_changed(rf::Frequency f);
|
||||
void on_baseband_bandwidth_changed(uint32_t bandwidth_hz);
|
||||
void on_rf_amp_changed(bool v);
|
||||
@ -141,6 +159,13 @@ private:
|
||||
void on_reference_ppm_correction_changed(int32_t v);
|
||||
void on_headphone_volume_changed(int32_t v);
|
||||
void on_edit_frequency();
|
||||
|
||||
void on_am_config_index_changed(size_t n);
|
||||
void on_nbfm_config_index_changed(size_t n);
|
||||
|
||||
void update_am_config();
|
||||
void update_nbfm_config();
|
||||
void update_wfm_config();
|
||||
};
|
||||
|
||||
} /* namespace ui */
|
||||
|
Loading…
Reference in New Issue
Block a user