Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Scroll Documents: Update page title prefix

Overview

Left-right balance control

Discussion

The Balance module smoothly scales left and right channels as specified by the balance parameter. The module has two multichannel input pins and two multichannel output pins. All dimensions of input and output pins are identical. The balance setting is automatically converted to target gains for left and right channels: gainL and gainR.

...

Internally, currentGainL and currentGainR represent the instaneous smoothed gains applied to the left and right channels. currentGainL,R exponentially approach gainL,R with a time constant equal to smoothingTime. Note: we have only one time constant controlling both left and right channels. currentGainL,R also serve as the starting point of the module. If currentGainL,R = gainL,R then the module starts in a converged state. If currentGain != gain for either left or right channels, then currentGain will smoothly vary until the value of gain is reached.

Type Definition

Code Block
typedef struct _ModuleBalance
{
    ModuleInstanceDescriptor instance;            // Common Audio Weaver module instance structure
    FLOAT32 balance;                              // Left/Right Balance.
    FLOAT32 smoothingTime;                        // Time constant of the smoothing process.
    FLOAT32 currentGainL;                         // Instantaneous gain applied to left channel. This is also the starting gain of the left channel.
    FLOAT32 currentGainR;                         // Instantaneous gain applied to right channel. This is also the starting gain of the right channel.
    FLOAT32 smoothingCoeff;                       // Smoothing coefficient.
    FLOAT32 gainL;                                // Target gain left channel.
    FLOAT32 gainR;                                // Target gain right channel.
} ModuleBalanceClass;

Variables

Properties

Name

Type

Usage

isHidden

Default value

Range

Units

balance

float

parameter

0

0

-1:1

linear

smoothingTime

float

parameter

0

10

0:1000

msec

currentGainL

float

state

0

0.707

0:1

linear

currentGainR

float

state

0

0.707

0:1

linear

smoothingCoeff

float

derived

1

0.002081

Unrestricted

gainL

float

derived

1

0.7071

0:1

linear

gainR

float

derived

1

0.7071

0:1

linear

Pins

Input Pins

Name: L

Description: audio input

...

Sample rate range: Unrestricted

Complex support: Real

Output Pins

Name: L

Description: audio output

...

Description: audio output

Data type: float

MATLAB Usage

File Name: balance_module.m

...