This function converts a linear gain to a gain expressed in decibels (dB). You get a linear gain value from functions such as audio_sound_get_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 formula: gain_db = 20 * log10(gain_linear);
lin_to_db(x);
Argument | Type | Description |
---|---|---|
x | Real | The value to convert |
var _db = lin_to_db(1.5);
The above code calculates the gain in dB corresponding to a linear gain of 1.5. The result of the conversion is stored in a temporary variable _db.