Skip to main content
Skip table of contents

ScalerSmoothedFract32

Overview

Linear multichannel smoothly varying scaler

Discussion

Scales all input channels by a single gain value. Changes to the gain parameter are exponentially smoothed (first order IIR) at the sample rate, with the time constant determined by the smoothingTime parameter. This module is controlled by varying the gain variable. Internally, currentGain represents the instantaneous smoothed gain that is applied. currentGain exponentially approaches gain with a time constant equal to smoothingTime.

The module's prebuild function initializes the currentGain equal to the gain. Thus, the module begins in a converged state. The module supports fract32 data types. The processing function is implemented using a fractional multiply (smoothed) followed by a fixed bit shift of the result. The number of bits to shift is based on .gain.range. You should set .gain.range near the expected operating values. Otherwise, if .gain.range is too large, you will lose some bits of precision in the final result. Note also that .gain.range must be set prior to building the system since the computation of the bit shift occurs in the prebuild function.

Type Definition

CODE
typedef struct _ModuleScalerSmoothedFract32
{
    ModuleInstanceDescriptor instance;            // Common Audio Weaver module instance structure
    FLOAT32 gain;                                 // Target gain
    FLOAT32 smoothingTime;                        // Time constant of the smoothing process
    fract32 targetGain;                           // Desired (or target) of the fractional portion of the overall scaling. This is also the starting gain of the module.
    fract32 currentGain;                          // Instantaneous gain applied by the module. This is also the starting gain of the module.
    fract32 smoothingCoeff;                       // Smoothing coefficient
    INT32 postShift;                              // Number of bits to shift after the fractional multiply. This is based on gain.range.
    FLOAT32 twoPowMinusPostShift;                 // 2^(-postShift). Used by to streamline the operation of the set function
} ModuleScalerSmoothedFract32Class;

Variables

Properties

Name

Type

Usage

isHidden

Default value

Range

Units

gain

float

parameter

0

1

-10:10

linear

smoothingTime

float

parameter

0

10

0:1000

msec

targetGain

fract32

derived

1

0.0625

Unrestricted

currentGain

fract32

state

1

0.0625

-10:10

linear

smoothingCoeff

fract32

derived

1

0.002081

Unrestricted

postShift

int

derived

1

4

Unrestricted

twoPowMinusPostShift

float

derived

1

0.0625

Unrestricted

Pins

Input Pins

Name: in1

Description: audio input

Data type: fract32

Channel range: Unrestricted

Block size range: Unrestricted

Sample rate range: Unrestricted

Complex support: Real and Complex

Output Pins

Name: out1

Description: audio output

Data type: fract32

MATLAB Usage

File Name: scaler_smoothed_fract32_module.m

CODE
 M=scaler_smoothed_fract32_module(NAME, NUMPINS)
 Creates a smoothly varying scaler module with a single input
 and single output pin.  This module operates on fract32
 data signals.  Arguments:
    NAME - name of the module.
    NUMPINS - Number of pins

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.