LIBML  Version 3.2.4
LIBML DSP Software Library
Functions
Finite Impulse Response (FIR) Sparse Filters
Collaboration diagram for Finite Impulse Response (FIR) Sparse Filters:

Functions

void tpt_fir_sparse_f32 (f32_t *aOutData, tpt_fir_sparse_f32_t *aFilter, f32_t *aInData, f32_t *aBuf, uint32_t aCount)
 Processing function for the floating-point sparse FIR filter. More...
 
void tpt_fir_sparse_init_f32 (tpt_fir_sparse_f32_t *aFilter, uint16_t aTaps, f32_t *aCoeffs, f32_t *aState, int32_t *aTapDelay, uint16_t aMaxDelay, uint32_t aCount)
 Initialization function for the floating-point sparse FIR filter. More...
 
void tpt_fir_sparse_init_q7 (tpt_fir_sparse_q7_t *aFilter, uint16_t aTaps, q7_t *aCoeffs, q7_t *aState, int32_t *aTapDelay, uint16_t aMaxDelay, uint32_t aCount)
 Initialization function for the Q7 sparse FIR filter. More...
 
void tpt_fir_sparse_init_q15 (tpt_fir_sparse_q15_t *aFilter, uint16_t aTaps, q15_t *aCoeffs, q15_t *aState, int32_t *aTapDelay, uint16_t aMaxDelay, uint32_t aCount)
 Initialization function for the Q15 sparse FIR filter. More...
 
void tpt_fir_sparse_init_q31 (tpt_fir_sparse_q31_t *aFilter, uint16_t aTaps, q31_t *aCoeffs, q31_t *aState, int32_t *aTapDelay, uint16_t aMaxDelay, uint32_t aCount)
 Initialization function for the Q31 sparse FIR filter. More...
 
void tpt_fir_sparse_q7 (q7_t *aOutData, tpt_fir_sparse_q7_t *aFilter, q7_t *aInData, q7_t *aBuf1, q31_t *aBuf2, uint32_t aCount)
 Function for the q7 Sparse FIR filter. More...
 
void tpt_fir_sparse_q15 (q15_t *aOutData, tpt_fir_sparse_q15_t *aFilter, q15_t *aInData, q15_t *aBuf1, q31_t *aBuf2, uint32_t aCount)
 Function for the q15 Sparse FIR filter. More...
 
void tpt_fir_sparse_q31 (q31_t *aOutData, tpt_fir_sparse_q31_t *aFilter, q31_t *aInData, q31_t *aBuf, uint32_t aCount)
 Processing function for the Q31 sparse FIR filter. More...
 

Detailed Description

Deprecated:
Those functions are no more tested nor maintained and will be removed in a future version.

This group of functions implements sparse FIR filters. Sparse FIR filters are equivalent to standard FIR filters except that most of the coefficients are equal to zero. Sparse filters are used for simulating reflections in communications and audio applications.

There are separate functions for Q7, Q15, Q31, and floating-point data types. The functions operate on blocks of input and output data and each call to the function processes blockSize samples through the filter. pSrc and pDst points to input and output arrays respectively containing blockSize values.

Algorithm
The sparse filter instant structure contains an array of tap indices pTapDelay which specifies the locations of the non-zero coefficients. This is in addition to the coefficient array b. The implementation essentially skips the multiplications by zero and leads to an efficient realization.
     y[n] = b[0] * x[n-pTapDelay[0]] + b[1] * x[n-pTapDelay[1]] + b[2] *
     x[n-pTapDelay[2]] + ...+ b[uTaps-1] * x[n-pTapDelay[uTaps-1]]
 
Sparse FIR filter. b[n]
represents the filter coefficients"
pCoeffs points to a coefficient array of aCount uTaps; pTapDelay points to an array of nonzero indices and is also of aCount uTaps; pState points to a state array of aCount maxDelay + blockSize, where maxDelay is the largest offset value that is ever used in the pTapDelay array. Some of the processing functions also require temporary working buffers.
Instance Structure
The coefficients and state variables for a filter are stored together in an instance data structure. A separate instance structure must be defined for each filter. Coefficient and offset arrays may be shared among several instances while state variable arrays cannot be shared. There are separate instance structure declarations for each of the 4 supported data types.
Initialization Functions
There is also an associated initialization function for each data type. The initialization function performs the following operations:
  • Sets the values of the internal structure fields.
  • Zeros out the values in the state buffer. To do this manually without calling the init function, assign the follow subfields of the instance structure: uTaps, pCoeffs, pTapDelay, maxDelay, stateIndex, pState. Also set all of the values in pState to zero.
Use of the initialization function is optional. However, if the initialization function is used, then the instance structure cannot be placed into a const data section. To place an instance structure into a const data section, the instance structure must be manually initialized. Set the values in the state buffer to zeros before static initialization. The code below statically initializes each of the 4 different data type filter instance structures
     tpt_fir_sparse_f32 aFilter = {uTaps, 0, pState, pCoeffs, maxDelay,
     pTapDelay}; tpt_fir_sparse_q31 S = {uTaps, 0, pState,
     pCoeffs, maxDelay, pTapDelay}; tpt_fir_sparse_q15 S = {uTaps,
     0, pState, pCoeffs, maxDelay, pTapDelay}; tpt_fir_sparse_q7 S =
     {uTaps, 0, pState, pCoeffs, maxDelay, pTapDelay};
 
Fixed-Point Behavior
Care must be taken when using the fixed-point versions of the sparse FIR filter functions. In particular, the overflow and saturation behavior of the accumulator used in each function must be considered. Refer to the function specific documentation below for usage guidelines.

