LIBML
Version 3.2.4
LIBML DSP Software Library
|
Functions | |
void | tpt_lms_norm_f32 (f32_t *aOutData, f32_t *aErrData, tpt_lms_norm_f32_t *aFilter, const f32_t *aInData, const f32_t *aRefData, uint32_t aCount) |
Processing function for floating-point normalized LMS filter. More... | |
void | tpt_lms_norm_init_f32 (tpt_lms_norm_f32_t *aFilter, uint16_t aTaps, f32_t *aCoeffs, f32_t *aState, f32_t aMu, uint32_t aCount) |
Initialization function for floating-point normalized LMS filter. More... | |
void | tpt_lms_norm_init_q15 (tpt_lms_norm_q15_t *aFilter, uint16_t aTaps, q15_t *aCoeffs, q15_t *aState, q15_t aMu, uint32_t aCount, uint8_t aShift) |
Initialization function for Q15 normalized LMS filter. More... | |
void | tpt_lms_norm_init_q31 (tpt_lms_norm_q31_t *aFilter, uint16_t aTaps, q31_t *aCoeffs, q31_t *aState, q31_t aMu, uint32_t aCount, uint8_t aShift) |
Initialization function for Q31 normalized LMS filter. More... | |
void | tpt_lms_norm_q15 (q15_t *aOutData, q15_t *aErrData, tpt_lms_norm_q15_t *aFilter, const q15_t *aInData, const q15_t *aRefData, uint32_t aCount) |
Initialization function for Q15 normalized LMS filter. More... | |
void | tpt_lms_norm_q31 (q31_t *aOutData, q31_t *aErrData, tpt_lms_norm_q31_t *aFilter, const q31_t *aInData, const q31_t *aRefData, uint32_t aCount) |
Initialization function for Q31 normalized LMS filter. More... | |
This set of functions implements a commonly used adaptive filter. It is related to the Least Mean Square (LMS) adaptive filter and includes an additional normalization factor which increases the adaptation rate of the filter. The DSP Library only contains normalized LMS filter functions that operate on floating-point data types.
A normalized least mean square (NLMS) filter consists of two components as shown below. The first component is a standard transversal or FIR filter. The second component is a coefficient update mechanism. The NLMS filter has two input signals. The "input" feeds the FIR filter while the "reference input" corresponds to the desired output of the FIR filter. That is, the FIR filter coefficients are updated so that the output of the FIR filter matches the reference input. The filter coefficient update mechanism is based on the difference between the FIR filter output and the reference input. This "error signal" tends towards zero as the filter adapts. The NLMS processing functions accept the input and reference input signals and generate the filter output and error signal.
The functions operate on blocks of data and each call to the function processes aCount
samples through the filter. aInData
points to input signal, aRefData
points to reference signal, aOutData
points to output signal and aErrData
points to error signal. All arrays contain aCount
values.
The functions operate on a block-by-block basis. Internally, the filter coefficients b[n]
are updated on a sample-by-sample basis. The convergence of the LMS filter is slower compared to the normalized LMS algorithm.
y[n]
is computed by a standard FIR filter: y[n] = b[0] * x[n] + b[1] * x[n - 1] + b[2] * x[n - 2] + ... + b[uTaps - 1] * x[n - uTaps + 1]
d[n]
and the filter output: e[n] = d[n] - y[n].
E = x[n] ^ 2 + x[n - 1] ^ 2 + ... + x[n - uTaps + 1] ^ 2.The filter coefficients
b[k]
are then updated on a sample-by-sample basis: b[k] = b[k] + e[n] * (fMu / E) * x[n - k], for k = 0, 1, ..., uTaps - 1where
fMu
is the step size and controls the rate of coefficient convergence. pCoeffs
points to a coefficient array of size uTaps
. Coefficients are stored in time reversed order. { b[uTaps - 1], b[uTaps - 2], ..., b[1], b[0] }
pState
points to a state array of size uTaps + aCount - 1
. Samples in the state buffer are stored in the order: { x[n - uTaps + 1], x[n - uTaps], x[n - uTaps - 1], ..., x[0], x[1], x[2], ..., x[aCount - 1] }
aCount - 1
samples. The increased state buffer length allows circular addressing, which is traditionally used in FIR filters, to be avoided and yields a significant speed improvement. The state variables are updated after each block of data is processed.void tpt_lms_norm_f32 | ( | f32_t * | aOutData, |
f32_t * | aErrData, | ||
tpt_lms_norm_f32_t * | aFilter, | ||
const f32_t * | aInData, | ||
const f32_t * | aRefData, | ||
uint32_t | aCount | ||
) |
Processing function for floating-point normalized LMS filter.
[out] | aOutData | points to the block of output data. |
[out] | aErrData | points to the block of error data. |
[in] | aFilter | points to an instance of the floating-point normalized LMS filter structure. |
[in] | aInData | points to the block of input data. |
[in] | aRefData | points to the block of reference data. |
[in] | aCount | number of samples to process |
void tpt_lms_norm_init_f32 | ( | tpt_lms_norm_f32_t * | aFilter, |
uint16_t | aTaps, | ||
f32_t * | aCoeffs, | ||
f32_t * | aState, | ||
f32_t | aMu, | ||
uint32_t | aCount | ||
) |
Initialization function for floating-point normalized LMS filter.
[in] | aFilter | points to an instance of the floating-point LMS filter structure. |
[in] | aTaps | number of filter coefficients |
[in] | aCoeffs | points to coefficient buffer. |
[in] | aState | points to state buffer. |
[in] | aMu | step size that controls filter coefficient updates |
[in] | aCount | number of samples to process |
aCoeffs
points to the array of filter coefficients stored in time reversed order: { b[aTaps-1], b[aTaps-2], b[N-2], ..., b[1], b[0] }The initial filter coefficients serve as a starting point for the adaptive filter.
aState
points to an array of length aTaps + aCount - 1
samples, where aCount
is the number of input samples processed by each call to tpt_lms_norm_f32()
. void tpt_lms_norm_init_q15 | ( | tpt_lms_norm_q15_t * | aFilter, |
uint16_t | aTaps, | ||
q15_t * | aCoeffs, | ||
q15_t * | aState, | ||
q15_t | aMu, | ||
uint32_t | aCount, | ||
uint8_t | aShift | ||
) |
Initialization function for Q15 normalized LMS filter.
[in] | aFilter | points to an instance of the Q15 LMS filter structure. |
[in] | aTaps | number of filter coefficients |
[in] | aCoeffs | points to coefficient buffer. |
[in] | aState | points to state buffer. |
[in] | aMu | step size that controls filter coefficient updates |
[in] | aCount | number of samples to process |
[in] | aShift | bit shift applied to coefficients |
aCoeffs
points to the array of filter coefficients stored in time reversed order: { b[aTaps-1], b[aTaps-2], b[N-2], ..., b[1], b[0] }The initial filter coefficients serve as a starting point for the adaptive filter.
aState
points to an array of length aTaps + aCount - 1
samples, where aCount
is the number of input samples processed by each call to tpt_lms_norm_f32()
. void tpt_lms_norm_init_q31 | ( | tpt_lms_norm_q31_t * | aFilter, |
uint16_t | aTaps, | ||
q31_t * | aCoeffs, | ||
q31_t * | aState, | ||
q31_t | aMu, | ||
uint32_t | aCount, | ||
uint8_t | aShift | ||
) |
Initialization function for Q31 normalized LMS filter.
[in] | aFilter | points to an instance of the Q31 LMS filter structure. |
[in] | aTaps | number of filter coefficients |
[in] | aCoeffs | points to coefficient buffer. |
[in] | aState | points to state buffer. |
[in] | aMu | step size that controls filter coefficient updates |
[in] | aCount | number of samples to process |
[in] | aShift | bit shift applied to coefficients |
aCoeffs
points to the array of filter coefficients stored in time reversed order: { b[aTaps-1], b[aTaps-2], b[N-2], ..., b[1], b[0] }The initial filter coefficients serve as a starting point for the adaptive filter.
aState
points to an array of length aTaps + aCount - 1
samples, where aCount
is the number of input samples processed by each call to tpt_lms_norm_f32()
. void tpt_lms_norm_q15 | ( | q15_t * | aOutData, |
q15_t * | aErrData, | ||
tpt_lms_norm_q15_t * | aFilter, | ||
const q15_t * | aInData, | ||
const q15_t * | aRefData, | ||
uint32_t | aCount | ||
) |
Initialization function for Q15 normalized LMS filter.
Processing function for Q15 normalized LMS filter.
[in] | aFilter | points to an instance of the Q15 LMS filter structure. |
[in] | aTaps | number of filter coefficients |
[in] | aCoeffs | points to coefficient buffer. |
[in] | aState | points to state buffer. |
[in] | aMu | step size that controls filter coefficient updates |
[in] | aCount | number of samples to process |
[in] | aShift | bit shift applied to coefficients |
void tpt_lms_norm_q31 | ( | q31_t * | aOutData, |
q31_t * | aErrData, | ||
tpt_lms_norm_q31_t * | aFilter, | ||
const q31_t * | aInData, | ||
const q31_t * | aRefData, | ||
uint32_t | aCount | ||
) |
Initialization function for Q31 normalized LMS filter.
Processing function for Q31 normalized LMS filter.
[in] | aFilter | points to an instance of the Q31 LMS filter structure. |
[in] | aTaps | number of filter coefficients |
[in] | aCoeffs | points to coefficient buffer. |
[in] | aState | points to state buffer. |
[in] | aMu | step size that controls filter coefficient updates |
[in] | aCount | number of samples to process |
[in] | aShift | bit shift applied to coefficients |