Play with the keys.
One octave digital piano with a sawtooth-like waveform. Every key plays a note and shows both its solfège and letter name. The knob sets the amplitude.
Just play and look at the numbers for now.
What, how and where is sound?
Every sound source does the same job: it displaces the air next to it. Most often that is a vibrating surface (a string, a drum head, a speaker cone, vocal folds), but it can also be a fluctuating jet of air (a flute, a whistle) or a sudden expansion (a spark, thunder). The displacement compresses the air locally, and that compression travels outward as a pressure wave at about 343 m/s. What reaches your ear is air pressure changing over time.
All six displace the air, in three different ways. The ear receives all of them the same way: pressure changing over time.
Amplitude: what pulling harder changes
Pull the string above harder and these four numbers change. Not one of the note or frequency boxes moves. Amplitude lives on its own axis, and this is where sound turns into digits.
Frequency: what the peg changes
Turn the peg and all eight of these change together, because they are all the same one number rewritten. Pulling harder touches none of them.
- Pull hard: the sound gets louder. The amplitude rises and you literally see the string swing further, the thickness of that blurred band is the amplitude.
- But the number of trips per second never changes. The counter on screen ticks at the same rate whether you pull gently or hard.
- A hard pull does make the string move faster in metres per second, but it does not make more trips. It covers more distance in the same time, that's all.
- Why: the restoring force is proportional to the displacement (
F = −kx). Pull twice as far and the force doubles too → twice the distance at twice the speed → same duration.
- Those three things set the frequency. Pluck strength does not appear in the formula.
- So this string always plays whatever it is tuned to, however hard you pull it. To change the note you have to turn the peg (tension), press a fret (length), or swap the string (mass). The selector above is that peg.
F = −kx is an approximation that holds for small displacements. Pull really hard and the string physically stretches, tension T rises, and the pitch goes slightly sharp for the first instant before settling as the sound decays. That is exactly why you always tune at normal playing strength.
The core idea: a note name is the remainder of a calculation
A note name and an octave are not two separate pieces of information. They are parts of one calculation:
Electric guitar: every link of the chain
On an electric guitar every stage of that transfer is separately visible:
- String: vibrates back and forth a fixed number of times per second.
- Pickup: a magnet and coil convert that motion into voltage by electromagnetic induction.
- Amplifier: raises the voltage and drives the speaker coil.
- Cone: moves air, producing compression and rarefaction.
- Air: the pressure wave travels at about 343 m/s and moves your eardrum at the same rate.
Every stage carries the same two quantities: rate (repetitions per second) and magnitude (size of the deviation). The medium changes; the two quantities do not.
* Slowed to 1–14 cycles per second so you can see it. The C4 you pressed in module 01 does this 261.63 times every second.
What is a note? A frequency? A wave?
A note is a name given to a sound with a definite fundamental frequency. It is a label attached to a steady periodic wave.
Does a note have only one frequency?
Almost never. A note usually contains more than one frequency, and which ones it contains depends entirely on the waveform it is played with. Its pitch comes from the fundamental and does not change with the waveform; what does change is everything above the fundamental.
A spectrum lists the frequencies contained in a sound and the amplitude of each one. The left screen plots amplitude against time. This screen plots amplitude against frequency. The two contain the same information; only the axis differs.
A single oscillator produces a waveform with a fixed shape, so its spectrum is fixed as well. Reducing its volume scales every harmonic by the same factor, so the ratios between them do not change. On a real string the higher harmonics decay faster than the lower ones, so those ratios do change over time. Reproducing that requires either one oscillator per harmonic with a separate envelope (additive synthesis), or one oscillator followed by a low-pass filter whose cutoff frequency falls over time (subtractive synthesis).
| wave | harmonics present | amplitude law | character |
|---|---|---|---|
| sine | f only | 1 | bare, hollow |
| triangle | f, 3f, 5f, 7f … odd only | 1/n² | soft, flute-like |
| square | f, 3f, 5f, 7f … odd only | 1/n | hollow, woody, clarinet |
| sawtooth | f, 2f, 3f, 4f … all of them | 1/n | rich, buzzy, bowed string |
Only sawtooth contains the complete harmonic series. That is exactly what a string produces, which is why every key on this page uses a spectrum close to sawtooth.
So where is a single oscillator actually used, and why does it still exist?
| use | which wave | why |
|---|---|---|
| Tuning reference, test tone | sine | No harmonics wanted; a single frequency is the point |
| Hearing tests (audiometry) | sine | Threshold measured at one exact frequency |
| Room and speaker measurement | sine sweep | Each frequency is examined one at a time |
| EDM sub bass | sine | Around 40 Hz harmonics only make mud |
| LFO | any | Not heard; it modulates a parameter |
| Analog synth (subtractive) | saw / square | One rich oscillator plus a filter gives a moving spectrum |
| 8-bit game music | square, triangle | The NES chip had 2 square, 1 triangle and 1 noise channel |
Why it survives: cost. Additive needs one oscillator per harmonic per note. A 32-voice instrument with 6 harmonics means 192 oscillators. Subtractive does the same job with 32 oscillators and 32 filters.
A third route, FM: two oscillators, one modulating the other's frequency. Lower the modulation depth over time and the spectrum thins out over time. The Yamaha DX7 electric piano is exactly this, made from just two oscillators.
What is harmony, and how do you build one?
A harmony is the relationship formed by two or more notes sounding at the same time. What decides that relationship is not the difference between their frequencies but their ratio: the simpler the ratio, the more their harmonics overlap, and the more fused they sound.
Understand the multipliers, and the Hz they produce
Play notes one after another, or together with chord mode. Hear how they complement each other. Look at the number you multiply by to get from one note to the next; try to work out how you reach F from C. In a moment we will build harmony out of exactly these frequency multipliers.
How do you get one note from another? Where do these multipliers come from?
A ratio is one frequency divided by another.
| pair | frequencies | quotient | its name | |
|---|---|---|---|---|
| C4 → C5 | 523.25 / 261.63 | 2.000 | octave | ▶ |
| C4 → G4 | 392.00 / 261.63 | 1.498 ≈ 3/2 | fifth | ▶ |
| C4 → F4 | 349.23 / 261.63 | 1.335 ≈ 4/3 | fourth | ▶ |
| C4 → E4 | 329.63 / 261.63 | 1.260 ≈ 5/4 | major third | ▶ |
Click a row: the keyboard above plays the first note, then the second.
- Octave is the name of the interval whose frequency ratio is 2.
- Fifth is the name of the interval whose ratio is 1.5.
fifth · ×1.5 · hear the pairs
Ratio 3:2. It is the 3rd harmonic of the lower note, folded down into the octave. Their harmonics overlap heavily, so the pair fuses.
major third · ×1.25 · hear the pairs
Ratio 5:4. This time it is the 5th harmonic folded in. There is less overlap than in the fifth, so it fuses less strongly but sounds brighter.
Where did the NUMBERS in these multipliers come from? 3/2, 4/3, who decided these ratios?
When a string vibrates at f it does not vibrate at f alone. It vibrates at 2f, 3f, 4f, 5f… at the same time. These are its harmonics, and they are not a choice: they are the physics of the string.
261.63 + 523.25 + 784.9 + 1046.5 + 1308.1 + … Hz, summed.
One complex wave. And we call it C4 because that is the lowest frequency in it.
The ear pins the pitch label onto the bottom of that stack. That is why the lowest one is called the fundamental.
| frequency | note | harmonic | strength (amplitude) |
|---|
So why seven notes? Is that cultural?
Stacking the 3/2 ratio just means multiplying by 1.5 over and over. Start at C: 261.63 → 392 (G) → 588 (D) → 883 (A) → 1324 (E) → 1987 (B). Five multiplications, six notes. Divide once as well: 174 (F). That is seven. Fold them all into one octave and five large and two small steps appear on their own: T T S T T T S. Nobody decided E–F should be close; it is not a design, it is an arithmetic remainder.
What is universal: the harmonic series. Every string has 2f, 3f, 4f, everywhere. That is why the octave (2/1) and the fifth (3/2) are foundational in nearly every known musical culture.
What is cultural: where you cut the chain, and how you divide what is left.
| tradition | division | note |
|---|---|---|
| China (三分损益) | 3/2 chain, cut at 5 | Same method, different cut → pentatonic |
| Western | 3/2 chain, cut at 7, then equalised to 12 | 12-TET |
| Turkish art music | Whole tone split into 9 commas, octave into 53 | Bakiye, küçük and büyük mücennep are distinct, there is no single "semitone" |
| Arabic | Octave into 24 (quarter tones) | Maqam system |
| Indian | 22 shruti | Fixed ratios, not equally spaced |
| Indonesia (gamelan) | slendro / pelog, 5 or 7 | Not derived from a fifth chain, it fits the instruments' inharmonic spectrum |
This is why Hicaz cannot be played on a piano: those intervals simply are not on the 12-step grid. The perde Segâh is not "somewhere between E♭ and E" either, it is a pitch in its own right. 12-TET is not a law of nature; it is an engineering trade that gave up purity in order to modulate from any key to any other.
And why 440 Hz?
There is no scientific reason for it. The ratios come from physics, but where the whole chain gets pinned down is pure convention.
| place / period | A4 |
|---|---|
| Baroque (France) | ~392 Hz |
| Mozart's Vienna | ~421 Hz |
| Verdi's preference | 432 Hz |
| 19th-c. Northern European orchestras | 450–460 Hz |
| ISO 16 (1955) | 440 Hz |
Through the 19th century orchestras kept raising the pitch to sound brighter. Singers revolted, standardisation followed; something between 435 and 445 had to be picked, and 440 was picked. (The claims about 432 Hz being "the frequency of the universe" have no physical basis.)
Timbre, chords, and harmonics. Paving our way to Fourier.
- So far: what sound is, how a frequency becomes a note, and how notes form harmony.
- A real note is not one frequency but a stack of harmonics. Which ones are in the stack and how strong each one is is the timbre of the note: what separates a violin from a flute.
- When two notes sound together their stacks overlap. The more they overlap, the more the ear fuses them, and the more consonant the harmony sounds.
- So both are made of the same material: harmonics inside one note, and harmonics shared between notes.
Fourier's idea comes from here too: every periodic wave is a sum of sines. Below you first build a note out of its harmonics, then a chord out of notes.
One single frequency, with nothing else inside it. The note name is just a label stuck onto that frequency.
All of this is one single note. The pitch comes from the lowest one; the mix of the ones above it is the note's timbre.
With only slider 1 up you hear a pure sine, which sounds like no instrument at all. Add harmonics and the sound comes alive. The presets are the same waveforms as in module 03, this time assembled one harmonic at a time.
Deep dive to frequency.
- Frequency is how many times per second the sound wave repeats. Its unit is the hertz (Hz).
- Its period is the inverse:
T = 1 / f. Its wavelength isλ = 343 / f. - Human hearing covers roughly 20 Hz to 20,000 Hz, which is about 10 octaves.
- We cut that range into octaves, then cut each octave into steps. Different cultures cut it differently: Western music into 12, Arabic music into 24, Turkish art music into 53.
- In the Western system, 1 octave = 6 whole tones = 12 semitones.
- An octave is the same note, multiplied: ×2 up, ÷2 down. 100 Hz → 200 Hz feels like the same jump as 200 Hz → 400 Hz.
- One agreed reference: A4 (La) = 440 Hz. Every other note is derived from it.
- Our C4 included:
440 × 2^(−9/12) = 261.63 Hz, nine semitones below A4.
A · 100 → 200 Hz
×2.00 · 1200 cents · a full octave
B · 1000 → 1100 Hz
×1.10 · 165 cents · less than two semitones
A difference in Hz tells you nothing musically. The ratio does.
Their MIDI numbers: 24, 36, 48, 60, 72, 84, 96, 108. All multiples of 12. Anything with m mod 12 = 0 is a C, a note name really is just a remainder.
| interval | from C4 | semitones | 12-TET ratio | just ratio | deviation |
|---|
12-TET detunes every interval a little; in exchange you can modulate anywhere. The fifth is off by 2 cents and nobody hears it. The major third is off by 14 cents and trained ears do. Why simple ratios sound good is answered in module 05: their harmonics overlap.
Notes are not evenly spaced on the frequency spectrum
On a keyboard the notes look evenly spaced. In Hz they are not.
- C4 → D4 is one whole tone and 32 Hz.
- A4 → B4 is also one whole tone, but 54 Hz.
- Same musical distance, different Hz, because distance here is multiplication, not addition: both are ×1.1225.
So you can lay the same 8 notes on a line in two different ways:
- The Hz ruler, each note sits at its true frequency. They crowd to the left and the gaps widen to the right.
- The note ruler, each note sits at its musical distance. Evenly spaced. This is exactly what a keyboard does.
Look at the two numbers on the bottom row. The red one (the Hz gap) changes at every step: 32, 36, 20, 43, 48, 54, 29. The cyan one (the ratio) takes only two values: whole tone ×1.1225, semitone ×1.0595. The number your ear follows is the cyan one.
A keyboard hides two things that are visible here:
- The same note exists in more than one place. C4 sits on three different strings. A note is a number, not a position.
- Equal musical steps are not equal distances. Fret spacing shrinks as you go up:
x_n = L · (1 − 2^(−n/12)).
- Every fret is exactly one semitone, that is
×1.05946. - The 12th fret is the exact midpoint of the string: half the length, double the frequency, one octave.
PCM. How do we record and save sound digitally?
PCM, or Pulse Code Modulation, is the standard way of storing sound digitally. The continuous pressure curve is measured at regular intervals, each measurement is rounded to a fixed number of steps, and the resulting integers are written down in order. The result is an uncompressed array of numbers, and that is what sits inside a WAV file.
- 1 · Sampling, slicing the time axis. How many measurements per second?
- 2 · Quantization, slicing the amplitude axis. How many steps do we round each measurement to?
The result: an uncompressed, raw array of integers. That is literally what's inside a WAV file.
Press play and move the slider: the sound does not stop, the resolution changes live. The source button switches between the continuous wave and the wave rebuilt from the samples. Reduce the dot count and past a point the samples no longer carry the shape; that information is gone for good.
- That's why 44,100 Hz was chosen: slightly more than twice the 20 kHz hearing limit.
- Exceed the limit and the frequency doesn't vanish, it comes back as the wrong frequency. That's aliasing.
- That's why every ADC has an anti-alias low-pass filter in front of it.
Push the slider past 4000 Hz: the pitch stops rising, turns around and goes down. The numbers aren't lying, in an 8 kHz world there is no such thing as 6 kHz; it looks exactly like 2 kHz.
16 bit = 65,536 levels ≈ 96 dB of dynamic range. While recording and mixing you use 24 bit or 32-bit float so errors don't accumulate through processing; 16 bit is plenty for delivery.
The wave on screen becomes this on disk:
| sample # | time (µs) | float −1…1 | int16 | bytes (LE) |
|---|
- Each sample is 2 bytes (16 bit). Low byte first, little-endian on Intel/ARM.
- Stereo is interleaved:
L R L R L R…Not separate blocks, alternating. - One second of stereo = 44100 × 2 bytes × 2 channels = 176,400 bytes.
- A WAV file = a ~44-byte header (rate, bit depth, channels) + that raw array. Nothing else.
- MP3/AAC/Opus compress that array; on playback it's decoded back to PCM. What reaches the speaker is always PCM.
Int16Array or Float32Array. Web Audio reads a WAV and hands you floats in -1…1. On the C/C++ side you usually get a raw int16_t*. Same numbers, different scale.
How do computers read digital music?
The trick is startlingly simple and entirely mechanical:
- Pick a test frequency. Generate a sine at it.
- Multiply your signal by that test sine, sample by sample.
- Look at the sum of the products.
- If that frequency is present, peaks line up with peaks → the sum comes out large.
- If it isn't, positives and negatives cancel → the sum lands near zero.
That's all of it. Try it by hand below.
Green area = positive, red = negative. With no match the two balance out and the sum collapses to zero. On a match nearly the whole product goes positive. An FFT does this for every frequency at once, very fast.
On the left the three sines pile into an unrecognizable wave. On the right the same thing splits back into three bars, nothing is lost, you're just seeing the same information on a different axis.
- Bin width = fs / N. Raise N → frequency resolution improves.
- But collecting N samples takes time. N=2048 @ 44.1 kHz is a 46 ms snapshot.
- If the note changed inside those 46 ms, both notes show up in the same frame → time resolution drops.
- Uncertainty principle: you can't have both perfectly.
- A long window is right for a tuner. A short window is right for drums and transients.
- Why windowing (Hann/Hamming): an FFT assumes your N samples repeat forever. If the start and end don't line up, a fake discontinuity appears and smears across the spectrum, spectral leakage. A window function tapers the edges to suppress it.
- FFT vs DFT: same result. A DFT is the plain computation, N² operations. An FFT picks N as a power of two and shares repeated work → N·log₂N. For N=1024 that's ~10,240 operations instead of 1,048,576. That's why it runs in real time.
- The N/2 rule: only the first N/2 bins are useful. For real-valued signals the upper half is a mirror of the lower half.
The breakdown of the digitalisation of sound.
Physical measurement ↔ what you perceive
| what you measure | what you hear | where it shows up |
|---|---|---|
| amplitude | loudness | wave height |
| fundamental frequency | pitch / note | first peak in the spectrum |
| harmonic ratios | timbre | relative peak heights |
| envelope | attack, punch | how fast the wave grows |
| spectral balance | bass / treble balance | left/right weight of the spectrum |
| phase | position, width | shift between the two channels |
Where they interact
- Amplitude and frequency are independent: turning it down doesn't change the note.
- But perceived loudness depends on frequency: at equal amplitude, 60 Hz sounds quieter than 1 kHz.
- Pitch comes from the fundamental; timbre from the harmonics. Both live in the same sound at once.
- In PCM, sample rate sets the frequency ceiling and bit depth sets amplitude precision. Two axes, two separate limits.
- The FFT ties it together: it extracts frequency content from the PCM numbers, and note and timbre are read off from there.
Play the saw wave and watch the spectrum: an evenly spaced harmonic series stacked above the fundamental. Play the chord: three fundamentals and their harmonics interleave. That pattern is what your ear calls a chord.
The terms we learned, in an unofficial 2D placement.
Module 03 had two knobs that never touched each other. Those two knobs are the two axes of this graph. Click any term: you'll see which axis it belongs to, what it's derived from, and its formula.
Click a term.
The chain along the bottom runs left to right in order of derivation: each box is a mathematical transformation of the one before it. The left edge works the same way. The two red boxes in the middle are different, they need both axes at once, which means they carry genuinely new information.
Move only vertically: the note box never moves. Move only horizontally: loudness stays put. The rest of the page goes deeper into these two axes one at a time, first the logarithmic face of the frequency axis, then timbre, then the digital form of both (PCM), and finally the operation that converts one into the other (FFT).
Play time.
The same keyboard, three different physical models. Press a key and every quantity you learned on this page rises out of the note: the name, the frequency, the period, the MIDI number, the int16 value, how many harmonics are sounding.
Play the same note on all three and watch the spectrum on the right. The pitch never moves, because the fundamental is the same. The only things that change are the harmonic pattern above it and the envelope: that is timbre.
BEAT. Slow a note down and it becomes a beat.
Rhythm and pitch are not two different things. Both answer the question how many times per second. The only difference is the rate: below about 20 Hz the ear counts the events one by one, above it fuses them into a single pitch.
At 2 Hz you hear separate clicks, two per second. Around 18 Hz they start to flutter. Past 30 Hz you no longer hear clicks but a low note. At 110 Hz that note is A2. Nothing was switched on or off; one number just got bigger.
Musicians write that number not in hertz but in beats per minute. The conversion is one division:
| BPM | Hz | beat length | feel | |
|---|---|---|---|---|
| 60 | 1.00 | 1000 ms | slow ballad | ▶ |
| 90 | 1.50 | 667 ms | hip hop | ▶ |
| 120 | 2.00 | 500 ms | pop, house | ▶ |
| 174 | 2.90 | 345 ms | drum and bass | ▶ |
Click a row to hear four beats at that tempo. 60 BPM is exactly 1 Hz, one beat per second.
Bars, accents and swing. The grid a song sits on.
- Bar: beats are counted in repeating groups. 4/4 means four beats per bar.
- Accent: the first beat of the group is stronger. That accent is the only thing that lets you hear the bar at all.
- Subdivision: each beat can be split into 2, 3 or 4 equal parts. Dividing is, again, just a multiplier.
- Swing: in a two-part division, lengthening the first part and shortening the second. 50% is straight, 66% is a full triplet feel.
Watch the accented beat in red: it is the only thing that makes the bar audible. Switch to 6/8 and the grouping changes at the same tempo. Then set the subdivision to triplet: the beats stay where they were, the gaps split into three.
Now cook something.
- A beat is frequency too, only very slow. 120 BPM = 2 Hz.
- Same formula:
f = BPM / 60. Below about 20 Hz the ear stops hearing a pitch and starts hearing a rhythm. - The row colours are the same palette as module 05, so you can see how consonant your pattern is.
- Click a cell a second time to make it accented, so it plays louder. A third click clears it. That is the amplitude axis from module 02.
- The octave buttons multiply or divide every note by 2. The pattern stays identical, it just moves.
- Change the root or the scale: the same pattern moves to another key, or turns from major to minor. The ratios are preserved, the feeling is not.
- This column names the chord formed by whatever is sounding on the current step, using the same detector as module 05.
Watch the notes that land on the same step: simple ratios fuse, semitone neighbours clash. What you saw as colour in module 05 you now hear laid out in time.