ScalerNSymmetricFadingN
Overview
General purpose scaler with separate gains and smoothing times per channel
Discussion
Scaler (or gain) module for floating-point signals. Compared to the general purpose scaler, this module takes equal time for fade in and fade out as decided by fadingTime. Furthermore, compared to ScalerNSymmetricFading this module applies all fading times separate per channel. This module has a single gain (masterGain) which is applied all channels plus a separate per channel gain (trimGain). For each channel, masterGain and trimGain[n] is combined to form the target gain value.
The gains are intrepreted as either linear or dB values based on the isDB module variable. By default, isDB = 1 and the gains are treated as dB values. If you set isDB = 0 then the gains are treated as linear values. When in dB, targetGain = masterGain + trimGain[n]. When in linear mode, targetGain = masterGain * trimGain[n].
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. fadingTime is the time in which the target gain is achieved. The module is slightly more efficient when no smoothing occurs.
The module argument NUMCHANNELS sets the initial number of channels. This allows you to configure the module for the proper number of channels before the system is built. After the system is built, NUMCHANNELS is no longer used and the number of channels is determined from the input wire. The module can also handle complex data no smoothing is performed and the gain value is applied to both the real and imaginary parts.
Module Pack
Standard
ClassID
classID = 257
Type Definition
typedef struct _ModuleScalerNSymmetricFadingN
{
ModuleInstanceDescriptor instance; // Common Audio Weaver module instance structure
FLOAT32 masterGain; // Overall gain to apply. Min. linear gain is clamped to 0.
INT32 isDB; // Selects between linear (=0) and dB (=1) operation
FLOAT32* trimGain; // Array of trim gains, one per channel
FLOAT32* fadingTime; // Array of fading times (0 = unsmoothed), one per channel
FLOAT32* targetGain; // Computed target gains in linear units
FLOAT32* currentGain; // Instanteous gains. These ramp towards targetGain
FLOAT32* factor; // The factor to be multiplied for implementing the exponential ramp up or ramp down
INT32* numSamples; // Number of samples over which smoothing has to be applied
FLOAT32* prevGain; // Previous gains
} ModuleScalerNSymmetricFadingNClass;
Variables
Properties
| Name | Type | Usage | isHidden | Default Value | Range | Units |
|---|---|---|---|---|---|---|
| masterGain | float | parameter | 0 | 0 | -24:24 | dB |
| isDB | int | parameter | 0 | 1 | 0:1 | |
| trimGain | float* | parameter | 0 | [1 x 1] | -24:24 | dB |
| fadingTime | float* | parameter | 0 | [1 x 1] | 0:1000 | msec |
| targetGain | float* | derived | 1 | [1 x 1] | Unrestricted | |
| currentGain | float* | state | 1 | [1 x 1] | Unrestricted | |
| factor | float* | derived | 1 | [1 x 1] | Unrestricted | |
| numSamples | int* | derived | 1 | [1 x 1] | Unrestricted | |
| prevGain | float* | derived | 1 | [1 x 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 and Complex |
Output Pins
| Name | out |
| Description | audio output |
| Data Type | float |
Matlab Usage
File Name: scalern_symmetric_fadingn_module.m
M = scalern_symmetric_fadingn_module(NAME, NUMCHANNELS)
Scaler module with a separate gain and smoothing time per channel.
Compared to the general purpose scaler, this scaler takes equal time for
fadeIn or fadeOut. The module can be configured for linear or dB operation
as well as smoothed and unsmoothed gain changes.
Arguments:
NAME - name of the module.
NUMCHANNELS - default number of channels. Default = 1. This is used
to draw the initial inspector. The actual number of channels
processed by the module is determined by pin propagation.
Copyright (c) 2026 DSP Concepts, Inc.