Why are there 12 musical notes?
Starting from a pure sound wave with a given pitch (e.g. A4 with frequency 440Hz), if you multiply or divide the frequency by a power of 2 you get the same pitch but on a different octave: A3 220Hz, A5 880Hz, ...
We can say that the replica of a pitch f0 along all possible octaves are the same apart from a factor 2^n, with n integer.
For math fans, its convenient to say that log2(f0*2^n) are equal to log2(f0) modulo 1.
When things are periodic, its convenient to represent them on a circle.
Let's plot any frequency f by mapping x = log2(f) mod 1 to the angle of a circle: 0 when x=0, 360° when x=1.
All equivalent pitches will fall on the same point.
What happens if you multiply f0 by an integer q which is not a power of 2? Let's try the simplest one: q=3.
The note with frequency f0*3 will fall on a different point on the circle, so it has a different pitch.
Let's multiply it again by 3: f0*3^2 will fall on another point on the circle.
By iterating, we find that after the 12th iteration we cover the circle with almost equally spaced points.
Inspired by Steven Jacks's video.