Fourier synthesizer: build a sound from its harmonics
A flute, a violin and a trumpet can play the same note and still sound nothing alike. The difference is in their harmonics: every steady sound is a sum of sine waves at whole multiples of its frequency, and the mix of their strengths is its timbre. Here you can build sounds that way, one harmonic at a time. Set the amplitude and the phase of 16 harmonics, watch the waveform they add up to on an oscilloscope, see a square wave appear out of sines with the famous Gibbs overshoot at its jumps, draw a wave of your own to find its Fourier series, and play it all on a keyboard. Every steady sound is a sum of sine waves at whole multiples of its frequency, its harmonics. Press Play to add them one by one and watch a sine grow into the chosen shape; Step and Back add or take away one, Reset starts again from the first. Pick a preset, drag over the bars to set the amplitudes, turn the dials to set the phases, or draw a wave on the scope with the mouse or a finger and its harmonics are worked out for you. Play the keyboard with the mouse, a finger or the computer's keys: Z to M and Q to I, the black keys on the row above. With Sound on, the note set under Note also sounds while it plays, and every note follows the bars as you change them; Record films it with the sound.
How it works
- Press Play: the harmonics join one by one, and the sine on the scope turns into a sawtooth. Each coloured curve is one harmonic; the yellow curve is their sum, and the dashed line the shape it is heading for.
- Pick a preset: a square wave uses only the odd harmonics, a triangle wave the odd ones much more weakly. Watch the overshoot at the square wave's jumps: it stays at about 9 % of the jump however many harmonics you add.
- Play the keyboard with the mouse, a finger or the keys Z to M and Q to I. Change the timbre while you play: drag over the bars to set the amplitudes, turn the dials to change the phases.
- Draw a wave on the scope: its harmonics are worked out at once by a Fourier transform, and you can hear what you drew. Try the missing fundamental and the shuffled phases to hear two surprises of the ear.
Fourier's theorem: every periodic sound is a sum of sines
In 1807 Joseph Fourier claimed that any periodic function can be written as a sum of sine waves whose frequencies are whole multiples of its own. For a sound that repeats f times a second this means x(t) = Σ aₙ sin(2π n f t + φₙ): a fundamental at f and harmonics at 2f, 3f, 4f and so on, each with an amplitude aₙ and a phase φₙ. The list of amplitudes is the sound's spectrum. Building a sound this way is additive synthesis; taking a recorded sound apart into its harmonics is Fourier analysis, which is what the app does when you draw a wave.
Square, sawtooth and triangle waves
The classic waveforms of synthesizers have simple Fourier series. A square wave is (4/π)(sin θ + sin 3θ/3 + sin 5θ/5 + …): only odd harmonics, falling as 1/n. A sawtooth uses every harmonic at 1/n with alternating signs, and a triangle only the odd ones at 1/n², so it sounds much softer and rounder. The rule behind it: a wave with jumps has harmonics falling as 1/n, a wave with corners but no jumps as 1/n², and a smooth wave even faster. A pulse wave that is high a quarter of the time leaves out every fourth harmonic.
The Gibbs phenomenon
Add more and more harmonics of a square wave and the sum gets steeper and flatter, yet next to every jump it overshoots, by about 9 % of the jump (8.95 % in the limit). The overshoot moves closer to the jump as harmonics are added but never gets smaller. Henry Wilbraham noticed it in 1848 and J. Willard Gibbs explained it in 1899. The same ringing appears wherever a signal with sharp edges is cut off at a highest frequency: next to edges in a JPEG photo and in audio filtered too steeply.
Timbre: why instruments sound different
The ear hears a harmonic series as one note at the pitch of the fundamental, and the strengths of the harmonics as its colour. A clarinet's tube is closed at one end, so in its low register the odd harmonics are strong and the even ones weak, a hollow sound close to a square wave. A violin's bow makes a sawtooth-like motion rich in every harmonic. A flute is almost a pure sine. The brightness of a sound follows its spectral centroid, the average of its harmonic numbers weighted by their amplitudes, shown in the app as a multiple of the fundamental.
Frequently asked questions
What is additive synthesis?
Making a sound by adding sine waves together, usually harmonics of one fundamental frequency, each with its own amplitude and phase. It is Fourier's theorem used the other way round: since every periodic sound is a sum of harmonics, any timbre can in principle be built from them. Pipe organs mix ranks of pipes this way, the Hammond organ's drawbars set the levels of nine harmonics, and digital synthesizers and the Web Audio API's PeriodicWave can add hundreds.
What is the Fourier series of a square wave?
A square wave that switches between −1 and +1 is (4/π)(sin θ + sin 3θ/3 + sin 5θ/5 + sin 7θ/7 + …): only the odd harmonics, with amplitudes falling as 1/n. Its even harmonics are missing because the wave's second half is the first half upside down. A sawtooth has every harmonic at 1/n, and a triangle only the odd ones at 1/n².
What is the Gibbs phenomenon?
The overshoot and ripples of a Fourier series next to a jump. However many harmonics of a square wave you add, the sum overshoots by about 9 % of the jump just beside it; more harmonics only squeeze the ripple closer to the jump. With the 8 odd harmonics up to the 15th the app shows 9.0 %, and the limit is 8.95 %. The same ringing appears next to sharp edges in compressed images and in steeply filtered audio.
Does the phase of the harmonics change the sound?
It changes the shape of the wave a lot but the sound of a steady tone very little, which is called Ohm's acoustic law (Georg Ohm, 1843, later backed by Hermann von Helmholtz). Pick the square wave and then the square wave with shuffled phases: the waveform no longer looks square at all, its peak and crest factor change, yet both sound almost alike. The ear mostly hears the amplitudes of the harmonics, not how they line up.
What is the missing fundamental?
A sound made of harmonics 2, 3, 4 and up of a frequency f, without f itself, is still heard at the pitch f: the brain finds the common spacing of the harmonics. The sum still repeats f times a second, as the scope shows. This is why a bass line can be heard on small speakers that cannot play its lowest notes, and why voices keep their pitch on an old telephone line that cuts off everything below 300 Hz.
Can I use the picture?
Yes. Save gives a PNG at the size you choose, and the pencil opens the picture in the PictorX photo editor with the background, each harmonic, the ideal shape, the waveform, the spectrum's bars, the phase dials, the keyboard and the labels on layers of their own, and the preset's name as editable text. In the editor itself it is under Apps ▸ Science ▸ Physics ▸ Fourier Synthesizer, where you pick the preset, the note, the number of harmonics and the view, or type the amplitudes and phases. Everything runs in your browser.
Fourier Synthesizer: how do I record a video?
Press the red Record button in the playback bar: it films what the stage shows. Press it again to stop, and the video is saved to your device. Recording is free; you only need to sign in. Without a subscription the video carries a small PictorX logo in a corner. The button beside Record opens the video options: the shape (as shown, square, story 9:16 or wide 16:9), the length (until you stop, or 5, 10, 15 or 30 seconds for social media) and the file: MP4, WebM or an animated GIF. For the sound, choose the app's own sounds or one of three music tracks: calm, bright or beat.
Ready to try it?
Open PictorX in your browser — no install, no credit card required to start.
Go to Editor