Function Documentation

◆ tpt_fir_sparse_f32()

void tpt_fir_sparse_f32 ( f32_t aOutData,
tpt_fir_sparse_f32_t aFilter,
f32_t aInData,
f32_t aBuf,
uint32_t  aCount 
)

Processing function for the floating-point sparse FIR filter.

Parameters
[out]aOutDatapoints to the block of output data
[in]aFilterpoints to an instance of the floating-point sparse FIR structure
[in]aInDatapoints to the block of input data
[in]aBufpoints to a temporary buffer of aCount blockSize
[in]aCountnumber of input samples to process

◆ tpt_fir_sparse_init_f32()

void tpt_fir_sparse_init_f32 ( tpt_fir_sparse_f32_t aFilter,
uint16_t  aTaps,
f32_t aCoeffs,
f32_t aState,
int32_t *  aTapDelay,
uint16_t  aMaxDelay,
uint32_t  aCount 
)

Initialization function for the floating-point sparse FIR filter.

Parameters
[in,out]aFilterpoints to an instance of the floating-point sparse FIR structure
[in]aTapsnumber of nonzero coefficients in the filter
[in]aCoeffspoints to the array of filter coefficients
[in]aStatepoints to the state buffer
[in]aTapDelaypoints to the array of offset times
[in]aMaxDelaymaximum offset time supported
[in]aCountnumber of samples that will be processed per block

◆ tpt_fir_sparse_init_q15()

void tpt_fir_sparse_init_q15 ( tpt_fir_sparse_q15_t aFilter,
uint16_t  aTaps,
q15_t aCoeffs,
q15_t aState,
int32_t *  aTapDelay,
uint16_t  aMaxDelay,
uint32_t  aCount 
)

Initialization function for the Q15 sparse FIR filter.

Parameters
[in,out]aFilterpoints to an instance of the floating-point sparse FIR structure
[in]aTapsnumber of nonzero coefficients in the filter
[in]aCoeffspoints to the array of filter coefficients
[in]aStatepoints to the state buffer
[in]aTapDelaypoints to the array of offset times
[in]aMaxDelaymaximum offset time supported
[in]aCountnumber of samples that will be processed per block

◆ tpt_fir_sparse_init_q31()

void tpt_fir_sparse_init_q31 ( tpt_fir_sparse_q31_t aFilter,
uint16_t  aTaps,
q31_t aCoeffs,
q31_t aState,
int32_t *  aTapDelay,
uint16_t  aMaxDelay,
uint32_t  aCount 
)

Initialization function for the Q31 sparse FIR filter.

Parameters
[in,out]aFilterpoints to an instance of the floating-point sparse FIR structure
[in]aTapsnumber of nonzero coefficients in the filter
[in]aCoeffspoints to the array of filter coefficients
[in]aStatepoints to the state buffer
[in]aTapDelaypoints to the array of offset times
[in]aMaxDelaymaximum offset time supported
[in]aCountnumber of samples that will be processed per block

◆ tpt_fir_sparse_init_q7()

void tpt_fir_sparse_init_q7 ( tpt_fir_sparse_q7_t aFilter,
uint16_t  aTaps,
q7_t aCoeffs,
q7_t aState,
int32_t *  aTapDelay,
uint16_t  aMaxDelay,
uint32_t  aCount 
)

Initialization function for the Q7 sparse FIR filter.

Parameters
[in,out]aFilterpoints to an instance of the floating-point sparse FIR structure
[in]aTapsnumber of nonzero coefficients in the filter
[in]aCoeffspoints to the array of filter coefficients
[in]aStatepoints to the state buffer
[in]aTapDelaypoints to the array of offset times
[in]aMaxDelaymaximum offset time supported
[in]aCountnumber of samples that will be processed per block

◆ tpt_fir_sparse_q15()

void tpt_fir_sparse_q15 ( q15_t aOutData,
tpt_fir_sparse_q15_t aFilter,
q15_t aInData,
q15_t aBuf1,
q31_t aBuf2,
uint32_t  aCount 
)

Function for the q15 Sparse FIR filter.

Parameters
[out]aOutDatapoints to the output block data.
[in]aFilterpoints to an instance of the Sparse FIR structure.
[in]aInDatapoints to the input block data.
[in]aBuf1points to a temporary buffer of length aCount.
[in]aBuf2points to a temporary buffer of length aCount.
[in]aCountnumber of the aCount.

◆ tpt_fir_sparse_q31()

void tpt_fir_sparse_q31 ( q31_t aOutData,
tpt_fir_sparse_q31_t aFilter,
q31_t aInData,
q31_t aBuf,
uint32_t  aCount 
)

Processing function for the Q31 sparse FIR filter.

Parameters
[out]aOutDatapoints to the block of output data
[in]aFilterpoints to an instance of the floating-point sparse FIR structure
[in]aInDatapoints to the block of input data
[in]aBufpoints to a temporary buffer of aCount blockSize
[in]aCountnumber of input samples to process

◆ tpt_fir_sparse_q7()

void tpt_fir_sparse_q7 ( q7_t aOutData,
tpt_fir_sparse_q7_t aFilter,
q7_t aInData,
q7_t aBuf1,
q31_t aBuf2,
uint32_t  aCount 
)

Function for the q7 Sparse FIR filter.

Parameters
[out]aOutDatapoints to the output block data.
[in]aFilterpoints to an instance of the Sparse FIR structure.
[in]aInDatapoints to the input block data.
[in]aBuf1points to a temporary buffer of length aCount.
[in]aBuf2points to a temporary buffer of length aCount.
[in]aCountnumber of the aCount.