🎵 Sound · Signal Processing · Mathematics
📅 July 2026 ⏱ ~9 min read 🟡 Intermediate

Fourier Series & the Fourier Transform

Every musical note, every vowel sound, every clang of a bell is a pressure wave that repeats over and over. Joseph Fourier's astonishing 1807 claim was that any such repeating wave — no matter how jagged — can be rebuilt exactly from an infinite sum of pure sine waves. This is the idea that powers synthesizers, MP3 compression, and the equalizer in your headphones app.

Periodic signals as sums of sines

A sound wave is periodic with period T if it repeats itself exactly every T seconds: p(t) = p(t + T). A pure tone — a single sine wave — is the simplest periodic signal. But a violin note, a human vowel, or a square-wave synth patch all look far messier than a sine on an oscilloscope, and yet they still repeat with a fixed period.

Fourier's theorem says that any reasonably well-behaved periodic function can be written as a sum of a constant (the average, or DC offset) plus sine and cosine waves at integer multiples of the fundamental frequency f₀ = 1/T — these multiples are called harmonics.

p(t) = a₀ + Σn=1 [ aₙ·cos(2π n f₀ t) + bₙ·sin(2π n f₀ t) ]

The numbers a₀, a₁, a₂, … and b₁, b₂, … are the Fourier coefficients. They tell you exactly how much of each harmonic is present — this list of numbers is the timbre of the sound. A flute has energy concentrated in the first few harmonics; a brighter, buzzier oboe has energy spread across many more.

The Fourier series coefficients

The coefficients are found by projecting the signal onto each harmonic — multiplying by a sine or cosine of that frequency and integrating over one period. This works because sines and cosines of different harmonic numbers are orthogonal: their product integrates to zero over a full period unless the frequencies match.

a₀ = (1/T) ∫₀T p(t) dt

aₙ = (2/T) ∫₀T p(t)·cos(2π n f₀ t) dt

bₙ = (2/T) ∫₀T p(t)·sin(2π n f₀ t) dt

Once you have aₙ and bₙ, it's often more useful to combine them into a single magnitude and phase per harmonic — this is exactly what a spectrum analyser displays as bars rising above each frequency:

Aₙ = √(aₙ² + bₙ²)    (amplitude of harmonic n)
φₙ = atan2(bₙ, aₙ)    (phase of harmonic n)

Worked example: the square wave

A classic synth square wave (amplitude ±1, period T) contains only odd harmonics, falling off as 1/n:

square(t) = (4/π) · Σk=0 sin(2π (2k+1) f₀ t) / (2k+1)

= (4/π) [ sin(ωt) + sin(3ωt)/3 + sin(5ωt)/5 + sin(7ωt)/7 + … ]

This is why a square wave sounds hollow and "clarinet-like" compared to a sawtooth (which has both even and odd harmonics, falling off as 1/n, and sounds brighter and buzzier). You can hear the difference directly: play just the fundamental, then add the 3rd harmonic at 1/3 amplitude, then the 5th at 1/5, and the tone edges from a soft sine toward a harsh square.

The Gibbs phenomenon

A perfect square wave has an instantaneous, infinitely sharp jump — but every partial sum of finitely many sine waves is smooth. As you add more harmonics, the approximation gets closer to the square wave almost everywhere, but right at the jump a stubborn overshoot of about 9% of the jump height refuses to shrink, no matter how many harmonics you add. This is the Gibbs phenomenon, discovered by Josiah Willard Gibbs in 1899.

Why it matters for audio: Gibbs ringing at a sharp transient is one reason naively band-limiting a hard digital edge (like a clipped waveform) produces audible pre-echo or "ringing" artifacts. Synthesizer oscillators use band-limited (BLEP/BLIT) waveform generation specifically to control this ringing and avoid aliasing.

Complex exponential form

Engineers almost always write the Fourier series using complex exponentials instead of separate sines and cosines — via Euler's formula e = cos θ + i sin θ, the whole sum collapses into one elegant expression:

p(t) = Σn=−∞ cₙ · ei 2π n f₀ t

cₙ = (1/T) ∫₀T p(t) · e−i 2π n f₀ t dt

Here cₙ is a single complex number per harmonic that packages both amplitude (|cₙ|) and phase (arg cₙ) together, and negative n simply represents the "negative frequency" partner needed to keep p(t) real-valued. This is the form used almost universally in signal processing — including the FFT, which computes a finite, sampled version of exactly this sum.

From series to transform

The Fourier series only applies to periodic signals. But most interesting sounds — a spoken sentence, a drum hit, a burst of noise — are not periodic at all. The Fourier transform generalises the idea by treating a non-periodic signal as the limit of a periodic one whose period T tends to infinity. As T → ∞, the spacing between harmonics (1/T) shrinks to zero, the discrete sum over n becomes a continuous integral over frequency f, and the coefficients cₙ become a continuous function X(f):

X(f) = ∫−∞ x(t) · e−i 2π f t dt    (forward transform)

x(t) = ∫−∞ X(f) · ei 2π f t df    (inverse transform)

X(f) is called the spectrum of x(t): a continuous density of frequency content rather than a discrete list of harmonic amplitudes. Every frequency, not just integer multiples of f₀, can now carry energy.

The discrete version: DFT

Computers can't integrate over infinite continuous time, so digital audio uses the Discrete Fourier Transform (DFT), applied to N samples of a signal:

X[k] = Σn=0N−1 x[n] · e−i 2π k n / N    for k = 0, 1, …, N−1

Computed directly, this costs O(N²) multiplications. The Fast Fourier Transform (FFT) — Cooley & Tukey, 1965 — recursively splits the sum into even- and odd-indexed samples, reducing the cost to O(N log N). This is what makes real-time spectrum analysers, pitch detectors, and audio equalizers possible on ordinary hardware; the Web Audio API's AnalyserNode runs exactly this algorithm every animation frame.

Rule of thumb: A 1024-sample FFT at a 44.1 kHz sample rate gives frequency bins spaced 44100/1024 ≈ 43 Hz apart — the trade-off between frequency resolution and time resolution is the heart of the uncertainty principle in signal processing: a longer window gives sharper frequency bins but blurs together events that happen close together in time.

Try it yourself

Watch harmonics being added one at a time, rotating as phasors around a circle, tracing out the waveform in real time — including the square wave overshoot from the Gibbs phenomenon:

🌀 Open Fourier Phasors Simulation →

Or explore live additive synthesis, adjusting each harmonic's amplitude yourself:

🎛️ Open Fourier Synthesis Simulation →

Sources