Aviate Audio Multiverse Library
|
IIR BiQuad Filter - Direct Form I
y[n] = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2]
Some design tools (like Matlab assume the feedback coefficients 'a' are negated.
More...
#include <LibBasicFunctions.h>
Public Member Functions | |
IirBiQuadFilter (unsigned numStages, const int32_t *coeffs, int coeffShift=0) | |
Construct a Biquad filter with specified number of stages, coefficients and scaling. More... | |
virtual | ~IirBiQuadFilter () |
Destructor. | |
void | changeFilterCoeffs (unsigned numStages, const int32_t *coeffs, int coeffShift=0) |
Reconfigure the filter coefficients. More... | |
bool | process (int16_t *output, int16_t *input, size_t numSamples) |
Process the data using the configured IIR filter. More... | |
IIR BiQuad Filter - Direct Form I
y[n] = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2]
Some design tools (like Matlab assume the feedback coefficients 'a' are negated.
You may have to negate your 'a' coefficients.
Note that the ARM CMSIS-DSP library requires an extra zero between first and second 'b' coefficients. E.g.
{b10, 0, b11, b12, a11, a12, b20, 0, b21, b22, a21, a22, ...}
Aviate::IirBiQuadFilter::IirBiQuadFilter | ( | unsigned | numStages, |
const int32_t * | coeffs, | ||
int | coeffShift = 0 |
||
) |
Construct a Biquad filter with specified number of stages, coefficients and scaling.
See CMSIS-DSP documentation for more details
numStages | number of biquad stages. Each stage has 5 coefficients. |
coeffs | pointer to an array of Q31 fixed-point coefficients (range -1 to +0.999...) |
coeffShift | coeffs are multiplied by 2^coeffShift to support coefficient range scaling |
void Aviate::IirBiQuadFilter::changeFilterCoeffs | ( | unsigned | numStages, |
const int32_t * | coeffs, | ||
int | coeffShift = 0 |
||
) |
Reconfigure the filter coefficients.
See CMSIS-DSP documentation for more details
numStages | number of biquad stages. Each stage has 5 coefficients. |
coeffs | pointer to an array of Q31 fixed-point coefficients (range -1 to +0.999...) |
coeffShift | coeffs are multiplied by 2^coeffShift to support coefficient range scaling |
bool Aviate::IirBiQuadFilter::process | ( | int16_t * | output, |
int16_t * | input, | ||
size_t | numSamples | ||
) |
Process the data using the configured IIR filter.
output and input can be the same pointer if in-place modification is desired
output | pointer to where the output results will be written |
input | pointer to where the input data will be read from |
numSamples | number of samples to process |