Document toolboxDocument toolbox

(8.D.2.7) WithinRangeFract32

Overview

Checks if the input signal levels are within a specified upper and lower range.

Discussion

This module determines if the input signal falls within a specified range. The range is specified by the instance variables .lower and .upper. An input sample falls within the range if (in[i] >= .lower) && (in[i] <= .upper). The instance variable .withinRange is set to 1 if all of the input samples are within range. If one or more input samples are outside of the allowable range, then .withinRange is set to 0.

The module has an optional output pin. If OUTPUTVALUE=0, then there is no output pin. If OUTPUTVALUE=1, then the output pin contains 1 sample equal to the .withinRange variable. If OUTPUTVALUE=2, then the output pin is the same size as the input pin and contains Boolean results on a sample-by-sample basis.

When the module is bypassed, the output is set to 1.

Type Definition

typedef struct _ModuleWithinRangeFract32 { ModuleInstanceDescriptor instance; // Common Audio Weaver module instance structure fract32 lower; // Lower edge of the allowable range fract32 upper; // Upper edge of the allowable range INT32 withinRange; // Equals 1 if all input samples in the block are within range. Otherwise equals 0. INT32 outputValue; // Specifies the behavior of the output pin. } ModuleWithinRangeFract32Class;

Variables

Properties

Name

Type

Usage

isHidden

Default value

Range

Units

lower

fract32

parameter

0

-0.5

-1:1

 

upper

fract32

parameter

0

0.5

-1:1

 

withinRange

int

state

0

0

Unrestricted

 

outputValue

int

const

0

1

Unrestricted

 

Pins

Input Pins

Name: in

Description: audio input

Data type: fract32

Channel range: Unrestricted

Block size range: Unrestricted

Sample rate range: Unrestricted

Complex support: Real

Output Pins

Name: out

Description: Boolean

Data type: int

MATLAB Usage

File Name: within_range_fract32_module.m

M=within_range_fract32_module(NAME, OUTPUTVALUE) This module determines if the input signal falls within a specified range [.lower .upper]. The module sets an internal Boolean variable .withinRange to 1 if (input >= .lower) and (input <= .upper). If the input signal is not within the allowable range, then .withinRange is set to 0. Arguments: NAME - name of the module. OUTPUTVALUE - specifies whether the behavior of the module's output pin, if any. OUTPUTVALUE=0, then the module does not have an output pin. If OUTPUTVALUE=1, then the output pin has size [1x1] and contains the variable .withinRange. If OUTPUTVALUE=2, then the output pin is the same dimension as the input pin and contains a sample-by-sample Boolean value. By default, OUTPUTVALUE=0. The variable .withinRange is set based on whether all samples in the input pin are within the allowable range.

Â