Back to C-ASPT Contents Page
asptFir32f
API Summary
API to create and delete asptFir32f filters
API to filter through asptFir32f filters
API to retrieve the properties of an asptFir32f filter
API to set the properties of an asptFir32f filter
Description
Implements the Finite Impulse Response filter using circular buffering. The filter supports sample per sample as well as block processing.
Copyright
Copyright (c) DSP ALGORITHMS 2003; all rights reserved.
<< Back to top
fir32fInit
DT32S fir32fInit (asptFir32f *fir, DT32S L, DT32F *pCof)
Initializes an asptFir32f filter and dynamically allocates its necessary storage buffers.- Returns :
-
Error code. On failure, the filterLength member of the asptFir32f filter is set to zero.
- Input Parameters :
- fir : pointer to asptFir32f filter to be initialized
- L : number of filter coefficients
- pCof : pointer to the array of L filter coefficients
- Output Parameters :
- fir is initialized using the given input parameters
- Error Conditions
- ASPT_NO_ERR : Initialization success
- ASPT_NULL_PTR_ERR : pCof is a NULL pointer
- ASPT_RANGE_ERR : L is not a valid filter length
- ASPT_NO_MEM_ERR : Could not allocate the necessary filter storage
<< Back to top
fir32fInitStatic
DT32S fir32fInitStatic(asptFir32f *fir, DT32S L, DT32F *pCof, DT32F *pDat)
Initializes an asptFir32f filter to use pre-allocated memory blocks.- Returns :
-
Error code. On failure, the filterLength member of the asptFir32f filter is set to zero.
- Input Parameters :
- fir : pointer to asptFir32f filter to be initialized
- L : number of filter coefficients
- pCof : pointer to the array of L filter coefficients.
- pDat : pointer to a pre-allocated memory block to be used
for data storage. At least (L) memory locations must be available starting at this memory address
- Output Parameters :
- fir is initialized using the given input parameters
- Error Conditions
- ASPT_NO_ERR : Initialization success
- ASPT_NULL_PTR_ERR : pCof/pDat is a NULL pointer
- ASPT_RANGE_ERR : L is not a valid filter length
<< Back to top
fir32fFilter
DT32F fir32fFilter(asptFir32f *fir, DT32F inSample)
Calculates the filter output due to input sample in. - Returns :
- Input Parameters :
- fir : pointer to asptFir32f filter
- in : new input sample.
<< Back to top
fir32fLCFilter
DT32F fir32fLCFilter(asptFir32f *fir)
Calculates the filter output for the Linear Combiner filter configuration. Assumes the delay line has been already updated externally before calling this function. - Returns :
- Input Parameters :
- fir : pointer to asptFir32f filter
<< Back to top
fir32fBlockFilter
DT32S fir32fBlockFilter(asptFir32f *fir, DT32F *in, DT32F *out,DT32S BlockLength)
Calculates the filter output; block processing. - Returns :
- Input Parameters :
- fir : pointer to asptFir32f filter
- in : array of input samples.
- Output Parameters :
- out : array of output samples
- Error Conditions
- ASPT_NO_ERR : success
- ASPT_NULL_PTR_ERR : in/out is a NULL pointer
<< Back to top
fir32fFree
void fir32fFree(asptFir32f *fir)
Frees the allocated memory for this asptFir32f filter. - Returns :
- Input Parameters :
- fir : pointer to the asptFir32f filter to be de-allocated
- Remarks :
-
Use this function only with filters created with fir32fInit(). Do not use with asptFir32f filters created using fir32fInitStatic().
<< Back to top
fir32fResetDelayLine
DT32S fir32fResetDelayLine(asptFir32f *fir)
Resets the internal delay lines to zero. - Returns :
- Input Parameters :
- fir : pointer to the asptFir32f filter to be reset.
<< Back to top
fir32fGetCoef
DT32S fir32fGetCoef(asptFir32f *fir, DT32F *buf, DT32S ind, DT32S N, DT32S flip)
Copies N internal filter coefficients starting from coef[ind] to dstBuf. - Returns :
-
on success returns the number of coefficients copied, otherwise an error code
- Input Parameters :
- fir : pointer to asptFir32f filter.
- dstBuf : destination buffer
- ind : index to the first coefficient to be copied.
- N : number of coefficients to be copied.
- flip : if not 0, will flip the coefficients order
- Output Parameters :
- Error Conditions
- ASPT_NULL_PTR_ERR : dstBuf/fir->coef is a NULL pointer
- ASPT_RANGE_ERR : ind/N is not a valid input value
<< Back to top
fir32fSetCoef
DT32S fir32fSetCoef(asptFir32f *fir, DT32F *newCoef, DT32S ind, DT32S N, DT32S flip)
Initializes N internal filter coefficients starting from coef[ind] to the contents of newCoef.- Returns :
-
on success returns the number of coefficients initialized, otherwise an error code
- Input Parameters :
- fir : pointer to asptFir32f filter to be set.
- newCoef : new coefficients vector.
- ind : index to the first coefficient to be set.
- N : number of coefficients to be set.
- flip : if not 0, will copy the coefficients in reverse order
- Output Parameters :
- Error Conditions
- ASPT_NULL_PTR_ERR : newCoef/fir->coef is a NULL pointer
- ASPT_RANGE_ERR : ind/N is not a valid input value
<< Back to top
fir32fGetDelayLine
DT32S fir32fGetDelayLine(asptFir32f *fir, DT32F *buf, DT32S ind, DT32S N, DT32S flip)
Copies N internal delay line samples starting from delayLine[ind] to dstBuf. - Returns :
-
on success returns the number of samples copied, otherwise an error code
- Input Parameters :
- fir : pointer to asptFir32f filter.
- dstBuf : destination buffer.
- ind : index to the first sample to be copied.
- N : number of samples to be copied.
- flip : if not 0, will flip the samples order.
- Output Parameters :
- Error Conditions
- ASPT_NULL_PTR_ERR : dstBuf/fir->delayLine is a NULL pointer
- ASPT_RANGE_ERR : ind/N is not a valid input value
- Remarks :
-
Samples are stored in dstBuf with newest sample at index 0, and oldest at index N-1, when flip == 0.
<< Back to top
fir32fSetDelayLine
DT32S fir32fSetDelayLine(asptFir32f *fir, DT32F *newCoef, DT32S ind, DT32S N, DT32S flip)
Initializes N internal delay line samples starting from delayLine[ind] to the contents of the given array. - Returns :
-
on success returns the number of samples initialized, otherwise an error code
- Input Parameters :
- fir : pointer to asptFir32f filter.
- newBuf : new data buffer.
- ind : index to the first sample to be copied.
- N : number of samples to be copied.
- flip : if not 0, will flip the samples order
- Output Parameters :
- fir->delayLine is updated
- Error Conditions
- ASPT_NULL_PTR_ERR : newBuf/fir->delayLine is a NULL pointer
- ASPT_RANGE_ERR : ind/N is not a valid input value
- Remarks :
-
Samples assumed to be stored in newBuf with newest sample at index 0, and oldest at index N-1, when flip == 0.
<< Back to top
fir32fResize
DT32S fir32fResize(asptFir32f *fir, DT32S newLength)
Resizes an asptFir32f filter keeping as much of the filter state as possible. - Returns :
- Input Parameters :
- fir : pointer to the asptFir32f filter to be resized.
- newLen : required new filter length.
- Error Conditions
- ASPT_NO_ERR : Resizing is success
- ASPT_NULL_PTR_ERR : NULL pointer error
- ASPT_RANGE_ERR : newLength is not a valid filter length
- ASPT_NO_MEM_ERR : Could not allocate the necessary filter storage
- Remarks :
-
Use this function only with dynamically allocated asptFir32f filters.