Why 12 notes in the Chromatic Scale?

If you've dabbled in a bit of music, or if you've ever seen a piano, you should be familiar with this image.

These are the keys on the piano that make up the Chromatic Scale.

As you can see, there are $12$ keys in the scale: $7$ white, and $5$ black. Curious as you are, you may wonder: "Why are there 12 keys on the piano? Is there a reason, or was it arbitrary? Could there be more, or less keys?"

There are probably other reasons for the Chromatic Scale being the way it is, but this is the way I think about it:

The Chromatic Scale is the most practical approximate scale that includes a base frequency, $\frac{3}{2}$ the base, twice the base, is periodic, and whose frequencies increase at a constant ratio.

It's a bit of a mouthful, but I'll get to explaining it soon enough.


First of all, why include the base frequency ($f$), $\frac{3}{2}f$ and $2f$ in the scale? We include $2f$ because people perceive $f$ and $2f$ as being essentially the same note, no matter what frequency $f$ is.

For example, the pitch $A4$ has the frequency $440Hz$ and $A5$ has the frequency $880Hz$. We call both of them $A$ because $A5$ has double the frequency of $A4$. Similarly $A3$ is $220Hz$ and $A2$ is $110Hz$.

We also include $\frac{3}{2}f$ since people also perceive it as sounding "smooth", "constant", or even "very nice". It is such a smooth sound that the $\frac{3}{2}$ frequency ratio is known as a "perfect fifth", and is the building block of not just the Chromatic Scale, but other scales like the Major, and the Pentatonic Scale, which is maximally saturated with perfect fifths.


Second, why should the scale be periodic? The periodicity of the scale is key to having a limited set of pitch classes, while being able to increase and decrease pitch beyond $f$ and $2f$. Concretely, by making the scale periodic we can have the pitches $A3$, $A4$, $A5$, ..., who all belong to the pitch class $A$, by repeating the structure of the scale every doubling of $f$. In other words, the pitch classes from $f$ to $2f$ will be the same as the ones from $2f$ to $4f$, except that all the pitches (the frequencies) are doubled.

Logarithmic perception

Alright, so good so far. How about the last restriction - the ratio of the pitches between consecutive notes being constant - Why is this a restriction we would want?

Hmm, this one is a bit tougher, and since my knowledge of music theory is somewhat limited, I can only hazard a guess that it's related to acoustic perception.

You see, our ears don't perceive sounds in a way that might be intuitive for some. Our ears perceive frequency logarithmically, or in other words, we sense $A3(220Hz)$, $A4(440Hz)$ and $A5(880Hz)$ as being the same distance away from each other, even though the differences between the frequencies is not constant.

The ratio between the frequencies, however, is indeed constant. $880Hz$ is twice $440Hz$, which is twice $220Hz$. So, if we want the notes on the scale to sound all the same step apart, we need the frequencies to increase by a multiplicative step.

Deriving the Chromatic Scale

Having explained why we are making all of the assumptions we are making, let's get started with deriving the Chromatic Scale.

Our goal here is to assign to each frequency a number, or an index, that represents the number of the note to play. A frequency with index $0$ is the frequency of the first note. A frequency with index $1$ is the frequency of the second note, etc.

So, we want to find a function $f: F \rightarrow ℕ$, that maps frequencies to numbers, given the previous restrictions. For clarity and simplicity, I'm going to represent the base frequency as $1$, and therefore it's double as $2$, and the half way point as $\frac{3}{2}$.

The first restriction gives us the assertions $$ \begin{align} f(0) &= 1 \cr f(p) &= 2 \cr \exist m:ℕ. \ f(m) &= 3/2 \cr \end{align} $$ where $p$ is the period/size of the scale and $m$ is the note corresponding to the middle frequency $\frac{3}{2}$.

The second restriction tells us that $$ \begin{align} f(n + p) = 2 f(n) \end{align} $$

By unraveling this equation, along with $(1)$ and $(2)$ we find that $$ \begin{align*} f(0) = 1; \ \ f(p) &= 2; \ \ f(2p) = 4; \cr \ \ f(3p) = 8; & \ f(4p) = 16... \end{align*} $$ and in general, we can show that $$ \begin{equation} f(np) = 2^n \end{equation} $$

The third restriction forces that consecutive notes have a constant ratio of pitches and so $$ \begin{equation} \forall n:ℕ, \exist r:ℝ. \frac{f(n+1)}{f(n)} = r \end{equation} $$

