↑ ↓ to move · enter to open

S00 · Sound · Standing waves, harmonics, beats

waves & harmonics

Every sound is air pressure wiggling back and forth. A guitar string, a clarinet and two slightly mistuned notes all come down to one idea: adding sine waves. A string can only ring at frequencies that fit whole loops between its ends. The mix of those frequencies sets an instrument's tone, and two close frequencies beat against each other.

LAB 1

a vibrating string

Pluck a string and a ripple runs to each end, bounces back, and meets itself. Only a few shapes survive that round trip: the ones where a whole number of half-waves fits exactly between the two fixed ends. Each surviving shape is a mode. Points that never move are nodes, and the points that swing the most are antinodes. Frequency is how many times per second the string swings back and forth, measured in hertz (Hz). Wavelength is the length of one full up-and-down wiggle. Tighten the string and the ripples run faster. Make it heavier and they run slower.

mode 3
Mode n
—
70 N 3.4 g/m
Presets

How to read this: the top shows one mode swinging in slow motion. The list below it shows the first eight shapes the string can take and their pitches; click any row to pick it.

  • the string's widest swing
  • where the string is held fixed
sound off
—
Wave speed v
—
Fundamental f₁
—
This mode fₙ
—
Wavelength λₙ = 2L/n

The fitting rule

v = √(T/μ) · L = n·λ/2 ⇒ fn = v/λ = n·v/(2L)

T is the tension in newtons, μ the mass per length in kg/m, L the length in meters, and n = 1, 2, 3, … counts the loops. Every mode is a whole-number multiple of the lowest one, f₁. Those multiples are called harmonics.

Now

Why players do what they do

A guitarist tunes by turning a peg, which changes T. Pressing a fret shortens L, which raises every mode by the same ratio. Bass strings are wound with extra wire to raise μ, so they can sound low without being slack or very long. Mode 2 is exactly double the frequency of mode 1, the interval musicians call an octave. S01 · Scales & tuning builds on these ratios.

This is an idealized string: perfectly flexible, with no stiffness and no damping. Real strings are slightly stiff, which nudges the higher modes a little sharp. Piano tuners have to allow for that.

CodePython

LAB 2

why instruments sound different

A flute and a violin can play the same note, at the same pitch (how high or low it sounds), and still sound nothing alike. The difference is timbre: the recipe of harmonics underneath. A real instrument vibrates in many modes at once, so its sound is the fundamental plus some 2×, some 3×, and so on. Each harmonic's amplitude is how strongly it is present. Set the amplitudes with the sliders and watch the sum take shape. Building a sound this way is called additive synthesis.

square wave
Recipe
15
220 Hz

How to read this: the bars at the bottom are the recipe. Bar 1 is the base note, bar 2 is twice its pitch, and so on; taller means louder. The green wave on top is what you get when you add them all up.

  • harmonic added
  • pointing down: harmonic added upside-down
  • faded: not used (past the gold N line)

Try this: pick Square and slide Harmonics used from 1 to 40. The green wave sharpens, but the little horns at each jump never go away.

Sliders set harmonics 1 to 12. Formula recipes continue past 12 when "harmonics used" is higher. *Clarinet-like and violin-like are illustrative approximations; a real instrument's recipe changes with the note, the loudness and the player.

sound off
—
Overshoot at the jump
—
Mismatch vs target (RMS)
—
Harmonics in use
—
Highest frequency

Additive synthesis

y(t) = Σ an·sin(2π·n·f0·t), n = 1 … N
square: an = 1/n, odd n · sawtooth: an = 1/n, all n
triangle: an = ±1/n², odd n, signs + − + − …

f₀ is the fundamental in Hz and an the amplitude of harmonic n. Practically any repeating shape can be built this way, an idea named after Joseph Fourier. S02 · The Fourier transform runs it in reverse and pulls the recipe out of a sound.

Now

The 9% that never goes away

Near a sudden jump, the partial sum always overshoots by about 9% of the jump height, however many harmonics you add. More terms squeeze the overshoot closer to the jump without shrinking it. This is the Gibbs phenomenon. A triangle has no jump, its amplitudes fall off as 1/n², and it converges quickly with no overshoot.

For a steady tone, your ear is far more sensitive to the amplitudes than to the signs or timing of the harmonics. Two recipes with the same amplitudes can draw different shapes and still sound nearly the same.

CodePython

LAB 3

two notes at once

When two sounds reach your ear together, the air simply adds their pressure wiggles. That is superposition. Where the two waves are in step, they add up and get louder (constructive interference). Where one is up while the other is down, they cancel (destructive interference). If the two frequencies are close, they drift in and out of step over and over, and you hear one tone that swells and fades. Those swells are beats. Sound itself travels through air at about at .

sum of two tones
440 Hz
443 Hz
100%
Presets

How to read this: the top strip shows a few seconds of the combined sound. The gold outline is how loud it is, so each bulge is one beat. The bottom zooms into the moment at the blue line to show the two tones and their sum. The colors change jobs in the zoom: there green is tone 1, blue is tone 2 and amber is their sum.

  • dotted gold lines: one beat each
  • top strip: where playback is now

Try this: click 1 beat/s and press Play both tones, then count the swells along with the gold bulges.

Click or drag on the top plot to choose the moment shown in the zoom below it.

sound off
—
Beat frequency |f₁ − f₂|
—
Beat period
—
Average pitch
—
Quietest vs loudest
—
Wavelength in air
—
Phase gap at zoom

Sum to product

sin(2πf₁t) + sin(2πf₂t) = 2·cos(π(f₁−f₂)t) · sin(π(f₁+f₂)t)
envelope E(t) = √(a₁² + a₂² + 2a₁a₂·cos(2π(f₁−f₂)t)) · fbeat = |f₁ − f₂|

The fast part wiggles at the average frequency. The slow cosine sets the loudness. Loudness follows the size of that cosine and ignores its sign, so it peaks twice per cosine cycle: |f₁ − f₂| times per second.

Now

Tuning by ear

Musicians tune by listening for beats. Play a string against a reference note and turn the peg until the throbbing slows down and stops. At 1 beat per second the two are 1 Hz apart; at zero they match. With unequal volumes the cancellation is never complete, so the beats get shallower. The boundaries between beats, roughness and two separate notes shown here are rules of thumb; they vary with pitch and listener.

CodePython