(8.D.2.3) RunningStatisticsN
Overview
Computes long term statistics per channel
Discussion
This module is a multichannel version of the RunningStatisics module. The module keeps track of the statistics of the input data. The state variable value holds the statistic result seen thus far since the module start processing. A separate statistic is computed for each input channel.
The statisticsType variable configures which type of computation the block does: 0=Maximum, 1=Minimum, 2=Maximum Absolute Value, Sum=3, Mean=4, RMS=5, StdDev=6, Var=7, AvgEnergy=8.
An optional constructor argument OUTPUTVALUE specifies whether the computed statistic should be output on an output pin. By default, OUTPUTVALUE=0 and the statistic is only stored internally in instantaneousValue. The .reset variable is used to clear history and restart the calculation. The variable .reset is set to 1 when the module is first constructed.
By default, the sample rate of the output pin equals SRin / blocksize. There are some times when this computes the wrong sample rate and you can overwrite the output sample rate using the SAMPLERATE argument.
Type Definition
typedef struct _ModuleRunningStatisticsN
{
ModuleInstanceDescriptor instance; // Common Audio Weaver module instance structure
INT32 statisticsType; // Type of statistics needed.
INT32 numBlocksProcessed; // Counter for the number of blocks processed.
INT32 reset; // Used to identify the first block which is processed.
FLOAT32* value; // Instantaneous output value.
FLOAT32* mean; // State variable for mean.
FLOAT32* avgEnergy; // State variable for average energy.
} ModuleRunningStatisticsNClass;
Variables
Properties
Name | Type | Usage | isHidden | Default value | Range | Units |
statisticsType | int | parameter | 0 | 0 | 0:8 | Â |
numBlocksProcessed | int | state | 0 | 0 | Unrestricted | Â |
reset | int | state | 0 | 1 | Unrestricted | Â |
value | float* | state | 0 | [1 x 1] | Unrestricted | Â |
mean | float* | state | 0 | [1 x 1] | Unrestricted | Â |
avgEnergy | float* | state | 0 | [1 x 1] | Unrestricted | Â |
Pins
Input Pins
Name: in
Description: Audio input
Data type: float
Channel range: Unrestricted
Block size range: Unrestricted
Sample rate range: Unrestricted
Complex support: Real
Output Pins
Name: out
Description: Audio input
Data type: float
Scratch Pins
Channel count: 1
Block size: 32
Sample rate: 48000
MATLAB Usage
File Name: running_statisticsn_module.m
M = running_statisticsn_module(NAME, OUTPUTVALUE, SAMPLERATE)
This is a multichannel version of the running_statistics_module.m.
It computes a per channel statistic of the wire data and the
statistic is tracked from system startup. The module stores the
compute statistic in an N element internal array. The module can
also output on an N channel control wire.
Arguments:
NAME - name of the module.
OUTPUTVALUE - Boolean value which specifies whether the module has
an output pin. If OUTPUTVALUE=0 (the default), then
the module has no output pin. If OUTPUTVALUE=1, then
the module has a multichannel control pin (block size = 1).
SAMPLERATE - optional argument which specifies the output sample rate
of the module. By default, this is empty and the output sample
rate is computed as inputSampleRate / blockSize. In some cases,
this sample rate is wrong and you can override it with this
argument.
Â