Why There Are Twelve Notes: Music Theory from First Principles
Music Theory for Programmers

A programmer who can't play an instrument derives music theory from scratch using code. Starting with a single sine wave, they explain pitch, timbre, and the harmonic series, showing why simple frequency ratios sound good and why there are twelve notes in an octave. Along the way, they build scales, chords, and a chord progression using the Web Audio API—no instrument or prior knowledge required.
The simpler the fraction, the better it sounds.
- theanonymousone
How come the same article has been posted four times in the past 18 days? https://news.ycombinator.com/from?site=runjs.app
Doesn't HN have a temporal deduplication system?
- kmoser
This article is quite well done, especially from a programmer's perspective, but falls flat (no pun intended) for me because of my terrible ear for pitch.
> Here are five notes. Every one is double the frequency of the one before it. [...] They are different pitches, and yet they sound like the same note.
Nothing about these notes seem similar to me. You could play pretty much any sequence of rising notes and (falsely) claim they're the "same note" and I'd believe it. This is one reason I've always had trouble learning music.
> √2 the awkward one -> 311.13Hz
That one doesn't sound particularly awkward to me. Again, I blame my inability to distinguish pitch.
The only instrument I was able to pick up pretty easily was drums.
- ergonaught
I want to read it, because it’s interesting. And yet.
https://bcantrill.dtrace.org/2026/09/05/the-revolt-of-the-re...