(8.D.2.7) SbKalmanAECStereoV1
Overview
Frequency domain stereo subband Kalman filter
Discussion
Subband Kalman based stereo echo canceler with support for multiple input channels.
I/O Pins
This module works in conjunction with the WOLA filterbank modules and accepts complex data. The default module has two input pins, and one output pin. The first input can have any number of microphone signals, while the second is the stereo reference signal. The reference signals and states are shared among the microphones, saving memory and MIPS over using several instances. The error output pin will have one channel per microphone input.
User Parameters
At instantiation time the maximum number of taps must be defined. The number of taps actually used is the parameter numTaps, found in the module inspector or the module properties view. numTaps allows you to vary the filter length at runtime to verify performance and CPU load.
The module has optional residual noise suppression which is enabled via the enableRNS variable. By default, residual noise suppression is on and the output of the echo canceler (the error signal) is further reduced in level. The residual noise suppression is configured by a 7 element interpolation table. This table operates just like the Table X-Y module with configurable (X, Y) lookup points. The lookup table specifies values in dB for the input and output function
The p0 variable is used to initialize the P and PXTerm arrays at startup time and during any reset events triggered by the optional input pins. p0 defaults to 1.0. Changing this value during runtime will automatically reset P and PXTerm to the new value.
The smoothingTime variable, with units of seconds, is a state transition factor analogous to the leakage factor in a leaky lms algorithm. It defaults to 30, which has a convergence time roughly equivalent to a setting of 100 in the deprecated SbStereoAECV1 module.
The FFTSize parameter is set at instantiation and used to calculate an internal adaptation constant. This is normally the FFT size of the WOLA Analysis module upstream of this module. FFTSize is often (blocksize-1) * 2 unless sub bands are split to multiple AECs.
Optional Input Pins
Three additional input pins will be added to the module if the resetPinsEn module argument is set to true. These control pins can be used to modify the behavior of the module during runtime, as described below:
resetP: This pin has one INT32 value per microphone channel. If the value is not zero, then that microphone's P and PXTerm arrays will be reset to the current p0 value each pump.
masterReset: This pin has only a single INT32 value and one channel. If the value is not zero, then all internal states and weight arrays will be reset to their default values for all microphone channels. This includes the P and PXTerm arrays.
freeze: This pin has one INT32 value per microphone channel. If the value is not zero, then the adaptation stage of the filter will not run for that channel. The existing weights will continue to be applied, but they will not be updated again until the freeze is set to zero. This does not include the RNS weights since they are highly dependent on reference levels.
Optional Output Pins
Three module arguments can be used to add additional output pins, which can be useful for debugging purposes.
outputRNSWeights: Enabling this will output the RNS weights (the W2 array) on an output pin. The output pin will have one channel per microphone. The W2 weights are real and there is one value per input bin. If this pin is enabled, then the W2 weights are not applied to the output error signal.
outputAECWeights: This argument will output the AEC weights (the WW1 array) on an output pin if set to true. This output pin will have 2 * maxtaps channels of numBins per mic input. The WW1 weights are complex, and they are ordered [t1r1c1 t1r1c2 ... t1r2c1 t1r2c2 ... tTrRcC tTrRcC], where r1 is ref channel 1, r2 is ref channel 2, t# is tap number, T is maxTaps and c/C is the mic channel number and max mic channels respectively.
outputPVals: If set to true, this argument will enable two additional output pins - one for the P array, and another for the PXTerm array. Both output pins will have one channel per microphone input.
The P array is all real values, and is ordered per channel as [b1t1c1 b1t1c2 b1t2c1 b1t2c2 ... b1tTc2 b2t1c1 b2t1c2 ... bBtTc1 bBtTc2], where c1 is ref channel 1, c2 is ref channel 2, t# is tap number, T is maxTaps, b# is bin number, and B is number of input bins.
The PXTerm array is complex, and is ordered per channel as [b1t1 b1t2 ... b1tT b2t1 b2t2 ... bBtT], where t# is tap number, T is maxTaps, b# is bin number, and B is number of input bins.
Type Definition
typedef struct _ModuleSbKalmanAECStereoV1
{
ModuleInstanceDescriptor instance; // Common Audio Weaver module instance structure
INT32 maxTaps; // Maximum length of the filter
INT32 numTaps; // Current length of the filter
FLOAT32 V; // Adaptation constant based on num taps and fft size
FLOAT32 smoothingTime; // Time constant of the smoothing process.
FLOAT32 A; // Smoothing factor
FLOAT32 p0; // Starting value for covariance estimate
INT32 enableRNS; // Enable residual noise suppression
INT32 firstRun; // First run for setting P from p0 on startup
FLOAT32 FFTSize; // FFT Size used for input bins. Can differ from input block size.
INT32 enableW2Output; // tracker for rns weight output enable
INT32 enableWOutput; // tracker for aec weight output enable
INT32 enablePVOutput; // tracker for rns weight output enable
INT32 enableControlInputs; // tracker for input control pin enable
INT32 scratchIndex; // tracker for which pin scratch is on
INT32 stateIndex; // Circular buffer index. [0 numTaps-1]
INT32 RNS_numPoints; // Number of values in the lookup table. The total table size is [maxPoints 2].
INT32 RNS_order; // Order of the interpolation. This can be either 2 (for linear) or 4 (for pchip).
FLOAT32* WW1; // Adaptive filter coefficients.
FLOAT32* P; // Real estimation error covariance matrix.
FLOAT32* PXTerm; // Estimation error covariance matrix - the off-diagonal terms.
FLOAT32* CC; // Complex state variables (previous inputs).
FLOAT32* corrC; // Stores all the correlation between reference signals per bin and tap - diagonal part. Real number.
FLOAT32* corrCXTerm; // Correlation between ref channels - the off-diagonal terms.
FLOAT32* W2; // Residual noise suppression weights.
FLOAT32* RNS_table; // Lookup table. The first row is the X values and the second row is the Y values.
FLOAT32* RNS_polyCoeffs; // Interpolation coefficients returned by the grid control.
} ModuleSbKalmanAECStereoV1Class;
Variables
Properties
Name | Type | Usage | isHidden | Default value | Range | Units |
maxTaps | int | const | 0 | 16 | Unrestricted | samples |
numTaps | int | parameter | 0 | 16 | 1:1:16 | samples |
V | float | derived | 0 | 1.0302 | Unrestricted | Â |
smoothingTime | float | parameter | 0 | 30 | 0.1:1000 | seconds |
A | float | derived | 0 | 1 | 0:1 | Â |
p0 | float | parameter | 0 | 1 | Unrestricted | Â |
enableRNS | int | parameter | 0 | 1 | 0:1:1 | Â |
firstRun | int | state | 0 | 0 | Unrestricted | Â |
FFTSize | float | derived | 1 | 512 | Unrestricted | Â |
enableW2Output | int | const | 1 | 0 | Unrestricted | Â |
enableWOutput | int | const | 1 | 0 | Unrestricted | Â |
enablePVOutput | int | const | 1 | 0 | Unrestricted | Â |
enableControlInputs | int | const | 1 | 0 | Unrestricted | Â |
scratchIndex | int | const | 1 | 3 | Unrestricted | Â |
stateIndex | int | state | 1 | 0 | Unrestricted | Â |
RNS_numPoints | int | const | 1 | 7 | 4:1:1000 | Â |
RNS_order | int | const | 1 | 2 | 2:2:4 | Â |
WW1 | float* | state | 0 | [1024 x 1] | Unrestricted | Â |
P | float* | state | 0 | [1024 x 1] | Unrestricted | Â |
PXTerm | float* | state | 0 | [512 x 1] | Unrestricted | Â |
CC | float* | state | 0 | [32 x 32] | Unrestricted | Â |
corrC | float* | state | 0 | [32 x 32] | Unrestricted | Â |
corrCXTerm | float* | state | 0 | [16 x 32] | Unrestricted | Â |
W2 | float* | state | 0 | [32 x 1] | Unrestricted | Â |
RNS_table | float* | parameter | 1 | [2 x 7] | Unrestricted | Â |
RNS_polyCoeffs | float* | state | 1 | [4 x 6] | Unrestricted | Â |
Pins
Input Pins
Name: dataIn
Description: Mic inputs
Data type: float
Channel range: Unrestricted
Block size range: Unrestricted
Sample rate range: Unrestricted
Complex support: Complex
Â
Name: reference
Description: Stereo reference input
Data type: float
Channel range: 2
Block size range: Unrestricted
Sample rate range: Unrestricted
Complex support: Complex
Output Pins
Name: errorSignal
Description: Error signal = difference between filter output and each channels data input
Data type: float
Scratch Pins
Channel count: 1
Block size: 86
Sample rate: 48000
MATLAB Usage
File Name: sb_kalman_aec_stereo_v1_module.m
M = sb_kalman_aec_stereo_v1_module(NAME, MAXTAPS, FFTSIZE, RESETPINSENABLE, OUTPUTRNSWEIGHTS, OUTPUTAECWEIGHTS, OUTPUTPVALS)
Frequency domain subband stereo echo canceler using a Kalman filter based
algorithm. Arguments:
NAME - name of the module.
MAXTAPS - maximum length of each frequency domain complex adaptive filter
FFTSIZE - fft size used for input data (typically (# WOLA
subbands-1)*2
RESETPINSENABLE - creates 3 optional input pins for controlling behavior of module.
- The resetP pin resets all P and PXTerm values to initial p0 value
- The masterReset pin resets all internal states to initial values (including P) for all channels
- The freeze pin can freeze the adaptation in the filter. Current weights are still applied
OUTPUTRNSWEIGHTS - optional output pin for RNS weights
OUTPUTAECWEIGHTS - optional output pin for AEC weights
OUTPUTPVALS - optional output pin for P values
Copyright 2020. DSP Concepts, Inc. All Rights Reserved.
----------------------------------------------------------------------
Set default input arguments
----------------------------------------------------------------------
Â