Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

Overview

Computes statistics of a block of samples

Discussion

This module calculates statistics of the input signal on a block-by-block basis. The input pin can have an arbitrary number of interleaved channels and the calculation occurs over all channels. The output pin has a single channel and a blockSize of 1.

statisticsType

Description

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 block-by-block basis and stored in the instantaneousValue variable. The module is stateless and the statistic is recomputed for each block.

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. If OUTPUTVALUE=1 then the value of the statistic is output of the first output pin as a floating-point value. If OUTPUTVALUE=2 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 OUTPUTVALUE=2 only makes sense when statisticType=0 (max), 1 (min), or 2 (maxAbs).

Type Definition

typedef struct _ModuleBlockStatistics
{
    ModuleInstanceDescriptor instance;            // Common Audio Weaver module instance structure
    INT32 statisticsType;                         // Type of statistics calculated.
    FLOAT32 instantaneousValue;                   // Instantaneous output value.
} ModuleBlockStatisticsClass;

Variables

Properties

Name

Type

Usage

isHidden

Default value

Range

Units

statisticsType

int

parameter

0

0

0:9

instantaneousValue

float

state

0

0

-10:10

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_statistics_module.m

 M=block_statistics_module(NAME, OUTPUTVALUE, SAMPLERATE)
 This module calculates statistics of the input signal on a block-by-
 block basis. The type of statistics calculated is determined by
 the statisticsType parameter. The computed value is stored in the
 internal state variable instantaneousValue.  
 
 Arguments:
    NAME - name of the module.
    OUTPUTVALUE - Integer value which specifies whether the module has
         an output pin. If OUTPUTVALUE=0, then the module has no output 
         pin. If OUTPUTVALUE=1  (the default), then the instantaneousValue 
         variable is output as a single sample on the first output pin.
         If OUTPUTVALUE=2 then the module has a second output pin
         containing the index at which the value occurred.  Outputting the
         index only makes sense for Max, Min, and MaxAbs statistics.  In
         all other cases, index = -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.%

  • No labels