kopia lustrzana https://github.com/OpenRTX/OpenRTX
76 wiersze
2.9 KiB
C
76 wiersze
2.9 KiB
C
|
/***************************************************************************
|
||
|
* Copyright (C) 2020 by Federico Amedeo Izzo IU2NUO, *
|
||
|
* Niccolò Izzo IU2KIN, *
|
||
|
* Silvano Seva IU2KWO, *
|
||
|
* Frederik Saraci IU2NRO *
|
||
|
* *
|
||
|
* 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 <http://www.gnu.org/licenses/> *
|
||
|
***************************************************************************/
|
||
|
|
||
|
#ifndef DSP_H
|
||
|
#define DSP_H
|
||
|
|
||
|
#include <inttypes.h>
|
||
|
#include <stdlib.h>
|
||
|
|
||
|
typedef int16_t audio_sample_t;
|
||
|
|
||
|
/*
|
||
|
* This header contains various DSP utilities which can be used to condition
|
||
|
* input or output signals when implementing digital modes on OpenRTX.
|
||
|
*/
|
||
|
|
||
|
#ifdef __cplusplus
|
||
|
#include <array>
|
||
|
extern "C" {
|
||
|
#endif
|
||
|
|
||
|
/*
|
||
|
* Compensate for the filtering applied by the PWM output over the modulated
|
||
|
* signal. The buffer will be processed in place to save memory.
|
||
|
*
|
||
|
* @param buffer: the buffer to be used as both source and destination.
|
||
|
* @param length: the length of the input buffer.
|
||
|
*/
|
||
|
void dsp_pwmCompensate(audio_sample_t *buffer, uint16_t length);
|
||
|
|
||
|
/*
|
||
|
* Remove any DC bias from the audio buffer passed as parameter.
|
||
|
* The buffer will be processed in place to save memory.
|
||
|
*
|
||
|
* @param buffer: the buffer to be used as both source and destination.
|
||
|
* @param length: the length of the input buffer.
|
||
|
*/
|
||
|
void dsp_dcRemoval(audio_sample_t *buffer, uint16_t length);
|
||
|
|
||
|
#ifdef __cplusplus
|
||
|
}
|
||
|
|
||
|
/*
|
||
|
* Applies a generic FIR filter on the audio buffer passed as parameter.
|
||
|
* The buffer will be processed in place to save memory.
|
||
|
*
|
||
|
* @param buffer: the buffer to be used as both source and destination.
|
||
|
* @param length: the length of the input buffer.
|
||
|
* @param taps: an array of coefficients which defines the transfer function.
|
||
|
*/
|
||
|
template<size_t order>
|
||
|
void dsp_applyFIR(audio_sample_t *buffer,
|
||
|
uint16_t length,
|
||
|
std::array<float, order> taps);
|
||
|
|
||
|
#endif // __cplusplus
|
||
|
|
||
|
#endif /* DSP_H */
|