Why ratios
A microphone gives a tiny 10 mV signal. To drive a speaker we need 5 V: 500 times bigger. Signals span huge ranges like this, so engineers compare them as ratios, measured in decibels (dB).
The decibel
A decibel compares two powers: dB = 10·log₁₀(P₂/P₁). Ten times the power is +10 dB, a hundred times is +20 dB, double is +3.01 dB, half is −3.01 dB. Equal powers give 0 dB.
Power grows with voltage squared: P = V²/R. So for voltages across the same resistance, dB = 20·log₁₀(V₂/V₁). Ten times the voltage is a hundred times the power: +20 dB either way.
A chain of gains
The preamp multiplies the voltage by 100: 10 mV becomes 1 V. In decibels its gain is 20·log₁₀(100) = +40 dB. Watch the level climb on both plots below.
The volume control halves the voltage: 1 V becomes 0.5 V. A ratio below 1 has a negative logarithm: 20·log₁₀(0.5) = −6.02 dB. In decibels, a loss is just a negative gain.
The power amp multiplies by 10: 0.5 V becomes 5 V, a gain of +20 dB. On the volts plot the early steps vanish near zero. On the decibel plot every step is easy to see.
Gains multiply: 100 × 0.5 × 10 = 500. Logarithms turn multiplying into adding: 40 − 6.02 + 20 = 53.98 dB. Check: 20·log₁₀(500) = 53.98 dB. Same answer, using only addition.
Levels, axes and code
With a fixed reference, dB gives an absolute level. dBV means compared with 1 V: 10 mV is −40 dBV, 5 V is +13.98 dBV. Into 8 Ω, 5 V gives 3.125 W, which is +34.95 dBm (re 1 mW).
The meter reads in dB and the right plot uses a log scale. Equal steps mean equal ratios: every 20 dB is ×10 in voltage, every 6.02 dB is ×2. Bode plots also use a log frequency axis.
In Python with numpy, np.log10 works on a whole array: one line turns the three gains into decibels. Their sum and 20·log₁₀ of the product both give 53.98 dB.
The working
# step 1/10 · range microphone 10 mV = 0.01 V speaker 5 V ratio 5 / 0.01 = 500 mV = millivolt = 0.001 V voltages here are rms values (the steady "heating" value of a wave)
The 10 mV microphone level is a chosen example; every other number is computed from it in this model. Voltages are rms values. Strictly, 20·log₁₀ of a voltage ratio equals the power ratio in dB only when both voltages are across equal resistances. Engineers still quote a block's voltage gain in dB this way, and so does this lesson.