(8.D.2.5) ScalerSymmetricFading
Overview
General purpose scaler with a single gain and a fading time in which the fadein/fadeout needs to be accomplished
Discussion
Scaler (or gain) module for floating-point signals with symmetric fading time and gain as control parameters. Compared to the general purpose scaler, the fadein and fadeout takes equal time as parameter fadingTime. This module has a parameter name "gain" which specifies the gain to apply. The same gain is applied to all channels.
Gain is interpreted 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. Make sure that linear gain is not negative.
The module can also switch between smoothed and unsmoothed gain changes. You enable smoothing by setting the parameter fadingTime to a non-zero value. If fadingTime=0 then no smoothing is performed. The module is slightly more efficient when no smoothing occurs. A linear gain of 0 corresponds to -200dB. 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. 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 _ModuleScalerSymmetricFading
{
ModuleInstanceDescriptor instance; // Common Audio Weaver module instance structure
FLOAT32 gain; // Gain in either linear or dB units.
FLOAT32 fadingTime; // Time in which the taget gain has to be attained (0 = unsmoothed).
INT32 isDB; // Selects between linear (=0) and dB (=1) operation
FLOAT32 factor; // The exponential factor that is to be multplied with gain for smoothing.
INT32 numSamples; // Number of samples over which smoothing is needed to be applied.
FLOAT32 targetGain; // Target gain in linear units.
FLOAT32 prevGain; // Previous gain in linear units.
FLOAT32 currentGain; // Instantaneous gain applied by the module.
} ModuleScalerSymmetricFadingClass;
Variables
Properties
Name | Type | Usage | isHidden | Default value | Range | Units |
gain | float | parameter | 0 | 0 | -24:24 | dB |
fadingTime | float | parameter | 0 | 10 | 0:1000 | msec |
isDB | int | parameter | 0 | 1 | 0:1 | Â |
factor | float | derived | 1 | 1 | Unrestricted | Â |
numSamples | int | derived | 1 | 0 | Unrestricted | Â |
targetGain | float | derived | 1 | 1 | Unrestricted | Â |
prevGain | float | derived | 1 | 1 | Unrestricted | Â |
currentGain | float | derived | 1 | 1 | Unrestricted | Â |
Pins
Input Pins
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_symmetric_fading_module.m
M = scaler_symmetric_fading_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.
NUMPINS - number of input pins. Default = 1.
Â