Back to C-ASPT Contents Page
asptBnlms32f
API Summary
API to create and delete an asptBnlms32f filters
API to filter through and update an asptBnlms32f filters
API to retrieve the properties of an asptBnlms32f filter
API to set the properties of an asptBnlms32f filter
- DT32S bnlms32fReset(asptBnlms32f *bnlms)
- DT32S bnlms32fResetDelayLine(asptBnlms32f *bnlms)
- DT32S bnlms32fResize(asptBnlms32f *bnlms, DT32S newL, DT32S newB)
- DT32S bnlms32fSetCoef(asptBnlms32f *bnlms, DT32F *newCoef, DT32S ind, DT32S N, DT32S flip)
- DT32S bnlms32fSetDelayLine(asptBnlms32f *bnlms, DT32F *newCoef, DT32S ind, DT32S N, DT32S flip)
- bnlms32fSetStepSize( asptBnlms32f
*bnlms, newStep )
- bnlms32fSetBlockLength( asptBnlms32f
*bnlms, newBlock )
Description
Implements the Block Normalized Least Mean Squares (LMS) adaptive filter algorithm.
Copyright
Copyright (c) DSP ALGORITHMS 2003; all rights reserved.
<< Back to top
bnlms32fInit
DT32S bnlms32fInit (asptBnlms32f *bnlms,DT32S L, DT32S B, DT32F mu)
Initializes an asptBnlms32f filter and allocates its necessary storage buffers. - Returns :
-
Error code. On failure, the filterLength member of the filter is set to zero.
- Input Parameters :
- bnlms : asptBnlms32f filter to be initialized
- L : number of filter coefficients
- B : block length; new input samples per block
- mu : step size.
- Error Conditions
- ASPT_NO_ERR : Initialization is successful
- ASPT_RANGE_ERR : L/B is not a valid input value
- ASPT_NO_MEM_ERR : could not allocate memory
<< Back to top
bnlms32fInitStatic
DT32S bnlms32fInitStatic(asptBnlms32f *bnlms,DT32S L, DT32S B, DT32F mu, DT32F *pCof, DT32F *pDat)
Initializes an asptBnlms32f filter to use pre-allocated memory. - Returns :
-
Error code. On failure, the filterLength member of the filter is set to zero.
- Input Parameters :
- bnlms : asptBnlms32f filter to be initialized
- L : number of filter coefficients
- B : block length, number of new samples per block
- mu : step size.
- pCof : pointer to a pre-allocated memory block to be used
for the adaptive filter coefficients. At least L memory locations must be available starting at this memory address.
- 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
- Error Conditions
- ASPT_NO_ERR : Initialization is successful
- ASPT_NULL_PTR_ERR : pCof/pDat is a NULL pointer
- ASPT_RANGE_ERR : L/B is not a valid input value
- ASPT_NO_MEM_ERR : could not allocate memory
<< Back to top
bnlms32fFilterUpdate
DT32S bnlms32fFilterUpdate (asptBnlms32f *bnlms, DT32F *inp, DT32F *des, DT32F *out, DT32F *err)
Calculates the filter output and updates the coefficients vector according to the BNLMS algorithm. - Returns :
- Input Parameters :
- bnlms : pointer to asptBnlms32f filter
- inp : array of B new input samples.
- des : array of B new desired samples
- Output Parameters :
- out : array of B filter output samples.
- err : array of B error samples
- Error Conditions
- ASPT_NO_ERR : success
- ASPT_NULL_PTR_ERR : NULL pointer error
<< Back to top
bnlms32fFilterOnly
DT32S bnlms32fFilterOnly (asptBnlms32f *bnlms, DT32F *inp, DT32F *out)
Calculates the filter output but does not updates the coefficients. It also update the internal input signal power estimate. - Returns :
- Input Parameters :
- bnlms : pointer to asptBnlms32f filter
- inp : array of B new input samples.
- Output Parameters :
- out : array of B filter output samples.
- Error Conditions
- ASPT_NO_ERR : success
- ASPT_NULL_PTR_ERR : NULL pointer error
<< Back to top
bnlms32fFree
void bnlms32fFree(asptBnlms32f *bnlms)
Frees the allocated memory for this asptBnlms32f filter. - Returns :
- Input Parameters :
- bnlms : pointer to asptBnlms32f filter
- Remarks :
-
Use this function only with filters created with bnlms32fInit(). Do not use with asptBnlms32f filters created using bnlms32fInitStatic().
<< Back to top
bnlms32fReset
DT32S bnlms32fReset(asptBnlms32f *bnlms)
Resets all filter coefficients to zero.- Returns :
- Input Parameters :
- bnlms : pointer to asptBnlms32f filter to be reset
- Error Conditions
- ASPT_NO_ERR : success
- ASPT_NULL_PTR_ERR : NULL pointer error
<< Back to top
bnlms32fResetDelayLine
DT32S bnlms32fResetDelayLine(asptBnlms32f *bnlms)
Resets all internal delay lines to zero.- Returns :
- Input Parameters :
- bnlms : pointer to asptBnlms32f filter to be reset
- Error Conditions
- ASPT_NO_ERR : success
- ASPT_NULL_PTR_ERR : NULL pointer error
<< Back to top
bnlms32fGetCoef
DT32S bnlms32fGetCoef(asptBnlms32f *bnlms, 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 the error code (negative int).
- Input Parameters :
- bnlms : pointer to asptBnlms32f 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/bnlms->coef is a NULL pointer
- ASPT_RANGE_ERR : ind/N is not a valid input value
<< Back to top
bnlms32fSetCoef
DT32S bnlms32fSetCoef(asptBnlms32f *bnlms, DT32F *newCoef, DT32S ind, DT32S N, DT32S flip)
Initializes N internal filter coefficients starting from coef[ind] to the contents of newBuf. - Returns :
-
On success returns the number of coefficients initialized, otherwise the error code (negative int).
- Input Parameters :
- bnlms : pointer to the asptBnlms32f 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/bnlms->coef is a NULL pointer
- ASPT_RANGE_ERR : ind/N is not a valid input value
<< Back to top
bnlms32fGetDelayLine
DT32S bnlms32fGetDelayLine(asptBnlms32f *bnlms, 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 the error code (negative int).
- Input Parameters :
- bnlms : pointer to asptBnlms32f 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/bnlms->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
bnlms32fSetDelayLine
DT32S bnlms32fSetDelayLine(asptBnlms32f *bnlms, 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 the error code (negative int).
- Input Parameters :
- bnlms : pointer to asptBnlms32f 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 :
- bnlms->delayLine is updated
- Error Conditions
- ASPT_NULL_PTR_ERR : newBuf/bnlms->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
bnlms32fResize
DT32S bnlms32fResize(asptBnlms32f *bnlms, DT32S newL, DT32S newB)
Resizes an asptBnlms32f filter keeping as much of the filter state as possible. - Returns :
- Input Parameters :
- bnlms : pointer to the asptBnlms32f filter to be resized.
- newL : required new filter length
- newB : required new block length
- Error Conditions
- ASPT_NO_ERR : Resizing is success
- ASPT_NULL_PTR_ERR : NULL pointer error
- ASPT_RANGE_ERR : newL/newB is not a valid input value
- ASPT_NO_MEM_ERR : Could not allocate the necessary filter storage
- Remarks :
-
Use this function only with dynamically allocated asptBnlms32f filters.