db_to_lin

This function converts a gain expressed in decibels (dB) to a linear gain, which can be used with functions such as audio_sound_gain.

Changes in gain can be expressed in dB. This corresponds better to how we perceive changes in amplitude (human perception of sound is not linear).

The conversion from a gain expressed in dB to a linear gain is done using the following formula: gain_linear = power(10, gain_db/20);

TIP  0dB means no change in gain (i.e. a linear gain of 1). An increase of 6dB roughly corresponds to a doubling of the linear gain, a decrease of 6dB (i.e. an increase of -6dB) to a halving of it.

Also see: lin_to_db

 

Syntax:

db_to_lin(x);

Argument Type Description
x Real The value to convert

 

Returns:

Real

 

Example:

var _lin = db_to_lin(-3);

The above code calculates the linear gain reduction corresponding to a reduction of 3dB. The result of the conversion is stored in a temporary variable _lin.