08Physics · Audiointeractive simulation

MonochordThe physics of a vibrating string

Why does a guitar sound brighter when plucked near the bridge, and a piano’s low notes slightly out of tune?

Monochord on a desktop screen
Monochord on a phone

Summary

Pluck, strike and hear a physically modelled stiff string simulated at audio rate, and compare its measured overtones with theory.

What you can do

  • Drag the string and let go: hear it, and watch it vibrate in slow motion.
  • A live spectrum and waterfall with the predicted partials and the “missing harmonics” of the pluck point.
  • Pluck, strike with a felt hammer, or bow; seven presets from published string data.
  • Experiments for pluck position, stiffness, damping and pickup position, plus a two-octave keyboard.
  • A table of measured versus predicted partials.

How it works

An explicit finite-difference scheme for the stiff, damped string (Bilbao) runs one step per audio sample in an AudioWorklet, right at its stability limit. The same physics module drives the sound, the slow-motion drawing, the tests and the validation script.

The hard part

Running a stable PDE solver at 48 000 steps a second on the audio thread, and showing with real numbers where it agrees with theory and where numerical dispersion appears.

Validation

f₀ of a near-ideal string, 82–440 Hz
within 0.005 cents of theory
Stiff-string partials vs n·f₀·√(1 + Bn²)
within the scheme’s own dispersion
Pluck at L/3: partials 3, 6, 9
110–119 dB below their neighbours
Lossless energy, every preset, 1 s
drift ≤ 7.3 × 10⁻¹³
Bowed violin, nylon and E4 strings
Helmholtz motion, harmonics within 0.01 ¢

Built with

  • TypeScript
  • Web Audio
  • AudioWorklet
  • Canvas
  • KaTeX

Skills it demonstrates

  • Numerical PDEs
  • Digital signal processing
  • Acoustics