Function db_to_linear

Source
pub fn db_to_linear(decibels: f32) -> f32
Expand description

Converts decibels to linear amplitude scale.

This function converts a decibel value to its corresponding linear amplitude value using the formula: linear = 10^(decibels/20) for amplitude.

§Arguments

  • decibels - The decibel value to convert. Common ranges:
    • 0 dB = linear value of 1.0 (no change)
    • Positive dB values represent amplification (> 1.0)
    • Negative dB values represent attenuation (< 1.0)
    • -60 dB ≈ 0.001 (barely audible)
    • +20 dB = 10.0 (10x amplification)

§Returns

The linear amplitude value corresponding to the input decibels.

§Performance

This implementation is optimized for speed, being ~3-4% faster than the standard 10f32.powf(decibels * 0.05) approach, with a maximum error of only 2.48e-7 (representing about -132 dB precision).