Back to C-ASPT Contents Page
asptSovnlms32f
API Summary
API to create and delete an sovFir filters
- DT32S sovnlms32fInit (asptSovnlms32f *sovnlms, DT32S L1, DT32S L2, DT32F muL, DT32F muN)
- DT32S sovnlms32fInitStatic (asptSovnlms32f *sovnlms, DT32S L1, DT32S L2, DT32F muL, DT32F muN, DT32F *pCof, DT32F *pDat)
- void sovnlms32fFree(asptSovnlms32f *sovnlms)
API to filter through a sovFir filter
- DT32F sovnlms32fFilterOnly (asptSovnlms32f *sovnlms, DT32F inp)
- DT32F sovnlms32fFilterUpdate (asptSovnlms32f *sovnlms, DT32F inp, DT32F des)
- DT32S sovnlms32fBlockFilterOnly (asptSovnlms32f *sovnlms, DT32F *inp, DT32F *out, DT32S N)
- DT32S sovnlms32fBlockFilterUpdate (asptSovnlms32f *sovnlms,DT32F *inp,DT32F *des,DT32F *out,DT32F *err,DT32S N)
API to retrieve the properties of an sovFir objects
- DT32S sovnlms32fGetCoef(asptSovnlms32f *sovnlms, DT32F *buf, DT32S ind, DT32S N, DT32S flip)
- DT32S sovnlms32fGetLinearCoef(asptSovnlms32f *sovnlms, DT32F *buf, DT32S ind, DT32S N, DT32S flip)
- DT32S sovnlms32fGetNonLinearCoef(asptSovnlms32f *sovnlms, DT32F *buf, DT32S ind, DT32S N, DT32S flip)
- DT32S sovnlms32fGetNonLinearDelayLine(asptSovnlms32f *sovnlms, DT32F *buf, DT32S ind, DT32S N, DT32S flip)
- DT32S sovnlms32fGetLinearDelayLine(asptSovnlms32f *sovnlms, DT32F *buf, DT32S ind, DT32S N, DT32S flip)
- sovnlms32fGetCoefPtr( asptSovnlms32f
*sovnlms )
- sovnlms32fGetLinearCoefPtr( asptSovnlms32f
*sovnlms )
- sovnlms32fGetNonLinearCoefPtr( asptSovnlms32f
*sovnlms )
- sovnlms32fGetDelayLinePtr( asptSovnlms32f
*sovnlms )
- sovnlms32fGetLinearDelayLinePtr( asptSovnlms32f
*sovnlms )
- sovnlms32fGetNonLinearDelayLinePtr( asptSovnlms32f
*sovnlms )
- sovnlms32fGetFilterLength( asptSovnlms32f
*sovnlms )
- sovnlms32fGetLinearLength( asptSovnlms32f
*sovnlms )
- sovnlms32fGetNonLinearLength( asptSovnlms32f
*sovnlms )
- sovnlms32fGetLastErrorSample( asptSovnlms32f
*sovnlms )
- sovnlms32fGetLinearStepSize( asptSovnlms32f
*sovnlms )
- sovnlms32fGetNonLinearStepSize( asptSovnlms32f
*sovnlms )
API to set the properties of an sovFir filter
- DT32S sovnlms32fReset(asptSovnlms32f *sovnlms)
- DT32S sovnlms32fResetDelayLine(asptSovnlms32f *sovnlms)
- DT32S sovnlms32fResize(asptSovnlms32f *sovnlms, DT32S newL1, DT32S newL2)
- DT32S sovnlms32fSetCoef(asptSovnlms32f *sovnlms, DT32F *newCoef, DT32S ind, DT32S N, DT32S flip)
- DT32S sovnlms32fSetLinearCoef(asptSovnlms32f *sovnlms, DT32F *newCoef, DT32S ind, DT32S N, DT32S flip)
- DT32S sovnlms32fSetNonLinearCoef(asptSovnlms32f *sovnlms, DT32F *newCoef, DT32S ind, DT32S N, DT32S flip)
- DT32S sovnlms32fSetLinearDelayLine(asptSovnlms32f *sovnlms, DT32F *buf, DT32S ind, DT32S N, DT32S flip)
- DT32S sovnlms32fSetNonLinearDelayLine(asptSovnlms32f *sovnlms, DT32F *buf, DT32S ind, DT32S N, DT32S flip)
- sovnlms32fSetLinearStepSize( asptSovnlms32f
*sovnlms, newStep )
- sovnlms32fSetNonLinearStepSize( asptSovnlms32f
*sovnlms, newStep )
Description
Implements the Second Order Volterra NLMS non-linear adaptive FIR 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
sovnlms32fInit
DT32S sovnlms32fInit (asptSovnlms32f *sovnlms, DT32S L1, DT32S L2, DT32F muL, DT32F muN)
Initializes an asptSovnlms32f filter and dynamically allocates its necessary storage buffers.- Returns :
-
Error code. On failure, the filterLength member of the asptSovnlms32f filter is set to zero.
- Input Parameters :
- sovnlms : pointer to asptSovnlms32f filter to be initialized
- L1 : memory length of the linear filter part
- L2 : memory length of the non-linear filter part
- muL : step size of the filter linear part
- muN : step size of the filter non-linear part
- Output Parameters :
- sovnlms is initialized using the given input parameters
- Error Conditions
- ASPT_NO_ERR : Initialization success
- ASPT_RANGE_ERR : L1/L2 is not a valid filter length
- ASPT_NO_MEM_ERR : Could not allocate the necessary filter storage
<< Back to top
sovnlms32fInitStatic
DT32S sovnlms32fInitStatic (asptSovnlms32f *sovnlms, DT32S L1, DT32S L2, DT32F muL, DT32F muN, DT32F *pCof, DT32F *pDat)
Initializes an asptSovnlms32f filter to use pre-allocated memory blocks and couples the filter to the given filter coefficients.- Returns :
-
Error code. On failure, the filterLength member of the asptSovnlms32f filter is set to zero.
- Input Parameters :
- sovnlms : pointer to asptSovnlms32f filter to be initialized
- L1 : memory length of the linear filter part
- L2 : memory length of the non-linear filter part
- muL : step size of the filter linear part
- muN : step size of the filter non-linear part
- pCof : pointer to a pre-allocated memory space of length at
least [L1 + rsum(1,L2)]to be used for storing the adaptive filter coefficients
- pDat : pointer to a pre-allocated memory block to be used
for data storage. At least [max(L1,L2)+rsum(1,L2)] memory locations must be available starting at this memory address
- Output Parameters :
- sovnlms 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 : L1/L2 is not a valid filter length
- ASPT_NO_MEM_ERR : Could not allocate the necessary filter storage
- Remarks :
-
rsum(1,L2) = 1 + 2 + ... + L2
<< Back to top
sovnlms32fFilterOnly
DT32F sovnlms32fFilterOnly (asptSovnlms32f *sovnlms, DT32F inp)
Calculates the filter output due to input sample inp and updates the internal filter states but does not update the filter coefficients. - Returns :
- Input Parameters :
- sovfir : pointer to the asptSovnlms32f filter
- inp : new input sample.
<< Back to top
sovnlms32fBlockFilterOnly
DT32S sovnlms32fBlockFilterOnly (asptSovnlms32f *sovnlms, DT32F *inp, DT32F *out, DT32S N)
filters a block of N inp samples through the asptSovnlms32f filter and stores the result in the out array without updating the filter coef. - Returns :
- Input Parameters :
- sovnlms : pointer to the asptSovnlms32f filter
- inp : array of N input samples
- Output Parameters :
- out : array of N output samples
- Error Conditions
- ASPT_NO_ERR : success
- ASPT_NULL_PTR_ERR : inp/out is a NULL pointer
<< Back to top
sovnlms32fFilterUpdate
DT32F sovnlms32fFilterUpdate (asptSovnlms32f *sovnlms, DT32F inp, DT32F des)
Calculates the filter output and updates the filter coefficients according to the second order volterra NLMS algorithm. - Returns :
- Input Parameters :
- sovfir : pointer to the asptSovnlms32f filter
- inp : new input sample
- des : new desired sample
- Remarks :
-
The error sample is stored internally and can be retrieved by calling sovnlms32fGetLastErrorSample().
<< Back to top
sovnlms32fBlockFilterUpdate
DT32S sovnlms32fBlockFilterUpdate (asptSovnlms32f *sovnlms,DT32F *inp,DT32F *des,DT32F *out,DT32F *err,DT32S N)
filters a block of N inp samples through the asptSovnlms32f filter, stores the result in the out array, and updates the filter coefficients - Returns :
- Input Parameters :
- sovnlms : pointer to the asptSovnlms32f filter
- inp : array of N input samples
- des : array of N desired samples
- N : block length
- Output Parameters :
- out : array of N output samples
- err : array of N error samples
- Error Conditions
- ASPT_NO_ERR : success
- ASPT_NULL_PTR_ERR : inp/out is a NULL pointer
<< Back to top
sovnlms32fFree
void sovnlms32fFree(asptSovnlms32f *sovnlms)
Frees the allocated memory for this asptSovnlms32f filter. - Returns :
- Input Parameters :
- sovnlms : pointer to the asptSovnlms32f filter to be de-allocated
- Remarks :
-
Use this function only with filters created with sovnlms32fInit(). Do not use with asptSovnlms32f filters created using sovnlms32fInitStatic().
<< Back to top
sovnlms32fResetDelayLine
DT32S sovnlms32fResetDelayLine(asptSovnlms32f *sovnlms)
Resets all internal filter states to zeros.- Returns :
- Input Parameters :
- sovnlms : pointer to an asptSovnlms32f filter to be reset
- Error Conditions
- ASPT_NO_ERR : success
- ASPT_NULL_PTR_ERR : sovnlms->delayLine is a NULL pointer
<< Back to top
sovnlms32fReset
DT32S sovnlms32fReset(asptSovnlms32f *sovnlms)
Resets all internal filter coefficients to zeros.- Returns :
- Input Parameters :
- sovnlms : pointer to an asptSovnlms32f filter to be reset
- Error Conditions
- ASPT_NO_ERR : success
- ASPT_NULL_PTR_ERR : sovnlms->coef is a NULL pointer
<< Back to top
sovnlms32fGetCoef
DT32S sovnlms32fGetCoef(asptSovnlms32f *sovnlms, DT32F *buf, DT32S ind, DT32S N, DT32S flip)
Copies N filter coefficients starting from coef[ind] to dstBuf. - Returns :
-
on success returns the number of coefficients copied, otherwise an error code
- Input Parameters :
- sovnlms : pointer to an asptSovnlms32f 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/sovnlms->coef is a NULL pointer
- ASPT_RANGE_ERR : ind/N is not a valid input value
<< Back to top
sovnlms32fGetLinearCoef
DT32S sovnlms32fGetLinearCoef(asptSovnlms32f *sovnlms, DT32F *buf, DT32S ind, DT32S N, DT32S flip)
Copies N linear filter coefficients starting from coef[ind] to dstBuf. - Returns :
-
on success returns the number of coefficients copied, otherwise an error code
- Input Parameters :
- sovnlms : pointer to an asptSovnlms32f 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/sovnlms->coef is a NULL pointer
- ASPT_RANGE_ERR : ind/N is not a valid input value
<< Back to top
sovnlms32fGetNonLinearCoef
DT32S sovnlms32fGetNonLinearCoef(asptSovnlms32f *sovnlms, DT32F *buf, DT32S ind, DT32S N, DT32S flip)
Copies N non-linear filter coefficients starting from coef[ind] to dstBuf. - Returns :
-
on success returns the number of coefficients copied, otherwise an error code
- Input Parameters :
- sovnlms : pointer to an asptSovnlms32f 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/sovnlms->coef is a NULL pointer
- ASPT_RANGE_ERR : ind/N is not a valid input value
<< Back to top
sovnlms32fSetCoef
DT32S sovnlms32fSetCoef(asptSovnlms32f *sovnlms, DT32F *newCoef, DT32S ind, DT32S N, DT32S flip)
Initializes the N 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 :
- sovnlms : pointer to an asptSovnlms32f 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/sovnlms->coef is a NULL pointer
- ASPT_RANGE_ERR : ind/N is not a valid input value
<< Back to top
sovnlms32fSetLinearCoef
DT32S sovnlms32fSetLinearCoef(asptSovnlms32f *sovnlms, DT32F *newCoef, DT32S ind, DT32S N, DT32S flip)
Initializes the N linear 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 :
- sovnlms : pointer to an asptSovnlms32f 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/sovnlms->coef is a NULL pointer
- ASPT_RANGE_ERR : ind/N is not a valid input value
<< Back to top
sovnlms32fSetNonLinearCoef
DT32S sovnlms32fSetNonLinearCoef(asptSovnlms32f *sovnlms, DT32F *newCoef, DT32S ind, DT32S N, DT32S flip)
Initializes the N non-linear 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 :
- sovnlms : pointer to an asptSovnlms32f 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/sovnlms->coef is a NULL pointer
- ASPT_RANGE_ERR : ind/N is not a valid input value
<< Back to top
sovnlms32fSetNonLinearDelayLine
DT32S sovnlms32fSetNonLinearDelayLine(asptSovnlms32f *sovnlms, DT32F *buf, DT32S ind, DT32S N, DT32S flip)
Initializes the N non-linear delay line samples starting from delayLine[ind] to the contents of newBuf.- Returns :
-
on success returns the number of coefficients initialized, otherwise an error code
- Input Parameters :
- sovnlms : pointer to an asptSovnlms32f filter to be set.
- newBuf : 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 : newBuf/sovnlms->delayLine is a NULL pointer
- ASPT_RANGE_ERR : ind/N is not a valid input value
<< Back to top
sovnlms32fSetLinearDelayLine
DT32S sovnlms32fSetLinearDelayLine(asptSovnlms32f *sovnlms, DT32F *buf, DT32S ind, DT32S N, DT32S flip)
Initializes the N linear delay line samples starting from delayLine[ind] to the contents of newBuf.- Returns :
-
on success returns the number of coefficients initialized, otherwise an error code
- Input Parameters :
- sovnlms : pointer to an asptSovnlms32f filter to be set.
- newBuf : 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 : newBuf/sovnlms->delayLine is a NULL pointer
- ASPT_RANGE_ERR : ind/N is not a valid input value
<< Back to top
sovnlms32fGetNonLinearDelayLine
DT32S sovnlms32fGetNonLinearDelayLine(asptSovnlms32f *sovnlms, DT32F *buf, DT32S ind, DT32S N, DT32S flip)
Copies N samples from the internal non-linear delay line starting from delayLine[ind] to dstBuf. - Returns :
-
on success returns the number of samples copied, otherwise an error code
- Input Parameters :
- sovnlms : pointer to the asptSovnlms32f 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/sovnlms->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
sovnlms32fGetLinearDelayLine
DT32S sovnlms32fGetLinearDelayLine(asptSovnlms32f *sovnlms, DT32F *buf, DT32S ind, DT32S N, DT32S flip)
Copies N samples from the internal linear delay line starting from delayLine[ind] to dstBuf. - Returns :
-
on success returns the number of samples copied, otherwise an error code
- Input Parameters :
- sovnlms : pointer to the asptSovnlms32f 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/sovnlms->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
sovnlms32fResize
DT32S sovnlms32fResize(asptSovnlms32f *sovnlms, DT32S newL1, DT32S newL2)
Resizes an asptSovnlms32f filter keeping as much of the filter state as possible. - Returns :
- Input Parameters :
- sovnlms : pointer to the asptSovnlms32f filter to be resized.
- newL1 : new number of linear coefficients
- newL2 : new non-linear memory length
- Error Conditions
- ASPT_NO_ERR : Resizing is success
- ASPT_NULL_PTR_ERR : NULL pointer error
- ASPT_RANGE_ERR : newL1/newL2 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 asptSovnlms32f filters.