From 876cb87d57e425b58e90fd0282f789b65f882c9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niccol=C3=B2=20Izzo?= Date: Mon, 8 Nov 2021 10:28:11 +0100 Subject: [PATCH] Move rrc filter into separate compilation unit By moving the rrc filter into a separate compilation unit with its own header file, we can use it both in the modulator and in the demodulator. --- meson.build | 1 + openrtx/include/protocols/M17/M17DSP.h | 48 +++++++++++++++++ openrtx/src/protocols/M17/M17DSP.cpp | 61 ++++++++++++++++++++++ openrtx/src/protocols/M17/M17Modulator.cpp | 41 +-------------- 4 files changed, 111 insertions(+), 40 deletions(-) create mode 100644 openrtx/include/protocols/M17/M17DSP.h create mode 100644 openrtx/src/protocols/M17/M17DSP.cpp diff --git a/meson.build b/meson.build index 38eadf96..94e8a7d5 100644 --- a/meson.build +++ b/meson.build @@ -39,6 +39,7 @@ openrtx_src = ['openrtx/src/core/state.c', 'openrtx/src/rtx/rtx.cpp', 'openrtx/src/rtx/OpMode_FM.cpp', 'openrtx/src/rtx/OpMode_M17.cpp', + 'openrtx/src/protocols/M17/M17DSP.cpp', 'openrtx/src/protocols/M17/M17Callsign.cpp', 'openrtx/src/protocols/M17/M17Modulator.cpp', 'openrtx/src/protocols/M17/M17Transmitter.cpp', diff --git a/openrtx/include/protocols/M17/M17DSP.h b/openrtx/include/protocols/M17/M17DSP.h new file mode 100644 index 00000000..4963eace --- /dev/null +++ b/openrtx/include/protocols/M17/M17DSP.h @@ -0,0 +1,48 @@ +/*************************************************************************** + * Copyright (C) 2021 by Federico Amedeo Izzo IU2NUO, * + * Niccolò Izzo IU2KIN * + * Wojciech Kaczmarski SP5WWP * + * Frederik Saraci IU2NRO * + * Silvano Seva IU2KWO * + * * + * * + * 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 3 of the License, 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; if not, see * + ***************************************************************************/ + +#ifndef M17_DSP_H +#define M17_DSP_H + +#ifndef __cplusplus +#error This header is C++ only! +#endif + +#include +#include + +namespace M17 +{ + +/* + * Coefficients for M17 RRC filter + */ +extern const std::array rrc_taps; + +/* + * FIR implementation of the RRC filter for baseband audio generation. + */ +extern Fir< std::tuple_size< decltype(rrc_taps) >::value > rrc; + +} /* M17 */ + +#endif /* M17_DSP_H */ diff --git a/openrtx/src/protocols/M17/M17DSP.cpp b/openrtx/src/protocols/M17/M17DSP.cpp new file mode 100644 index 00000000..c719fb4c --- /dev/null +++ b/openrtx/src/protocols/M17/M17DSP.cpp @@ -0,0 +1,61 @@ +/*************************************************************************** + * Copyright (C) 2021 by Federico Amedeo Izzo IU2NUO, * + * Niccolò Izzo IU2KIN * + * Frederik Saraci IU2NRO * + * Silvano Seva IU2KWO * + * * + * 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 3 of the License, 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; if not, see * + ***************************************************************************/ + +#include + +namespace M17 +{ + +/* + * Coefficients for M17 RRC filter + */ +const std::array rrc_taps = { + -0.009265784007800534, -0.006136551625729697, -0.001125978562075172, + 0.004891777252042491, 0.01071805138282269, 0.01505751553351295, + 0.01679337935001369, 0.015256245142156299, 0.01042830577908502, + 0.003031522725559901, -0.0055333532968188165, -0.013403099825723372, + -0.018598682349642525, -0.01944761739590459, -0.015005271935951746, + -0.0053887880354343935, 0.008056525910253532, 0.022816244158307273, + 0.035513467692208076, 0.04244131815783876, 0.04025481153629372, + 0.02671818654865632, 0.0013810216516704976, -0.03394615682795165, + -0.07502635967975885, -0.11540977897637611, -0.14703962203941534, + -0.16119995609538576, -0.14969512896336504, -0.10610329539459686, + -0.026921412469634916, 0.08757875030779196, 0.23293327870303457, + 0.4006012210123992, 0.5786324696325503, 0.7528286479934068, + 0.908262741447522, 1.0309661131633199, 1.1095611856548013, + 1.1366197723675815, 1.1095611856548013, 1.0309661131633199, + 0.908262741447522, 0.7528286479934068, 0.5786324696325503, + 0.4006012210123992, 0.23293327870303457, 0.08757875030779196, + -0.026921412469634916, -0.10610329539459686, -0.14969512896336504, + -0.16119995609538576, -0.14703962203941534, -0.11540977897637611, + -0.07502635967975885, -0.03394615682795165, 0.0013810216516704976, + 0.02671818654865632, 0.04025481153629372, 0.04244131815783876, + 0.035513467692208076, 0.022816244158307273, 0.008056525910253532, + -0.0053887880354343935, -0.015005271935951746, -0.01944761739590459, + -0.018598682349642525, -0.013403099825723372, -0.0055333532968188165, + 0.003031522725559901, 0.01042830577908502, 0.015256245142156299, + 0.01679337935001369, 0.01505751553351295, 0.01071805138282269, + 0.004891777252042491, -0.001125978562075172, -0.006136551625729697, + -0.009265784007800534 +}; + +Fir< std::tuple_size< decltype(rrc_taps) >::value > rrc(rrc_taps); + +} /* M17 */ diff --git a/openrtx/src/protocols/M17/M17Modulator.cpp b/openrtx/src/protocols/M17/M17Modulator.cpp index 2da452a5..b58ef4ce 100644 --- a/openrtx/src/protocols/M17/M17Modulator.cpp +++ b/openrtx/src/protocols/M17/M17Modulator.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #if defined(PLATFORM_MD3x0) || defined(PLATFORM_MDUV3x0) #include @@ -30,46 +31,6 @@ #include #endif -/* - * Coefficients for M17 RRC filter - */ -const auto rrc_taps = std::experimental::make_array -( - -0.009265784007800534, -0.006136551625729697, -0.001125978562075172, - 0.004891777252042491, 0.01071805138282269, 0.01505751553351295, - 0.01679337935001369, 0.015256245142156299, 0.01042830577908502, - 0.003031522725559901, -0.0055333532968188165, -0.013403099825723372, - -0.018598682349642525, -0.01944761739590459, -0.015005271935951746, - -0.0053887880354343935, 0.008056525910253532, 0.022816244158307273, - 0.035513467692208076, 0.04244131815783876, 0.04025481153629372, - 0.02671818654865632, 0.0013810216516704976, -0.03394615682795165, - -0.07502635967975885, -0.11540977897637611, -0.14703962203941534, - -0.16119995609538576, -0.14969512896336504, -0.10610329539459686, - -0.026921412469634916, 0.08757875030779196, 0.23293327870303457, - 0.4006012210123992, 0.5786324696325503, 0.7528286479934068, - 0.908262741447522, 1.0309661131633199, 1.1095611856548013, - 1.1366197723675815, 1.1095611856548013, 1.0309661131633199, - 0.908262741447522, 0.7528286479934068, 0.5786324696325503, - 0.4006012210123992, 0.23293327870303457, 0.08757875030779196, - -0.026921412469634916, -0.10610329539459686, -0.14969512896336504, - -0.16119995609538576, -0.14703962203941534, -0.11540977897637611, - -0.07502635967975885, -0.03394615682795165, 0.0013810216516704976, - 0.02671818654865632, 0.04025481153629372, 0.04244131815783876, - 0.035513467692208076, 0.022816244158307273, 0.008056525910253532, - -0.0053887880354343935, -0.015005271935951746, -0.01944761739590459, - -0.018598682349642525, -0.013403099825723372, -0.0055333532968188165, - 0.003031522725559901, 0.01042830577908502, 0.015256245142156299, - 0.01679337935001369, 0.01505751553351295, 0.01071805138282269, - 0.004891777252042491, -0.001125978562075172, -0.006136551625729697, - -0.009265784007800534 -); - -/* - * FIR implementation of the RRC filter for baseband audio generation. - */ -static Fir< std::tuple_size< decltype(rrc_taps) >::value > rrc(rrc_taps); - - M17Modulator::M17Modulator() {