mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-01-07 22:37:39 +00:00
Extract WidebandFMAudio into separate files.
This commit is contained in:
parent
7c5db55f8f
commit
ffe829cf67
@ -135,6 +135,7 @@ CPPSRC = main.cpp \
|
|||||||
dsp_demodulate.cpp \
|
dsp_demodulate.cpp \
|
||||||
proc_am_audio.cpp \
|
proc_am_audio.cpp \
|
||||||
proc_nfm_audio.cpp \
|
proc_nfm_audio.cpp \
|
||||||
|
proc_wfm_audio.cpp \
|
||||||
dsp_squelch.cpp \
|
dsp_squelch.cpp \
|
||||||
clock_recovery.cpp \
|
clock_recovery.cpp \
|
||||||
access_code_correlator.cpp \
|
access_code_correlator.cpp \
|
||||||
|
@ -54,6 +54,7 @@
|
|||||||
#include "baseband_processor.hpp"
|
#include "baseband_processor.hpp"
|
||||||
#include "proc_am_audio.hpp"
|
#include "proc_am_audio.hpp"
|
||||||
#include "proc_nfm_audio.hpp"
|
#include "proc_nfm_audio.hpp"
|
||||||
|
#include "proc_wfm_audio.hpp"
|
||||||
|
|
||||||
#include "clock_recovery.hpp"
|
#include "clock_recovery.hpp"
|
||||||
#include "access_code_correlator.hpp"
|
#include "access_code_correlator.hpp"
|
||||||
@ -79,70 +80,6 @@
|
|||||||
constexpr auto baseband_thread_priority = NORMALPRIO + 20;
|
constexpr auto baseband_thread_priority = NORMALPRIO + 20;
|
||||||
constexpr auto rssi_thread_priority = NORMALPRIO + 10;
|
constexpr auto rssi_thread_priority = NORMALPRIO + 10;
|
||||||
|
|
||||||
class WidebandFMAudio : public BasebandProcessor {
|
|
||||||
public:
|
|
||||||
void execute(buffer_c8_t buffer) override {
|
|
||||||
auto decimator_out = decimator.execute(buffer);
|
|
||||||
|
|
||||||
const buffer_s16_t work_audio_buffer {
|
|
||||||
(int16_t*)decimator_out.p,
|
|
||||||
sizeof(*decimator_out.p) * decimator_out.count
|
|
||||||
};
|
|
||||||
|
|
||||||
auto channel = decimator_out;
|
|
||||||
|
|
||||||
// TODO: Feed channel_stats post-decimation data?
|
|
||||||
feed_channel_stats(channel);
|
|
||||||
//feed_channel_spectrum(channel);
|
|
||||||
|
|
||||||
/* 768kHz complex<int16_t>[512]
|
|
||||||
* -> FM demodulation
|
|
||||||
* -> 768kHz int16_t[512] */
|
|
||||||
/* TODO: To improve adjacent channel rejection, implement complex channel filter:
|
|
||||||
* pass < +/- 100kHz, stop > +/- 200kHz
|
|
||||||
*/
|
|
||||||
|
|
||||||
auto audio_oversampled = demod.execute(decimator_out, work_audio_buffer);
|
|
||||||
|
|
||||||
/* 768kHz int16_t[512]
|
|
||||||
* -> 4th order CIC decimation by 2, gain of 1
|
|
||||||
* -> 384kHz int16_t[256] */
|
|
||||||
auto audio_8fs = 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_2.execute(audio_8fs, 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_3.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);
|
|
||||||
|
|
||||||
/* -> 48kHz int16_t[32] */
|
|
||||||
audio_hpf.execute_in_place(audio);
|
|
||||||
fill_audio_buffer(audio);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
ChannelDecimator decimator { ChannelDecimator::DecimationFactor::By4 };
|
|
||||||
|
|
||||||
//dsp::decimate::FIRAndDecimateBy2Complex<64> channel_filter { taps_64_lp_031_070_tfilter };
|
|
||||||
dsp::demodulate::FM demod { 768000, 75000 };
|
|
||||||
dsp::decimate::DecimateBy2CIC4Real audio_dec_1;
|
|
||||||
dsp::decimate::DecimateBy2CIC4Real audio_dec_2;
|
|
||||||
dsp::decimate::DecimateBy2CIC4Real audio_dec_3;
|
|
||||||
const fir_taps_real<64>& audio_filter_taps = taps_64_lp_156_198;
|
|
||||||
dsp::decimate::FIR64AndDecimateBy2Real audio_filter { audio_filter_taps.taps };
|
|
||||||
|
|
||||||
IIRBiquadFilter audio_hpf { audio_hpf_config };
|
|
||||||
};
|
|
||||||
|
|
||||||
class FSKProcessor : public BasebandProcessor {
|
class FSKProcessor : public BasebandProcessor {
|
||||||
public:
|
public:
|
||||||
FSKProcessor(
|
FSKProcessor(
|
||||||
|
72
firmware/baseband/proc_wfm_audio.cpp
Normal file
72
firmware/baseband/proc_wfm_audio.cpp
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc.
|
||||||
|
*
|
||||||
|
* This file is part of PortaPack.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; see the file COPYING. If not, write to
|
||||||
|
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||||
|
* Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "proc_wfm_audio.hpp"
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
void WidebandFMAudio::execute(buffer_c8_t buffer) {
|
||||||
|
auto decimator_out = decimator.execute(buffer);
|
||||||
|
|
||||||
|
const buffer_s16_t work_audio_buffer {
|
||||||
|
(int16_t*)decimator_out.p,
|
||||||
|
sizeof(*decimator_out.p) * decimator_out.count
|
||||||
|
};
|
||||||
|
|
||||||
|
auto channel = decimator_out;
|
||||||
|
|
||||||
|
// TODO: Feed channel_stats post-decimation data?
|
||||||
|
feed_channel_stats(channel);
|
||||||
|
//feed_channel_spectrum(channel);
|
||||||
|
|
||||||
|
/* 768kHz complex<int16_t>[512]
|
||||||
|
* -> FM demodulation
|
||||||
|
* -> 768kHz int16_t[512] */
|
||||||
|
/* TODO: To improve adjacent channel rejection, implement complex channel filter:
|
||||||
|
* pass < +/- 100kHz, stop > +/- 200kHz
|
||||||
|
*/
|
||||||
|
|
||||||
|
auto audio_oversampled = demod.execute(decimator_out, work_audio_buffer);
|
||||||
|
|
||||||
|
/* 768kHz int16_t[512]
|
||||||
|
* -> 4th order CIC decimation by 2, gain of 1
|
||||||
|
* -> 384kHz int16_t[256] */
|
||||||
|
auto audio_8fs = 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_2.execute(audio_8fs, 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_3.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);
|
||||||
|
|
||||||
|
/* -> 48kHz int16_t[32] */
|
||||||
|
audio_hpf.execute_in_place(audio);
|
||||||
|
fill_audio_buffer(audio);
|
||||||
|
}
|
52
firmware/baseband/proc_wfm_audio.hpp
Normal file
52
firmware/baseband/proc_wfm_audio.hpp
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc.
|
||||||
|
*
|
||||||
|
* This file is part of PortaPack.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; see the file COPYING. If not, write to
|
||||||
|
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||||
|
* Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __PROC_WFM_AUDIO_H__
|
||||||
|
#define __PROC_WFM_AUDIO_H__
|
||||||
|
|
||||||
|
#include "baseband_processor.hpp"
|
||||||
|
|
||||||
|
#include "channel_decimator.hpp"
|
||||||
|
#include "dsp_decimate.hpp"
|
||||||
|
#include "dsp_demodulate.hpp"
|
||||||
|
#include "dsp_fir_taps.hpp"
|
||||||
|
#include "dsp_iir.hpp"
|
||||||
|
#include "dsp_iir_config.hpp"
|
||||||
|
|
||||||
|
class WidebandFMAudio : public BasebandProcessor {
|
||||||
|
public:
|
||||||
|
void execute(buffer_c8_t buffer) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
ChannelDecimator decimator { ChannelDecimator::DecimationFactor::By4 };
|
||||||
|
|
||||||
|
//dsp::decimate::FIRAndDecimateBy2Complex<64> channel_filter { taps_64_lp_031_070_tfilter };
|
||||||
|
dsp::demodulate::FM demod { 768000, 75000 };
|
||||||
|
dsp::decimate::DecimateBy2CIC4Real audio_dec_1;
|
||||||
|
dsp::decimate::DecimateBy2CIC4Real audio_dec_2;
|
||||||
|
dsp::decimate::DecimateBy2CIC4Real audio_dec_3;
|
||||||
|
const fir_taps_real<64>& audio_filter_taps = taps_64_lp_156_198;
|
||||||
|
dsp::decimate::FIR64AndDecimateBy2Real audio_filter { audio_filter_taps.taps };
|
||||||
|
|
||||||
|
IIRBiquadFilter audio_hpf { audio_hpf_config };
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif/*__PROC_WFM_AUDIO_H__*/
|
Loading…
x
Reference in New Issue
Block a user