(8.D.2.7) ScalerV2
Overview
General purpose scaler with a single gain
Discussion
General purpose scaler (or gain) module for floating-point signals. This module has a single parameter "gain" which specifies the gain to apply. The same gain is applied to all channels.
Gain is intrepreted as either a linear value or as a dB value based on the isDB module variable. By default, isDB=1 and the gain parameter is treated as a dB value. If you set isDB=0 then the gain parameter is treated as a linear value.
The module can also switch between smoothed and unsmoothed gain changes. You enable smoothing by setting the parameter smoothingTime to a non-zero value. If smoothingTime=0 then no smoothing is performed. The module is slightly more efficient when no smoothing occurs.
The module supports multiple input and output pins using the argument NUMPINS. By default, NUMPINS=1 and the module has a single input and output pin. If you set NUMPINS > 1 then you can scale multiple signals. The same gain variable is used across signals.
By default the module has no control pin and the gain is taken from the instance variable .gain. The second argument ISCONTROL to scaler_v2_module.m controls whether the module has an input control pin. By default ISCONTROL = 0 and the module is not controllable. If you set ISCONTROL then the module will have one extra input pin. In this case, the gain is taken from the first input pin. The control pin accepts only mono wires and the gain is taken from the first sample in the buffer. The total gain applied is then a combination of the value on the control pin and the .gain parameter. For dB gains, the total gain applied is controlPinValue + M.gain. For linear gains, the total gain applied is controlPinValue * M.gain.
The description above applies to real data. The module can also handle complex data but in the case of complex data no smoothing is performed and the gain value is applied to both the real and imaginary parts.
Type Definition
typedef struct _ModuleScalerV2
{
ModuleInstanceDescriptor instance; // Common Audio Weaver module instance structure
FLOAT32 gain; // Gain in either linear or dB units.
FLOAT32 smoothingTime; // Time constant of the smoothing process (0 = unsmoothed).
INT32 isDB; // Selects between linear (=0) and dB (=1) operation
FLOAT32 targetGain; // Target gain in linear units.
FLOAT32 currentGain; // Instantaneous gain applied by the module.
FLOAT32 smoothingCoeff; // Smoothing coefficient.
} ModuleScalerV2Class;
Variables
Properties
Name | Type | Usage | isHidden | Default value | Range | Units |
gain | float | parameter | 0 | 0 | -24:24 | dB |
smoothingTime | float | parameter | 0 | 10 | 0:1000 | msec |
isDB | int | parameter | 0 | 1 | 0:1 | Â |
targetGain | float | derived | 1 | 1 | Unrestricted | Â |
currentGain | float | state | 1 | 0 | Unrestricted | Â |
smoothingCoeff | float | derived | 1 | 0.002081 | Unrestricted | Â |
Pins
Input Pins
Name: gain
Description:
Data type: float
Channel range: 1
Block size range: Unrestricted
Sample rate range: Unrestricted
Complex support: Real
Â
Name: in1
Description: audio input
Data type: float
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: float
MATLAB Usage
File Name: scaler_v2_module.m
M = scaler_v2_module(NAME, ISCONTROL, NUMPINS)
General purpose scaler module with a single gain applied across all
channels. The module can be configured for linear or dB operation
as well as smoothed and unsmoothed gain changes. Arguments:
NAME - name of the module.
ISCONTROL - Boolean. Does the module have a control pin for the gain.
Default = 0 and the gain to apply is taken from the
inspector.
NUMPINS - number of input pins. Default = 1.
Â