CMSIS-DSP
Version 1.5.2
CMSIS DSP Software Library
|
Functions | |
void | arm_biquad_cascade_df1_f32 (const arm_biquad_casd_df1_inst_f32 *S, float32_t *pSrc, float32_t *pDst, uint32_t blockSize) |
Processing function for the floating-point Biquad cascade filter. More... | |
void | arm_biquad_cascade_df1_fast_q15 (const arm_biquad_casd_df1_inst_q15 *S, q15_t *pSrc, q15_t *pDst, uint32_t blockSize) |
Fast but less precise processing function for the Q15 Biquad cascade filter for Cortex-M3 and Cortex-M4. More... | |
void | arm_biquad_cascade_df1_fast_q31 (const arm_biquad_casd_df1_inst_q31 *S, q31_t *pSrc, q31_t *pDst, uint32_t blockSize) |
Fast but less precise processing function for the Q31 Biquad cascade filter for Cortex-M3 and Cortex-M4. More... | |
void | arm_biquad_cascade_df1_init_f32 (arm_biquad_casd_df1_inst_f32 *S, uint8_t numStages, float32_t *pCoeffs, float32_t *pState) |
Initialization function for the floating-point Biquad cascade filter. More... | |
void | arm_biquad_cascade_df1_init_q15 (arm_biquad_casd_df1_inst_q15 *S, uint8_t numStages, q15_t *pCoeffs, q15_t *pState, int8_t postShift) |
Initialization function for the Q15 Biquad cascade filter. More... | |
void | arm_biquad_cascade_df1_init_q31 (arm_biquad_casd_df1_inst_q31 *S, uint8_t numStages, q31_t *pCoeffs, q31_t *pState, int8_t postShift) |
Initialization function for the Q31 Biquad cascade filter. More... | |
void | arm_biquad_cascade_df1_q15 (const arm_biquad_casd_df1_inst_q15 *S, q15_t *pSrc, q15_t *pDst, uint32_t blockSize) |
Processing function for the Q15 Biquad cascade filter. More... | |
void | arm_biquad_cascade_df1_q31 (const arm_biquad_casd_df1_inst_q31 *S, q31_t *pSrc, q31_t *pDst, uint32_t blockSize) |
Processing function for the Q31 Biquad cascade filter. More... | |
This set of functions implements arbitrary order recursive (IIR) filters. The filters are implemented as a cascade of second order Biquad sections. The functions support Q15, Q31 and floating-point data types. Fast version of Q15 and Q31 also supported on CortexM4 and Cortex-M3.
The functions operate on blocks of input and output data and each call to the function processes blockSize
samples through the filter. pSrc
points to the array of input data and pDst
points to the array of output data. Both arrays contain blockSize
values.
y[n] = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2]A Direct Form I algorithm is used with 5 coefficients and 4 state variables per stage.
b0, b1 and b2
multiply the input signal x[n]
and are referred to as the feedforward coefficients. Coefficients a1
and a2
multiply the output signal y[n]
and are referred to as the feedback coefficients. Pay careful attention to the sign of the feedback coefficients. Some design tools use the difference equation y[n] = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] - a1 * y[n-1] - a2 * y[n-2]In this case the feedback coefficients
a1
and a2
must be negated when used with the CMSIS DSP Library.numStages
refers to the number of second order stages used. For example, an 8th order filter would be realized with numStages=4
second order stages. numStages=5
second order stages with the coefficients for one of the stages configured as a first order filter (b2=0
and a2=0
).pState
points to state variables array. Each Biquad stage has 4 state variables x[n-1], x[n-2], y[n-1],
and y[n-2]
. The state variables are arranged in the pState
array as: {x[n-1], x[n-2], y[n-1], y[n-2]}
4*numStages
values. The state variables are updated after each block of data is processed, the coefficients are untouched.arm_biquad_casd_df1_inst_f32 S1 = {numStages, pState, pCoeffs}; arm_biquad_casd_df1_inst_q15 S2 = {numStages, pState, pCoeffs, postShift}; arm_biquad_casd_df1_inst_q31 S3 = {numStages, pState, pCoeffs, postShift};where
numStages
is the number of Biquad stages in the filter; pState
is the address of the state buffer; pCoeffs
is the address of the coefficient buffer; postShift
shift to be applied.[-1 +1)
. The fixed-point functions have an additional scaling parameter postShift
which allow the filter coefficients to exceed the range [+1 -1)
. At the output of the filter's accumulator is a shift register which shifts the result by postShift
bits. 2^postShift
. For example, to realize the coefficients {1.5, -0.8, 1.2, 1.6, -0.9}set the pCoeffs array to:
{0.75, -0.4, 0.6, 0.8, -0.45}and set
postShift=1
void arm_biquad_cascade_df1_f32 | ( | const arm_biquad_casd_df1_inst_f32 * | S, |
float32_t * | pSrc, | ||
float32_t * | pDst, | ||
uint32_t | blockSize | ||
) |
[in] | *S | points to an instance of the floating-point Biquad cascade structure. |
[in] | *pSrc | points to the block of input data. |
[out] | *pDst | points to the block of output data. |
[in] | blockSize | number of samples to process per call. |
References blockSize, arm_biquad_casd_df1_inst_f32::numStages, arm_biquad_casd_df1_inst_f32::pCoeffs, and arm_biquad_casd_df1_inst_f32::pState.
void arm_biquad_cascade_df1_fast_q15 | ( | const arm_biquad_casd_df1_inst_q15 * | S, |
q15_t * | pSrc, | ||
q15_t * | pDst, | ||
uint32_t | blockSize | ||
) |
[in] | *S | points to an instance of the Q15 Biquad cascade structure. |
[in] | *pSrc | points to the block of input data. |
[out] | *pDst | points to the block of output data. |
[in] | blockSize | number of samples to process per call. |
Scaling and Overflow Behavior:
postShift
bits and the result truncated to 1.15 format by discarding the low 16 bits.arm_biquad_cascade_df1_q15()
for a slower implementation of this function which uses 64-bit accumulation to avoid wrap around distortion. Both the slow and the fast versions use the same instance structure. Use the function arm_biquad_cascade_df1_init_q15()
to initialize the filter structure. References __PKHBT, __SIMD32, __SMLAD(), __SMUAD(), __SMUADX(), arm_biquad_casd_df1_inst_q15::numStages, arm_biquad_casd_df1_inst_q15::pCoeffs, arm_biquad_casd_df1_inst_q15::postShift, and arm_biquad_casd_df1_inst_q15::pState.
void arm_biquad_cascade_df1_fast_q31 | ( | const arm_biquad_casd_df1_inst_q31 * | S, |
q31_t * | pSrc, | ||
q31_t * | pDst, | ||
uint32_t | blockSize | ||
) |
[in] | *S | points to an instance of the Q31 Biquad cascade structure. |
[in] | *pSrc | points to the block of input data. |
[out] | *pDst | points to the block of output data. |
[in] | blockSize | number of samples to process per call. |
Scaling and Overflow Behavior:
arm_biquad_cascade_df1_q31()
for a slower implementation of this function which uses 64-bit accumulation to provide higher precision. Both the slow and the fast versions use the same instance structure. Use the function arm_biquad_cascade_df1_init_q31()
to initialize the filter structure. References mult_32x32_keep32_R, multAcc_32x32_keep32_R, arm_biquad_casd_df1_inst_q31::numStages, arm_biquad_casd_df1_inst_q31::pCoeffs, arm_biquad_casd_df1_inst_q31::postShift, and arm_biquad_casd_df1_inst_q31::pState.
void arm_biquad_cascade_df1_init_f32 | ( | arm_biquad_casd_df1_inst_f32 * | S, |
uint8_t | numStages, | ||
float32_t * | pCoeffs, | ||
float32_t * | pState | ||
) |
[in,out] | *S | points to an instance of the floating-point Biquad cascade structure. |
[in] | numStages | number of 2nd order stages in the filter. |
[in] | *pCoeffs | points to the filter coefficients array. |
[in] | *pState | points to the state array. |
Coefficient and State Ordering:
pCoeffs
in the following order: {b10, b11, b12, a11, a12, b20, b21, b22, a21, a22, ...}
b1x
and a1x
are the coefficients for the first stage, b2x
and a2x
are the coefficients for the second stage, and so on. The pCoeffs
array contains a total of 5*numStages
values.pState
is a pointer to state array. Each Biquad stage has 4 state variables x[n-1], x[n-2], y[n-1],
and y[n-2]
. The state variables are arranged in the pState
array as: {x[n-1], x[n-2], y[n-1], y[n-2]}The 4 state variables for stage 1 are first, then the 4 state variables for stage 2, and so on. The state array has a total length of
4*numStages
values. The state variables are updated after each block of data is processed; the coefficients are untouched. References arm_biquad_casd_df1_inst_f32::numStages, arm_biquad_casd_df1_inst_f32::pCoeffs, and arm_biquad_casd_df1_inst_f32::pState.
void arm_biquad_cascade_df1_init_q15 | ( | arm_biquad_casd_df1_inst_q15 * | S, |
uint8_t | numStages, | ||
q15_t * | pCoeffs, | ||
q15_t * | pState, | ||
int8_t | postShift | ||
) |
[in,out] | *S | points to an instance of the Q15 Biquad cascade structure. |
[in] | numStages | number of 2nd order stages in the filter. |
[in] | *pCoeffs | points to the filter coefficients. |
[in] | *pState | points to the state buffer. |
[in] | postShift | Shift to be applied to the accumulator result. Varies according to the coefficients format |
Coefficient and State Ordering:
pCoeffs
in the following order: {b10, 0, b11, b12, a11, a12, b20, 0, b21, b22, a21, a22, ...}where
b1x
and a1x
are the coefficients for the first stage, b2x
and a2x
are the coefficients for the second stage, and so on. The pCoeffs
array contains a total of 6*numStages
values. The zero coefficient between b1
and b2
facilities use of 16-bit SIMD instructions on the Cortex-M4.pState
. Each Biquad stage has 4 state variables x[n-1], x[n-2], y[n-1],
and y[n-2]
. The state variables are arranged in the pState
array as: {x[n-1], x[n-2], y[n-1], y[n-2]}The 4 state variables for stage 1 are first, then the 4 state variables for stage 2, and so on. The state array has a total length of
4*numStages
values. The state variables are updated after each block of data is processed; the coefficients are untouched. References arm_biquad_casd_df1_inst_q15::numStages, arm_biquad_casd_df1_inst_q15::pCoeffs, arm_biquad_casd_df1_inst_q15::postShift, and arm_biquad_casd_df1_inst_q15::pState.
void arm_biquad_cascade_df1_init_q31 | ( | arm_biquad_casd_df1_inst_q31 * | S, |
uint8_t | numStages, | ||
q31_t * | pCoeffs, | ||
q31_t * | pState, | ||
int8_t | postShift | ||
) |
[in,out] | *S | points to an instance of the Q31 Biquad cascade structure. |
[in] | numStages | number of 2nd order stages in the filter. |
[in] | *pCoeffs | points to the filter coefficients buffer. |
[in] | *pState | points to the state buffer. |
[in] | postShift | Shift to be applied after the accumulator. Varies according to the coefficients format |
Coefficient and State Ordering:
pCoeffs
in the following order: {b10, b11, b12, a11, a12, b20, b21, b22, a21, a22, ...}where
b1x
and a1x
are the coefficients for the first stage, b2x
and a2x
are the coefficients for the second stage, and so on. The pCoeffs
array contains a total of 5*numStages
values.pState
points to state variables array. Each Biquad stage has 4 state variables x[n-1], x[n-2], y[n-1],
and y[n-2]
. The state variables are arranged in the pState
array as: {x[n-1], x[n-2], y[n-1], y[n-2]}The 4 state variables for stage 1 are first, then the 4 state variables for stage 2, and so on. The state array has a total length of
4*numStages
values. The state variables are updated after each block of data is processed; the coefficients are untouched. References arm_biquad_casd_df1_inst_q31::numStages, arm_biquad_casd_df1_inst_q31::pCoeffs, arm_biquad_casd_df1_inst_q31::postShift, and arm_biquad_casd_df1_inst_q31::pState.
Referenced by main().
void arm_biquad_cascade_df1_q15 | ( | const arm_biquad_casd_df1_inst_q15 * | S, |
q15_t * | pSrc, | ||
q15_t * | pDst, | ||
uint32_t | blockSize | ||
) |
[in] | *S | points to an instance of the Q15 Biquad cascade structure. |
[in] | *pSrc | points to the block of input data. |
[out] | *pDst | points to the location where the output result is written. |
[in] | blockSize | number of samples to process per call. |
Scaling and Overflow Behavior:
postShift
bits to truncate the result to 1.15 format by discarding the low 16 bits. Finally, the result is saturated to 1.15 format.arm_biquad_cascade_df1_fast_q15()
for a faster but less precise implementation of this filter for Cortex-M3 and Cortex-M4. References __PKHBT, __SIMD32, __SMLALD(), __SMUAD(), __SMUADX(), arm_biquad_casd_df1_inst_q15::numStages, arm_biquad_casd_df1_inst_q15::pCoeffs, arm_biquad_casd_df1_inst_q15::postShift, and arm_biquad_casd_df1_inst_q15::pState.
void arm_biquad_cascade_df1_q31 | ( | const arm_biquad_casd_df1_inst_q31 * | S, |
q31_t * | pSrc, | ||
q31_t * | pDst, | ||
uint32_t | blockSize | ||
) |
[in] | *S | points to an instance of the Q31 Biquad cascade structure. |
[in] | *pSrc | points to the block of input data. |
[out] | *pDst | points to the block of output data. |
[in] | blockSize | number of samples to process per call. |
Scaling and Overflow Behavior:
postShift
bits and the result truncated to 1.31 format by discarding the low 32 bits.arm_biquad_cascade_df1_fast_q31()
for a faster but less precise implementation of this filter for Cortex-M3 and Cortex-M4. References blockSize, arm_biquad_casd_df1_inst_q31::numStages, arm_biquad_casd_df1_inst_q31::pCoeffs, arm_biquad_casd_df1_inst_q31::postShift, and arm_biquad_casd_df1_inst_q31::pState.
Referenced by main().