Lesson 13 of 15
Gain to Decibels
The Inverse: Gain → dB
In the previous lesson we converted dB → gain. The inverse converts a linear gain value back to decibels:
dB = 20 × log₁₀(gain)
When Is This Useful?
- VU meters: show the current signal level in dB
- Metering plugins: display loudness in LUFS/dBFS
- Normalisation: "how many dB do I need to boost this to reach 0 dBFS?"
Key Values
| Gain | dB |
|---|---|
| 1.0 | 0.00 |
| 0.5 | −6.02 |
| 0.1 | −20.00 |
| 2.0 | +6.02 |
Note: doubling the amplitude adds exactly 6.02 dB (20 × log₁₀(2)).
Your Task
Implement gainToDb(gain) that converts a linear gain to decibels.
Run your code to see a rising volume displayed in dB.
Web Audio API loading...
Loading...
Click "Run" to execute your code.