(8.D.2.3) RunningStatistics
Overview
Computes long term statistics
Discussion
This module keeps track of the statistics of the input data. The state variable value holds the statistic result seen thus far.
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.
Type Definition
typedef struct _ModuleRunningStatistics
{
ModuleInstanceDescriptor instance; // Common Audio Weaver module instance structure
INT32 statisticsType; // Type of statistics needed.
FLOAT32 value; // Instantaneous output value.
FLOAT32 mean; // State variable for mean.
FLOAT32 avgEnergy; // State variable for average energy.
INT32 numBlocksProcessed; // Counter for the number of blocks processed.
INT32 reset; // Used to identify the first block which is processed.
} ModuleRunningStatisticsClass;
Variables
Properties
Name | Type | Usage | isHidden | Default value | Range | Units |
statisticsType | int | parameter | 0 | 0 | 0:8 | Â |
value | float | state | 0 | 0 | Unrestricted | Â |
mean | float | state | 0 | 0 | Unrestricted | Â |
avgEnergy | float | state | 0 | 0 | Unrestricted | Â |
numBlocksProcessed | int | state | 0 | 0 | Unrestricted | Â |
reset | int | state | 0 | 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: State value output
Data type: float
MATLAB Usage
File Name: running_statistics_module.m
M=running_statistics_module(NAME, OUTPUTVALUE)
This module keeps track of some of the statistics of the
input and stores this to the internal state variable value. The
module uses all samples since the start of processing. A number of
different statistics can be calculated based on the statisticsType
parameter.
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 value variable is output as a single sample on the
output pin.
Â