Document toolboxDocument toolbox

Averager

Overview

Advanced multichannel averager

Discussion

Intelligent averager module which avoids the startup transient. When the module starts it uses a cumulative averaging method and then later on switches to exponential averaging. The .smoothingTime variable determines the averaging interval. Cumulative averaging lasts for .smoothingTime msec and when this is done the module switches to exponential averaging.

The module supports multichannel inputs and separately computes the average for each channel. That is, if the input has N channels then the output will also have N channels. The average is computed on a sample by sample basis.

The module has an optional reset pin which is enabled using the RESETPIN argument. The module checks the first sample of data on the reset pin and if non-zero restarts averaging. The module starts in cumulative averaging mode and then switches to exponential averaging.

Type Definition

typedef struct _ModuleAverager { ModuleInstanceDescriptor instance; // Common Audio Weaver module instance structure FLOAT32 smoothingTime; // Time constant of the smoothing process. FLOAT32 smoothingCoeff; // Smoothing coefficient. INT32 sampleCounter; // Number of samples processed since last reset. INT32 switchCount; // When to switch from cumulative to exponential averaging. INT32 stateSize; // Size of the state array derived from input pin. FLOAT32* state; // Instantaneous average value. } ModuleAveragerClass;

Variables

Properties

Name

Type

Usage

isHidden

Default value

Range

Units

smoothingTime

float

parameter

0

100

0:1:10000

msec

smoothingCoeff

float

derived

1

0.0002083

Unrestricted

 

sampleCounter

int

state

1

0

Unrestricted

 

switchCount

int

derived

1

4800

Unrestricted

 

stateSize

int

state

1

1

Unrestricted

 

state

float*

state

0

[1 x 1]

Unrestricted

 

Pins

Input Pins

Name: reset

Description: Resets averaging

Data type: int

Channel range: 1

Block size range: Unrestricted

Sample rate range: Unrestricted

Complex support: Real

 

Name: in

Description: Input signal

Data type: float

Channel range: Unrestricted

Block size range: Unrestricted

Sample rate range: Unrestricted

Complex support: Real

Output Pins

Name: out

Description: Output signal

Data type: float

MATLAB Usage

File Name: averager_module.m

M = averager_module(NAME, RESETPIN) Advanced averager module which eliminates the startup transient. The module separately averages each input channel. Arguments: NAME - name of the module. RESETPIN - optional Boolean variable that specifies if the module has a reset pin. By default RESETPIN = 0.

Â