Expanding this definition a bit, and with $(1)$, we get that $$ \begin{equation*} f(0) = 1; \ \ f(1) = r; \ \ f(2) = r^2; \ \ f(3) = r^3... \end{equation*} $$ and in general, $$ \begin{equation} f(n) = r^n \end{equation} $$

Putting it all together

Wheeww! Those were a lot of symbols just to express our assumptions. But now, we can get to the meat of the problem: finding the size and frequencies of the scale.

We want to find a closed form for $f(n)$, so let's starting by joining togeter equations $(3)$ and $(7)$.

$$ \begin{align} f(m) = \frac{3}{2} &= r^{m} \cr \Big(\frac{3}{2}\Big)^{\frac{1}{m}} = r \end{align} $$

So we can write the ratio $r$ in terms of the index of the "perfect fifth". Cool, some progress.

Now let's join that up with $(5)$ and see what we get

$$ \begin{align*} f(np) = 2^n &= r^{np} \cr 2 &= r^{p} \cr 2 &= \Big(\frac{3}{2}\Big)^{\frac{p}{m}} \cr 2^{\frac{m}{p}} &= \frac{3}{2} \end{align*} $$ Taking the logarithm base $2$ ($\lg$) on both sides we find out that $$ \begin{align*} \frac{m}{p} &= \lg\Big(\frac{3}{2}\Big) \cr &= \lg(3) - \lg(2) \cr &= \lg(3) - 1 \end{align*} $$

Alright! All we have to do now is write $\lg(3) - 1$ as a fraction and we find our $m$ and our $p$!

But wait... Something's off. checks notes. Yep, I thought so.

So, it turns out that $\lg(3)$ is an irrational number, because if it wasn't you would have $2^p = 3^q$ for some pair $p$ and $q$, which is impossible since the left side is even and the right side is odd.

It seems it is impossible for our scale to exist, which is sad, given all the work we've put in so far in finding it. You know what? Let's just keep going! You heard me. Let's forget about the fact that $\lg(3)$ is irrational, and let's just find a "pretty good" rational approximation for $\lg(3) - 1$.

I'll spare you the details, but by finding truncated continued fractions of $\lg(3) - 1$ we get these rational approximations: $$ \frac{1}{2} \ \ \frac{3}{5} \ \ \frac{7}{12} \ \ \frac{24}{41} \ \ \frac{31}{53} \ \ \frac{179}{306} \ \ \frac{389}{665} ... $$

If we choose $\frac{1}{2}$ as our approximation, we get a $14%$ error, $\frac{3}{5}$ gives a $2%$ error, $\frac{7}{12}$ gives a $0.2%$ error and $\frac{24}{41}$ gives a $0.07%$ error. I won't keep going, since choosing $\frac{24}{41}$ as our approximation would imply having 41 notes in our scale, which to me sounds a bit excessive.

So, we choose the next best thing: $\frac{7}{12}$

Close enough!

So with all of that out of the way, $$ \begin{align*} \frac{m}{p} &= \frac{7}{12} \cr m = 7 \ \ &\text{and} \ \ p = 12 \end{align*} $$

So the period is $12$ and we have $12$ notes in the scale! Just as we wanted! We also get the added bonus of finding that the perfect fifth is the $8$th note in the scale, or the note with index $7$.

We can use equation $(9)$ to find the pitch ratio $r$, which would be $\Big(\frac{3}{2}\Big)^{\frac{1}{m}} \approx 1.059634...$.

Due to our approximation this $r$ isn't quite constant. For example, $$ \begin{align*} f(p) = f(12) = 2 &= r^{12} \cr r &= 2^{\frac{1}{12}} \cr r &\approx 1.059463 \end{align*} $$

which is slightly off from the previous $r$.

The standard Chromatic Scale uses $2^{\frac{1}{12}}$ as the ratio between notes, which makes the first note and the 12th have exactly twice the frequency. However the perfect fifth is $2^{\frac{7}{12}} \approx 1.498307 \approx \frac{3}{2}$, so perfect fifths aren't exactly perfect.

Wrapping up

This was a fun little exercise into thinking deeply about seemingly mundane and standard things that gives some insight into why they exist in the first place. Octaves are pretty important, and so are perfect fifths. So important in fact, that we base a lot of modern scales on those intervals.

With this little tour we also saw that it is impossible to perfectly tune a piano with a constant ratio of pitches if we want a periodic scale that includes an octave and a perfect fifth.

Maybe by relaxing some of these restrictions, mainly the constant ratio, we can find other scales, such as the Major and the Minor scale.

Hope you enjoyed reading along, see ya!