Lesson 12 of 15

Decibels to Gain

Decibels

Decibels (dB) measure sound level on a logarithmic scale, matching how human hearing perceives loudness.

dB to Linear Gain

The Web Audio API's GainNode expects a linear gain value (0 to 1+). Convert from dB:

gain = 10^(dB / 20)

Key Reference Points

dBGainMeaning
01.0000Unity — no change
−60.5012Approximately half loudness
−200.1000One-tenth amplitude
+61.9953Approximately double loudness
−∞0Silence

Why Logarithmic?

A 6 dB increase always doubles the amplitude, regardless of the starting level. This matches how we perceive sound — each doubling of loudness feels like a similar step up.

Your Task

Implement dBToGain(db) that converts decibels to linear gain.

Run your code to hear the same note played at 0 dB and −12 dB.

Web Audio API loading...
Loading...
Click "Run" to execute your code.