🎶

Real-Time Harmonic Balance Analyzer

Watch the harmonic spectrum of a live signal in real time — H1 through H20 as a bar chart, odd vs even ratio, and automatic waveform-shape classification (sine / triangle / square / sawtooth) by matching the harmonic profile to canonical Fourier series. Use the built-in test signals to see the math, or feed in your own signal via mic.

Source

Switch waveforms while running — the bar chart morphs instantly to the canonical profile.
The analysis runs on the pre-speaker signal, so harmonic readings are always exact regardless of volume. Volume only controls what you HEAR.

Result

Closest waveform
Odd harmonics
H3, H5, H7…
Even harmonics
H2, H4, H6…
Total harmonic distortion (THD)
Harmonic spectrum — H1 through H20 (dB relative to fundamental)

Odd, Even & Why Tubes Sound Different

The harmonic balance of a signal — how its energy distributes across H2, H3, H4, etc. relative to H1 — is more perceptually meaningful than its single THD number. Two amplifiers can both measure 1% THD but sound radically different if one is even-harmonic-dominated (musically warm) and the other odd-harmonic-dominated (harsh / clipped).

The canonical waveforms

Each of the four standard waveforms has a specific Fourier-series harmonic profile:

  • Sine — only H1. No harmonics, 0% THD by definition.
  • Triangle — odd harmonics only, amplitudes 1/n² (very gentle high-end). Soft, almost-pure character.
  • Square — odd harmonics only, amplitudes 1/n (∞ slope reaches all frequencies equally). Hollow, "buzzy" character.
  • Sawtooth — all harmonics, amplitudes 1/n. Bright, "brassy" — the basis of subtractive synth bass.

The shape classifier

The tool normalises your live harmonic profile so H1 = 1, then computes the cosine similarity to each canonical profile. The match with the highest similarity (closest to 1.0) is reported as "closest waveform". Above 95% similarity is a strong match (likely that pure waveform); 85–95% is moderate (a distorted version of that shape); below 70% means the signal doesn't match any standard waveform well (could be a complex tone, voice, music, or an arbitrary distortion product).

Odd vs even — what your ear cares about

Even harmonics (H2, H4, H6…) sit on musically consonant intervals: H2 is exactly one octave above the fundamental, H4 two octaves, H6 two octaves + a fifth. Adding them to a signal sounds like the original, just bigger and warmer. That's the "tube sound" everyone chases.

Odd harmonics (H3, H5, H7…) sit on dissonant intervals: H3 is an octave + a fifth (consonant-ish), H5 is two octaves + a major third (consonant-ish), H7 is two octaves + a flat-7th (dissonant). H9 onwards becomes increasingly grating. Symmetric clipping in solid-state circuits produces predominantly odd harmonics — that's the "transistor harshness" people describe.

Asymmetry = even harmonics

Mathematically: if your distortion function f(x) is asymmetric (f(x) ≠ −f(−x)), it generates even harmonics. Symmetric clipping (f(x) = clip(x), top and bottom equally) is anti-symmetric and produces only odd harmonics. A class-A tube amp running into asymmetric saturation (because of the asymmetric voltage swing across the tube) produces even harmonics. A class-AB push-pull amp at clipping is symmetric and produces only odd. This is why a single-ended class-A tube amp is the holy grail of "musical distortion".

What you'll see in real signals

Voice and music are not standard waveforms — they're complex spectra with rich, signal-dependent harmonics. The classifier will usually fall below the 70% threshold and be flagged as a "weak match"; that's expected. Use the bar chart and odd/even ratio for the actual information.

Frequently Asked Questions

Why does the "sine" preset still show some small harmonics?
An ideal Web Audio sine oscillator is mathematically pure — no harmonics — but the analysis runs through an FFT with finite resolution. Bins near the fundamental can pick up tiny "spectral leakage" from imperfect bin alignment (the fundamental's frequency is rarely an exact bin centre). With a Hann window this leakage typically stays below −60 dB. If you see harmonics above that on a sine source, you've probably tipped into clipping at the speaker / DAC.
My square wave shows only odd harmonics — why?
A symmetric square wave's Fourier series only contains odd harmonics. The amplitude of the n-th odd harmonic is exactly 1/n: H3 is 1/3 of H1 (−9.54 dB), H5 is 1/5 (−13.98 dB), H7 is 1/7 (−16.90 dB), and so on. The chart will show every other bar at the noise floor — that's the textbook profile. (PWM-modulated square waves with asymmetric duty cycle generate even harmonics too.)
Why is the odd/even ratio not 50/50 on sawtooth?
Sawtooth's harmonic amplitudes are all 1/n. The energy in odd harmonics (excluding the fundamental) is sum(1/n²) for n=3,5,7,…, even harmonics sum(1/n²) for n=2,4,6,… The n=2 contribution (1/4) outweighs n=3 (1/9). Computed across H2–H20 the tool shows odd ≈ 35%, even ≈ 65%. Square wave is 100% odd; triangle is 100% odd (no even content); pure sine is 0/0 (no distortion at all).
What does shape similarity below 70% mean?
Your harmonic profile doesn't strongly match any of the four canonical waveforms. Likely scenarios: (1) you're feeding in voice, music, or other complex signals; (2) the fundamental setting is off from the real fundamental, so harmonic peaks aren't being captured at the right bins; (3) the signal is noisy and harmonics are buried in spectral noise; (4) the signal has a unique distortion character (e.g., crossover distortion in class-AB amps produces a specific high-frequency emphasis). The bar chart still shows the actual spectrum.
Can I use this to evaluate guitar tone?
Yes — feed a sustained guitar note into the mic, set the fundamental to the note's frequency, and watch the chart. A clean tube amp will show predominantly even harmonics (warm). An overdriven distortion pedal will swing toward odd. A perfect linear DAC playing a recorded clean tone will show almost no harmonics until the recording's own distortion shows. Slight room-acoustics colouration and mic frequency response will affect readings — don't treat this as a calibrated lab measurement.
Why does THD here sometimes differ from the harmonic-distortion-estimator?
This tool uses 20 harmonics (H1 through H20); the harmonic-distortion-estimator uses 10. Higher-harmonic terms are usually small but they contribute a few percent to the sum-of-squares. Also, both tools use the peak-bin amplitude per harmonic (not integrated energy across each bin window), so both share that approximation.
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 permission; you can revoke it any time.