(8.D.2.6) LMS
Overview
Normalized LMS FIR filter
Discussion
The LMS module implements a single channel N-order FIR adaptive filter. The module takes 2 single channel inputs: desired filter output and filter input (the reference signal). For every data sample the filter output is compared to the desired output and this information is used to update the filter taps according to the normalized LMS algorithm. The module always has 2 single channel ouputs: adaptive filter output and error signal, (desired filter output - actual filter output. The module also optionally outputs the filter coefficients on a third output pin. The array coeffs holds the filter coefficients and is of size numTaps x 1. The coefficients are stored in normal order. The state variable array is of size numTaps x 1. The adaptation constant mu is visible as a parameter.
Type Definition
typedef struct _ModuleLMS
{
ModuleInstanceDescriptor instance; // Common Audio Weaver module instance structure
INT32 maxTaps; // Maximum length of the filter
INT32 numTaps; // Current length of the filter
FLOAT32 mu; // Adaptation constant
INT32 stateIndex; // Index of the oldest state variable in the array of state variables
FLOAT32* coeffs; // Coefficient array
FLOAT32* state; // State variable array
} ModuleLMSClass;
Variables
Properties
Name | Type | Usage | isHidden | Default value | Range | Units |
maxTaps | int | const | 0 | 1024 | 1:1:5000 | samples |
numTaps | int | parameter | 0 | 32 | 1:1:1024 | samples |
mu | float | parameter | 0 | 0 | 0:1 | linear |
stateIndex | int | state | 1 | 0 | Unrestricted | Â |
coeffs | float* | parameter | 0 | [1024 x 1] | Unrestricted | Â |
state | float* | state | 1 | [1027 x 1] | Unrestricted | Â |
Pins
Input Pins
Name: dataIn
Description: Filter input
Data type: float
Channel range: 1
Block size range: Unrestricted
Sample rate range: Unrestricted
Complex support: Real
Â
Name: reference
Description: Reference input: desired filter output
Data type: float
Channel range: 1
Block size range: Unrestricted
Sample rate range: Unrestricted
Complex support: Real
Output Pins
Name: dataOut
Description: Filter output
Data type: float
Â
Name: errorSignal
Description: Error signal = difference between filter output and reference input
Data type: float
Â
Name: coeffs
Description: Filter coefficients
Data type: float
MATLAB Usage
File Name: lms_module.m
M=lms_module(NAME, MAXTAPS, OUTPUTCOEFFS)
Creates a normalized LMS FIR filter for use in the Audio Weaver environment.
The module has 2 single channel input pins and up to 3 single channel
output pins:
Input Pin 1: dataIn - Adaptive filter desired output
Input Pin 2: reference - Adaptive filter input
Output Pin 1: dataOut - output of the adaptive filter
Output Pin 2: errorSignal - difference between dataIn and dataOut
Output Pin 3: Coefficients (optional)
Arguments:
NAME - name of the module.
MAXTAPS - maximum length of the filter (number of taps).
OUTPUTCOEFFS - Boolean which specifies whether a third output
pin holding the coefficients should be added. By default,
OUTPUTCOEFFS=0.
Â