mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-07-30 10:09:25 -04:00
Added PWM RSSI output for NBFM and WFM
This commit is contained in:
parent
1beac3bdbd
commit
1d697d2201
22 changed files with 274 additions and 118 deletions
|
@ -31,7 +31,7 @@ void WidebandFMAudio::execute(const buffer_c8_t& buffer) {
|
|||
if( !configured ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
const auto decim_0_out = decim_0.execute(buffer, dst_buffer);
|
||||
const auto channel = decim_1.execute(decim_0_out, dst_buffer);
|
||||
|
||||
|
@ -44,32 +44,49 @@ void WidebandFMAudio::execute(const buffer_c8_t& buffer) {
|
|||
channel_spectrum.feed(channel, channel_filter_pass_f, channel_filter_stop_f);
|
||||
}
|
||||
|
||||
/* 384kHz complex<int16_t>[256]
|
||||
* -> FM demodulation
|
||||
* -> 384kHz int16_t[256] */
|
||||
/* TODO: To improve adjacent channel rejection, implement complex channel filter:
|
||||
* pass < +/- 100kHz, stop > +/- 200kHz
|
||||
*/
|
||||
if ( !pwmrssi_enabled ) {
|
||||
/* 384kHz complex<int16_t>[256]
|
||||
* -> FM demodulation
|
||||
* -> 384kHz int16_t[256] */
|
||||
/* TODO: To improve adjacent channel rejection, implement complex channel filter:
|
||||
* pass < +/- 100kHz, stop > +/- 200kHz
|
||||
*/
|
||||
|
||||
auto audio_oversampled = demod.execute(channel, work_audio_buffer);
|
||||
auto audio_oversampled = demod.execute(channel, work_audio_buffer);
|
||||
|
||||
/* 384kHz int16_t[256]
|
||||
* -> 4th order CIC decimation by 2, gain of 1
|
||||
* -> 192kHz int16_t[128] */
|
||||
auto audio_4fs = audio_dec_1.execute(audio_oversampled, work_audio_buffer);
|
||||
/* 384kHz int16_t[256]
|
||||
* -> 4th order CIC decimation by 2, gain of 1
|
||||
* -> 192kHz int16_t[128] */
|
||||
auto audio_4fs = audio_dec_1.execute(audio_oversampled, work_audio_buffer);
|
||||
|
||||
/* 192kHz int16_t[128]
|
||||
* -> 4th order CIC decimation by 2, gain of 1
|
||||
* -> 96kHz int16_t[64] */
|
||||
auto audio_2fs = audio_dec_2.execute(audio_4fs, work_audio_buffer);
|
||||
/* 192kHz int16_t[128]
|
||||
* -> 4th order CIC decimation by 2, gain of 1
|
||||
* -> 96kHz int16_t[64] */
|
||||
auto audio_2fs = audio_dec_2.execute(audio_4fs, work_audio_buffer);
|
||||
|
||||
/* 96kHz int16_t[64]
|
||||
* -> FIR filter, <15kHz (0.156fs) pass, >19kHz (0.198fs) stop, gain of 1
|
||||
* -> 48kHz int16_t[32] */
|
||||
auto audio = audio_filter.execute(audio_2fs, work_audio_buffer);
|
||||
/* 96kHz int16_t[64]
|
||||
* -> FIR filter, <15kHz (0.156fs) pass, >19kHz (0.198fs) stop, gain of 1
|
||||
* -> 48kHz int16_t[32] */
|
||||
auto audio = audio_filter.execute(audio_2fs, work_audio_buffer);
|
||||
|
||||
/* -> 48kHz int16_t[32] */
|
||||
audio_output.write(audio);
|
||||
} else {
|
||||
for (c = 0; c < 32; c++) {
|
||||
if (synth_acc < pwmrssi_avg)
|
||||
pwmrssi_audio_buffer.p[c] = 32767;
|
||||
else
|
||||
pwmrssi_audio_buffer.p[c] = -32768;
|
||||
if (synth_acc < 96) // 48kHz / 96 = 500Hz (TODO: use pwmrssi_freq !)
|
||||
synth_acc++;
|
||||
else
|
||||
synth_acc = 0;
|
||||
}
|
||||
|
||||
/* -> 48kHz int16_t[32] */
|
||||
audio_output.write(audio);
|
||||
/* -> 48kHz int16_t[32] */
|
||||
audio_output.write(pwmrssi_audio_buffer);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void WidebandFMAudio::on_message(const Message* const message) {
|
||||
|
@ -86,6 +103,10 @@ void WidebandFMAudio::on_message(const Message* const message) {
|
|||
case Message::ID::CaptureConfig:
|
||||
capture_config(*reinterpret_cast<const CaptureConfigMessage*>(message));
|
||||
break;
|
||||
|
||||
case Message::ID::PWMRSSIConfigure:
|
||||
pwmrssi_config(*reinterpret_cast<const PWMRSSIConfigureMessage*>(message));
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
|
@ -114,9 +135,18 @@ void WidebandFMAudio::configure(const WFMConfigureMessage& message) {
|
|||
|
||||
channel_spectrum.set_decimation_factor(1);
|
||||
|
||||
pwmrssi_enabled = false;
|
||||
synth_acc = 0;
|
||||
|
||||
configured = true;
|
||||
}
|
||||
|
||||
void WidebandFMAudio::pwmrssi_config(const PWMRSSIConfigureMessage& message) {
|
||||
pwmrssi_enabled = message.enabled;
|
||||
pwmrssi_freq = message.freq;
|
||||
pwmrssi_avg = message.avg;
|
||||
}
|
||||
|
||||
void WidebandFMAudio::capture_config(const CaptureConfigMessage& message) {
|
||||
if( message.config ) {
|
||||
audio_output.set_stream(std::make_unique<StreamInput>(message.config));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue