Document toolboxDocument toolbox

(8.D.2.7) WithinRange

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.

Type Definition

typedef struct _ModuleWithinRange { ModuleInstanceDescriptor instance; // Common Audio Weaver module instance structure FLOAT32 lower; // Lower edge of the allowable range. FLOAT32 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. } ModuleWithinRangeClass;

Variables

Properties

Name

Type

Usage

isHidden

Default value

Range

Units

lower

float

parameter

0

-0.5

-1:1

 

upper

float

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: float

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

M=within_range_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 the behavior of the module's output pin, if any. OUTPUTVALUE=0, then the module does not have an output pin. OUTPUTVALUE=1, then the output pin has size [1x1] and contains the variable .withinRange. 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.

Â