Skip to content

PlaygroundSignals · 01

Harmonics

Harmonic number · 1 is the note itself (220 Hz), 2 is twice that, and so on

Preset

Challenge

A mystery sound made of a few harmonics. Rebuild it by ear.

What's going on

Play the same note on a flute and on a violin and you can still tell them apart. That difference, the colour of a sound, is called timbre, and it follows a surprisingly simple recipe.

Almost every musical note is a stack of pure tones. The lowest one, the fundamental, sets the pitch you hear. On top of it sit harmonics at exactly two, three, four… times its frequency. The bars above are the recipe: how loud each ingredient is. A flute is almost a single pure tone. A clarinet mostly uses every other harmonic, which gives it its hollow sound. A violin or a trumpet uses all of them and sounds bright.

That any repeating sound can be built this way was Joseph Fourier's idea in 1807, and it reaches far beyond music. Splitting a signal into its frequencies, the Fourier transform, is one of the most used tools in science and engineering. Drawing with circles shows the same idea in pictures.

Why it matters: the Fourier transform is the starting point of almost all audio technology: equalizers, MP3, pitch detection, noise reduction, and the spectrograms that most machine-learning models for audio take as input.

The maths behind itFor the curious · formulas and details

Fourier series

A periodic signal with frequency f is a sum of sines at whole-number multiples of f. The bars are the coefficients aₙ:

x(t) = Σ aₙ·sin(2π·n·f·t)    n = 1 … 12

A square wave uses only the odd harmonics, each one quieter by 1/n:

square(θ) = (4/π)·(sin θ + ⅓·sin 3θ + ⅕·sin 5θ + …)

With finitely many terms a small overshoot remains next to each jump, about 9% of the jump however many terms you add: the Gibbs phenomenon. Pick Square above and look at the corners.

Fourier transform

For signals that do not repeat, the transform gives a continuous spectrum instead of a list of harmonics. Applied to short slices of a recording one after another, it gives a spectrogram.

X(f) = ∫ x(t) · e^(−2πi·f·t) dt    e^(iθ) = cos θ + i·sin θ

The factor e^(−2πift) is a point spinning around a circle, so the transform asks, for every speed, how much of the signal spins along with it.

Why sine waves are enough

Periodic signals form a vector space with an inner product, a way to measure how much two signals point in the same direction:

⟨f, g⟩ = ∫₀¹ f(t) · g(t)* dt    eₙ(t) = e^(2πi·n·t)

The waves eₙ are orthonormal: ⟨eₙ, eₘ⟩ is 1 when n = m and 0 otherwise, like perpendicular unit axes. A Fourier coefficient is then simply a projection, the length of the signal's shadow on axis n: cₙ = ⟨f, eₙ⟩.

They are also complete: in the Hilbert space L²[0, 1] of finite-energy signals every f equals Σ cₙ·eₙ, and no energy is lost (Parseval: ∫|f|² = Σ|cₙ|²). The convergence is in energy, not point by point, which is why the Gibbs overshoot never shrinks while the total energy of the error still goes to zero.