Document toolboxDocument toolbox

(8.D.2.2 ) Balance

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.

gainL,R are computed from balance using the sine/cosine panning law: $gainL = cos((1+balance)*\pi/4), gainR = sin((1+balance)*\pi/4).$ Thus, full pan left: gainL=1, gainR=0; full pan right: gainL=0, gainR=1; centered (balance=0): gainL=gainR=0.707.

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

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

Data type: float

Channel range: Unrestricted

Block size range: Unrestricted

Sample rate range: Unrestricted

Complex support: Real

 

Name: R

Description: audio input

Data type: float

Channel range: Unrestricted

Block size range: Unrestricted

Sample rate range: Unrestricted

Complex support: Real

Output Pins

Name: L

Description: audio output

Data type: float

 

Name: R

Description: audio output

Data type: float

MATLAB Usage

File Name: balance_module.m

M=balance_module(NAME) Creates a balance module for use with Audio Weaver. The module has two multi channel inputs and two multi channel outputs. Each channel is scaled according to the value of a balance parameter. Arguments: NAME - name of the module.

Â