BlockStatisticsN
Overview
Computes statistics per channel on a block-by-block basis
Discussion
This module calculates statistics of the input signal on a per-channel block-by-block basis. The input pin can have an arbitrary number of interleaved channels and the calculation occurs per channel. The output pin has the same number of channels as the input and a blockSize of 1.
For each block, one of the following values is calculated: maximum, minimum, maximum absolute value, mean, RMS, standard deviation, variance, or average energy. The parameter statisticsType specifies which statistic is computed: 0=maximum, 1=minimum, 2=maximum absolute value, 3=mean, 4=RMS, 5=standard deviation, 6=variance, 7=average energy, 8=sum, 9=sum of squares. The statistic is computed on a per-channel block-by-block basis. The module is stateless and the statistic is recomputed for each block.
An optional constructor argument OUTPUTINDEX specifies whether the computed statistic index (only for Max, Min, and MaxAbs) should be output on an output pin. By default, OUTPUTINDEX=0 and the module has a single output pin containing the statistic value. If OUTPUTINDEX=1 then the module has two output pins. The first output pin is the statistic value and the second output pin is the index at which the value occurs. Using OUTPUTINDEX=1 only makes sense when statisticType=0 (Max), 1 (Min), or 2 (MaxAbs).
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 _ModuleBlockStatisticsN
{
ModuleInstanceDescriptor instance; // Common Audio Weaver module instance structure
INT32 statisticsType; // Type of statistics calculated.
} ModuleBlockStatisticsNClass;
Variables
Properties
Name | Type | Usage | isHidden | Default value | Range | Units |
statisticsType | int | parameter | 0 | 0 | 0:9 |
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: Value
Data type: float
Name: index
Description: Index
Data type: int
MATLAB Usage
File Name: block_statisticsn_module.m
M=block_statisticsn_module(NAME, OUTPUTINDEX, SAMPLERATE)
This module calculates statistics of the input signal on block-by-block basis
per channel. This is similar to block_statistics_module.m but has a multichannel
output. The type of statistics calculated is determined by the
statisticsType parameter. An optional per-channel index output for Max,
Min, and MaxAbs statistics is available.
Arguments:
NAME - name of the module.
OUTPUTINDEX - Integer value which specifies whether the module outputs
the per-channel index of the location of the Max, Min, or
MaxAbs statistic (if selected). By default, equals 0 and the module
does not output the index. Setting OUTPUTINDEX=1 causes a second
output pin to appear and this outputs the sample index.
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.