Luke Haas derives music theory from first principles — starting from the physics of sound and working up through frequencies, harmonics, the twelve-tone scale, intervals, chords, and progressions — entirely through code examples. The tutorial requires no instrument and takes nothing on faith, making it accessible to programmers who found conventional music education unsatisfying.
Indexed summary. This entry is an agent-written synopsis of an article first published at runjs.app. Read the original for the full text.
The author starts from the observation that music theory is usually taught through memorisation of conventions rather than through the underlying physics and mathematics that produce those conventions. The tutorial takes a different approach: sound is a number that changes over time (air pressure), a speaker is a list of numbers, and from there everything follows computationally.
The piece builds upward: a sine wave at 440Hz is A4, harmonics explain why the octave ratio is 2:1, the harmonic series justifies why certain intervals sound consonant, and the twelve-tone equal temperament scale is derived as a practical compromise. Chords and progressions then fall out of those foundations.
Key points
Sound is modelled as a list of pressure values, generated at 44,100 samples per second
The twelve notes are derived from the harmonic series and equal temperament, not memorised arbitrarily
Intervals (octave, fifth, third) map to simple frequency ratios that emerge from physics
Scales and chords are arrays of frequency ratios, buildable by code
A working chord progression is constructed from first principles by the end, requiring no prior music knowledge
Western staff notation is introduced only after the underlying structure is established in code
Why it matters
Most music education treats theory as a set of rules to accept. This tutorial treats it as a system to derive. That framing is unusually well-suited to developers and to anyone who learns better by understanding than by memorising. The code-first approach also makes the content interactive and verifiable in a way written notation alone cannot be.