Change audio sampling rates on NBFM, AM modes.

This commit is contained in:
Jared Boone 2016-01-29 15:33:01 -08:00
parent 0e436ded14
commit db642cac8d
5 changed files with 32 additions and 15 deletions

View File

@ -62,6 +62,7 @@ void AnalogAudioModel::configure_nbfm() {
2500, 2500,
}; };
shared_memory.baseband_queue.push(message); shared_memory.baseband_queue.push(message);
clock_manager.set_base_audio_clock_divider(3);
} }
void AnalogAudioModel::configure_wfm() { void AnalogAudioModel::configure_wfm() {
@ -72,6 +73,7 @@ void AnalogAudioModel::configure_wfm() {
75000, 75000,
}; };
shared_memory.baseband_queue.push(message); shared_memory.baseband_queue.push(message);
clock_manager.set_base_audio_clock_divider(1);
} }
void AnalogAudioModel::configure_am() { void AnalogAudioModel::configure_am() {
@ -81,4 +83,5 @@ void AnalogAudioModel::configure_am() {
taps_6k0_channel, taps_6k0_channel,
}; };
shared_memory.baseband_queue.push(message); shared_memory.baseband_queue.push(message);
clock_manager.set_base_audio_clock_divider(6);
} }

View File

@ -39,9 +39,12 @@ void NarrowbandAMAudio::execute(const buffer_c8_t& buffer) {
feed_channel_stats(channel_out); feed_channel_stats(channel_out);
channel_spectrum.feed(channel_out, channel_filter_pass_f, channel_filter_stop_f); channel_spectrum.feed(channel_out, channel_filter_pass_f, channel_filter_stop_f);
auto audio = demod.execute(channel_out, work_audio_buffer); channel_block_buffer.feed(
channel_out, [this](const buffer_c16_t buffer) {
audio_output.write(audio); auto audio = this->demod.execute(buffer, this->audio_buffer);
this->audio_output.write(audio);
}
);
} }
void NarrowbandAMAudio::on_message(const Message* const message) { void NarrowbandAMAudio::on_message(const Message* const message) {
@ -81,7 +84,7 @@ void NarrowbandAMAudio::configure(const AMConfigureMessage& message) {
channel_filter_pass_f = message.channel_filter.pass_frequency_normalized * channel_filter_input_fs; 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_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))); channel_spectrum.set_decimation_factor(std::floor((channel_filter_output_fs / 2) / ((channel_filter_pass_f + channel_filter_stop_f) / 2)));
audio_output.configure(audio_hpf_300hz_config); audio_output.configure(audio_8k_hpf_300hz_config);
configured = true; configured = true;
} }

View File

@ -44,9 +44,10 @@ private:
dst.data(), dst.data(),
dst.size() dst.size()
}; };
const buffer_f32_t work_audio_buffer { std::array<float, 32> audio;
(float*)dst.data(), const buffer_f32_t audio_buffer {
sizeof(dst) / sizeof(float) audio.data(),
audio.size()
}; };
dsp::decimate::FIRC8xR16x24FS4Decim8 decim_0; dsp::decimate::FIRC8xR16x24FS4Decim8 decim_0;
@ -55,6 +56,9 @@ private:
uint32_t channel_filter_pass_f; uint32_t channel_filter_pass_f;
uint32_t channel_filter_stop_f; uint32_t channel_filter_stop_f;
static constexpr size_t post_channel_decimation_factor = 6;
BlockDecimator<32> channel_block_buffer { post_channel_decimation_factor };
dsp::demodulate::AM demod; dsp::demodulate::AM demod;
AudioOutput audio_output; AudioOutput audio_output;

View File

@ -39,9 +39,12 @@ void NarrowbandFMAudio::execute(const buffer_c8_t& buffer) {
feed_channel_stats(channel_out); feed_channel_stats(channel_out);
channel_spectrum.feed(channel_out, channel_filter_pass_f, channel_filter_stop_f); channel_spectrum.feed(channel_out, channel_filter_pass_f, channel_filter_stop_f);
auto audio = demod.execute(channel_out, work_audio_buffer); channel_block_buffer.feed(
channel_out, [this](const buffer_c16_t buffer) {
audio_output.write(audio); auto audio = this->demod.execute(buffer, this->audio_buffer);
this->audio_output.write(audio);
}
);
} }
void NarrowbandFMAudio::on_message(const Message* const message) { void NarrowbandFMAudio::on_message(const Message* const message) {
@ -75,7 +78,7 @@ void NarrowbandFMAudio::configure(const NBFMConfigureMessage& message) {
constexpr size_t channel_filter_decimation_factor = 1; constexpr size_t channel_filter_decimation_factor = 1;
constexpr size_t channel_filter_output_fs = channel_filter_input_fs / channel_filter_decimation_factor; constexpr size_t channel_filter_output_fs = channel_filter_input_fs / channel_filter_decimation_factor;
constexpr size_t demod_input_fs = channel_filter_output_fs; constexpr size_t demod_input_fs = channel_filter_output_fs / post_channel_decimation_factor;
decim_0.configure(message.decim_0_filter.taps, 33554432); decim_0.configure(message.decim_0_filter.taps, 33554432);
decim_1.configure(message.decim_1_filter.taps, 131072); decim_1.configure(message.decim_1_filter.taps, 131072);
@ -84,7 +87,7 @@ void NarrowbandFMAudio::configure(const NBFMConfigureMessage& message) {
channel_filter_pass_f = message.channel_filter.pass_frequency_normalized * channel_filter_input_fs; 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_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))); channel_spectrum.set_decimation_factor(std::floor((channel_filter_output_fs / 2) / ((channel_filter_pass_f + channel_filter_stop_f) / 2)));
audio_output.configure(audio_hpf_300hz_config, audio_deemph_300_6_config, 6144); audio_output.configure(audio_16k_hpf_300hz_config, audio_16k_deemph_300_6_config, 0);
configured = true; configured = true;
} }

View File

@ -42,9 +42,10 @@ private:
dst.data(), dst.data(),
dst.size() dst.size()
}; };
const buffer_f32_t work_audio_buffer { std::array<float, 32> audio;
(float*)dst.data(), const buffer_f32_t audio_buffer {
sizeof(dst) / sizeof(float) audio.data(),
audio.size()
}; };
dsp::decimate::FIRC8xR16x24FS4Decim8 decim_0; dsp::decimate::FIRC8xR16x24FS4Decim8 decim_0;
@ -54,6 +55,9 @@ private:
uint32_t channel_filter_pass_f = 0; uint32_t channel_filter_pass_f = 0;
uint32_t channel_filter_stop_f = 0; uint32_t channel_filter_stop_f = 0;
static constexpr size_t post_channel_decimation_factor = 3;
BlockDecimator<32> channel_block_buffer { post_channel_decimation_factor };
dsp::demodulate::FM demod; dsp::demodulate::FM demod;
AudioOutput audio_output; AudioOutput audio_output;