Pump a pure sine wave into a system and any energy that comes out at frequencies other than the input is distortion. Total Harmonic Distortion (THD) measures the integer-multiple harmonics — H2 at twice the fundamental, H3 at three times, etc. — and reports their combined RMS level as a fraction of the fundamental. THD+N adds wideband noise into the same fraction, so it's always larger than THD.
The formula
For a fundamental amplitude H1 and harmonic amplitudes H2, H3, ..., Hn (in linear units, not dB):
THD = √(H2² + H3² + … + Hn²) / H1
Expressed either as a percentage (0.01% ≈ -80 dB) or in dB (20·log10 of the ratio). The tool computes both.
Even vs odd harmonics — and why tubes sound nice
Symmetric clipping (a hard limiter clipping equally top and bottom) produces only odd harmonics — H3, H5, H7… A square wave is the limit case (all odd, amplitudes 1/n) and ironically has the highest THD of any standard waveform (~48%). Asymmetric distortion — a tube amp running slightly into compression, or a class-A transistor amp warming up — produces predominantly even harmonics: H2, H4, H6. Even harmonics are musically consonant (H2 is an octave above the fundamental) and add a "warm" character, while odd harmonics (H3 is a perfect fifth, H5 is a major third) become harsh once they're loud. That's why a 5% THD tube amp can sound "musical" while a 1% transistor amp at the same crossover region sounds "edgy".
Standards in the wild
Hi-end audiophile DAC: −120 dB THD+N (0.0001%) — limited by the analog reconstruction filter, not the digital path. Pro studio mic preamp: −86 dB (0.005%). Consumer hi-fi amp (IEC 60268-3): typically < 0.01% at rated power. Broadcast audio: 0.1% is the practical limit, more often 0.03%. Telephone (G.712 narrowband): up to 2% is acceptable. Tube guitar amp at clean: 0.5–2%. Overdrive pedal: 20% and up — that's the feature, not the bug.
Why mic mode can be wrong
The live-mic mode picks the nearest FFT bin to each integer multiple of your test frequency and reads its dB. That assumes (a) the mic doesn't add its own distortion (cheap USB mics do — at high SPL their THD can swamp the device under test), (b) your speakers are clean (most aren't above 90 dB SPL), (c) the room isn't adding reflections that change the harmonic phasing. For real measurement work, use a dedicated audio analyzer (Audio Precision, RME ADI-2, dscope) and a calibrated electrical loopback path, not a microphone in a room. This tool is for illustration and rough sanity checks, not certification.
Why is THD+N always worse than THD?
THD+N includes wideband noise — hiss from the amp, thermal noise from resistors, hum, room noise via the mic — in addition to harmonics. THD-only ignores everything that isn't an integer multiple of the fundamental. A clean hi-fi amp might be −95 dB THD but only −85 dB THD+N because the residual noise floor lives at −85 to −90 dB. For DAC measurements specifically, THD+N is the headline spec because noise dominates over harmonics in good designs.
Does the tool really compute everything from just dB inputs?
Yes — manual mode is pure math. You enter each harmonic's level in dB relative to the fundamental, the tool converts each to a linear ratio (10^(dB/20)), squares them, sums, takes the square root, and divides by the fundamental (which is always 1.0 in linear after normalisation). It's the same formula used in measurement gear; the difference is the gear extracts those harmonic levels automatically while here you enter them by hand or capture them live.
Why does my measured THD jump around so much in live mode?
Several things are happening: (1) The mic itself adds distortion that overlaps with the device under test. (2) Your speakers produce harmonics at SPLs you'd be unwise to subject your hearing to. (3) Room reflections cause the harmonic amplitudes to vary with mic position. (4) The FFT samples a finite window — small changes in your input level or mic gain shift bin energies. For stable measurements you need a calibrated electrical loopback (line-out → device under test → line-in), not an acoustic path.
Why does the "ideal square wave" preset show 48.3% THD?
A square wave's Fourier series has amplitude 1/n for the n-th harmonic and only odd n: 1, 1/3, 1/5, 1/7, … The sum-of-squares = π²/8 − 1 ≈ 0.2337. Square root ≈ 0.4833 = 48.3%. The preset uses the first ten odd harmonics with the right amplitudes and effectively-zero values for the even ones, so you see exactly that result. (The series technically extends to infinity, but H11 onwards contributes < 1% additional THD.)
What's a "Bandwidth-limited THD" measurement?
Real measurements specify a bandwidth (typically 22 kHz or 80 kHz) because higher harmonics above the audio band don't contribute to perceived distortion but can dominate a wideband measurement. AES17 specifies a 22 kHz brick-wall filter for THD+N. This tool effectively bandwidth-limits at the Nyquist frequency (half your sample rate) — any harmonic above that is invisible to the FFT. For mic mode at 48 kHz, harmonics above 24 kHz are dropped from the calculation; that's a 24× margin over the audible upper limit, fine for music-band measurements.
Can THD predict how something sounds?
Only loosely. THD aggregates all the harmonics into one number, but a 1% THD that's all H2 sounds completely different from a 1% THD that's all H7. The bar chart matters more than the headline number — look at the spectrum shape. Audio engineers complement THD with intermodulation distortion (IMD), interchannel crosstalk, and frequency response measurements because no single number captures perceived quality. THD is the easiest to compute and the most-quoted; treat it as a sanity floor, not a verdict.
Is my mic audio uploaded?
No. Web Audio reads the mic locally; signal goes mic → AnalyserNode → FFT, never to any server. The browser asks once for mic permission; you can revoke it any time from site permissions.