TwiddleLab / Math / Trig and Waves
Project: Make a Synth Note
What you will learn
- A note at f is a sum of sine waves at f, 2f, 3f...: the harmonics.
- How much of each harmonic you add is the timbre: same pitch, different sound.
- A real note fades like e^(-kt): bigger k, faster fade.
- Digital sound is the same sine, sampled: sample n plays at time n ÷ 44100 seconds.
How the lesson goes
Build an instrument nobody has heard before.
From nothing but sine waves. First, three mystery notes: tap each one.
Step 1: set the root note.
Move the lever to 220 Hz, the note A3. The card shows its period.
Step 2: add overtones.
Raise the bars 2f to 5f. Turn on at least two and press Play.
Harmonics and timbre.
The harmonics of a note at f are the sine waves at f, 2f, 3f, 4f and so on.
The timbre is the recipe: how much of each harmonic. Same pitch, different recipe, different instrument.
Match each recipe to its wave.
Tap a recipe, then the wave it makes.
Each harmonic adds a small sine with n wiggles per cycle of f. Only f gives a smooth sine. Odd harmonics keep the bottom half a mirror of the top half; adding the even ones too makes the wave lean like a saw.
Step 3: make the note fade.
Loudness falls like e^(-kt). Set k so only 10% is left after 1 second.
The root is 220 Hz. What frequency is the third harmonic?
Harmonics are whole-number multiples of the root: 3f = 3 × 220 = 660 Hz.
Challenge: copy the sound.
Make your blue lines cover the dashed target: the wave shape and the fade. Compare when ready.
Step 4: your own instrument.
Set the bars and the fade any way you like, pick a name and Keep it.
This code plays the note an octave too high.
A computer plays sound as 44,100 numbers a second. Find the right time for sample n.
With 44,100 samples a second, sample n is at t = n ÷ 44100 s. Using 22050 doubles every t, which doubles the frequency: 440 Hz, one octave up.
Which overtone is in this wave?
It is f plus one overtone. Tap that overtone's bar.
A harmonic nf goes through n cycles while f goes through one, so 3f adds three bumps per cycle.
Your instrument, made of sine waves.
Press Play my tune and watch the wave change with every note.
Previous lesson: Rotation with Trig · Part of the course: Trig and Waves
Lessons are interactive and need JavaScript. Turn it on to play them.