Back to C-ASPT Contents Page
asptLeakynlms32f
API Summary
API to create and delete an asptLeakynlms32f filters
API to filter through and update an asptLeakynlms32f filters
API to retrieve the properties of an asptLeakynlms32f filter
API to set the properties of an asptLeakynlms32f filter
- DT32S leakynlms32fReset(asptLeakynlms32f *leakynlms)
- DT32S leakynlms32fResetDelayLine(asptLeakynlms32f *leakynlms)
- DT32S leakynlms32fResize(asptLeakynlms32f *leakynlms, DT32S newLength)
- DT32S leakynlms32fSetCoef(asptLeakynlms32f *leakynlms, DT32F *newCoef, DT32S ind, DT32S N, DT32S flip)
- DT32S leakynlms32fSetDelayLine(asptLeakynlms32f *leakynlms, DT32F *newCoef, DT32S ind, DT32S N, DT32S flip)
- leakynlms32fSetStepSize( asptLeakynlms32f
*leakynlms, newStep )
- leakynlms32fSetLeakFactor( asptLeakynlms32f
*leakynlms, Leak )
Description
Implements the Leaky Normalized LMS adaptive filter algorithm.
Copyright
Copyright (c) DSP ALGORITHMS 2003; all rights reserved.
<< Back to top
leakynlms32fInit
DT32S leakynlms32fInit (asptLeakynlms32f *leakynlms,DT32S L, DT32F mu, DT32F leak)
Initializes an asptLeakynlms32f filter and allocates its necessary storage buffers. - Returns :
-
Error code. On failure, the filterLength member of the filter is set to zero.
- Input Parameters :
- leakynlms : asptLeakynlms32f filter to be initialized
- L : number of filter coefficients
- mu : step size
- Leak : leak factor
- Error Conditions
- ASPT_NO_ERR : Initialization is successful
- ASPT_RANGE_ERR : L is not a valid input value
- ASPT_NO_MEM_ERR : could not allocate memory
<< Back to top
leakynlms32fInitStatic
DT32S leakynlms32fInitStatic(asptLeakynlms32f *leakynlms,DT32S L, DT32F mu, DT32F leak, DT32F *pCof, DT32F *pDat)
Initializes an asptLeakynlms32f filter to use pre-allocated memory. - Returns :
-
Error code. On failure, the filterLength member of the filter is set to zero.
- Input Parameters :
- leakynlms : asptLeakynlms32f filter to be initialized
- L : number of filter coefficients
- mu : step size
- Leak : leak factor
- 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 is not a valid input value
- ASPT_NO_MEM_ERR : could not allocate memory
<< Back to top
leakynlms32fFilterUpdate
DT32F leakynlms32fFilterUpdate(asptLeakynlms32f *leakynlms, DT32F inp, DT32F des)
Calculates the filter output and updates the coefficients vector according to the Leaky Normalized LMS algorithm. - Returns :
-
The filter output sample.
- Input Parameters :
- leakynlms : pointer to asptLeakynlms32f filter
- inp : new input sample.
- des : new desired sample
- Remarks :
-
The error sample is stored internally and can be retrieved by calling leakynlms32fGetLastErrorSample().
<< Back to top
leakynlms32fFilterOnly
DT32F leakynlms32fFilterOnly (asptLeakynlms32f *leakynlms, DT32F inp)
Calculates the filter output but does not updates the coefficients. It also updates the input power. - Returns :
-
The filter output sample.
- Input Parameters :
- leakynlms : pointer to the asptLeakynlms32f filter
- inp : new input sample.
- Remarks :
-
error sample is not calculated.
<< Back to top
leakynlms32fLCFilterUpdate
DT32F leakynlms32fLCFilterUpdate(asptLeakynlms32f *leakynlms, DT32F des)
Calculates the filter output and updates the coefficients vector according to the Leaky Normalized LMS algorithm for the Linear Combiner filter configuration. Assumes the delay line has been already updated before calling this function. - Returns :
-
The filter output sample.
- Input Parameters :
- leakynlms : pointer to asptLeakynlms32f filter
- des : new desired sample
- Remarks :
-
The error sample is stored internally and can be retrieved by calling leakynlms32fGetLastErrorSample().
<< Back to top
leakynlms32fFilterOnly
DT32F leakynlms32fFilterOnly (asptLeakynlms32f *leakynlms, DT32F inp)
Calculates the filter output but does not updates the coefficients. It also updates the input power for the Linear Combiner filter configuration. Assumes the delay line has been already updated before calling this function. - Returns :
-
The filter output sample.
- Input Parameters :
- leakynlms : pointer to asptLeakynlms32f filter
- Remarks :
-
error sample is not calculated.
<< Back to top
leakynlms32fFree
void leakynlms32fFree(asptLeakynlms32f *leakynlms)
Frees the allocated memory for this asptLeakynlms32f filter. - Returns :
- Input Parameters :
- leakynlms : pointer to asptLeakynlms32f filter
- Remarks :
-
Use this function only with filters created with leakynlms32fInit(). Do not use with asptLeakynlms32f filters created using leakynlms32fInitStatic().
<< Back to top
leakynlms32fReset
DT32S leakynlms32fReset(asptLeakynlms32f *leakynlms)
Resets all filter coefficients to zero.- Returns :
- Input Parameters :
- leakynlms : pointer to asptLeakynlms32f filter to be reset
- Error Conditions
- ASPT_NO_ERR : success
- ASPT_NULL_PTR_ERR : NULL pointer error
<< Back to top
leakynlms32fResetDelayLine
DT32S leakynlms32fResetDelayLine(asptLeakynlms32f *leakynlms)
Resets all internal delay lines to zero.- Returns :
- Input Parameters :
- leakynlms : pointer to asptLeakynlms32f filter to be reset
- Error Conditions
- ASPT_NO_ERR : success
- ASPT_NULL_PTR_ERR : NULL pointer error
<< Back to top
leakynlms32fGetCoef
DT32S leakynlms32fGetCoef(asptLeakynlms32f *leakynlms, 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 :
- leakynlms : pointer to asptLeakynlms32f 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/leakynlms->coef is a NULL pointer
- ASPT_RANGE_ERR : ind/N is not a valid input value
<< Back to top
leakynlms32fSetCoef
DT32S leakynlms32fSetCoef(asptLeakynlms32f *leakynlms, 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 :
- leakynlms : pointer to asptLeakynlms32f 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 :
- leakynlms->coef is updated
- Error Conditions
- ASPT_NULL_PTR_ERR : newCoef/leakynlms->coef is a NULL pointer
- ASPT_RANGE_ERR : ind/N is not a valid input value
<< Back to top
leakynlms32fGetDelayLine
DT32S leakynlms32fGetDelayLine(asptLeakynlms32f *leakynlms, 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 :
- leakynlms : pointer to asptLeakynlms32f 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/leakynlms->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
leakynlms32fSetDelayLine
DT32S leakynlms32fSetDelayLine(asptLeakynlms32f *leakynlms, 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 :
- leakynlms : pointer to asptLeakynlms32f 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 :
- leakynlms->delayLine is updated
- Error Conditions
- ASPT_NULL_PTR_ERR : newBuf/leakynlms->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
leakynlms32fResize
DT32S leakynlms32fResize(asptLeakynlms32f *leakynlms, DT32S newLength)
Resizes an asptLeakynlms32f filter keeping as much of the filter state as possible. - Returns :
- Input Parameters :
- leakynlms : pointer to the asptLeakynlms32f 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 input value
- ASPT_NO_MEM_ERR : Could not allocate the necessary filter storage
- Remarks :
-
Use this function only with dynamically allocated asptLeakynlms32f filters.