# The frequency assignment of musical notes

# The notes

First, let’s define what is a *note*.

A note is an element of the countable set $N$. Here exists a bijection from $\mathbb Z$ to $N$ denoted as $k\mapsto \nu_k$. Therefore, all notes form a sequence \begin{equation*} \dots,\nu_{-2},\nu_{-1},\nu_0,\nu_1,\nu_2,\dots \end{equation*}

Our goal is to define a *frequency assignment*, which is a mapping
$f:N\rightarrow\mathbb R$, whose meaning is the frequency (in Hz)
of the sound of a note.

It is a natural idea to define a sequence \begin{equation*} f_k:=f\left(\nu_k\right). \end{equation*} It makes sense that the sequence is in strictly increasing order.

# The octaves

Now, let’s think about a *musical interval*. At this stage, a
musical interval can be defined as an unordered pair of notes.
After long time of experimenting, people find that they tend to
think a musical interval extremely harmonic if it consists of
such two notes that the frequency of one of them doubles that of
the other.

In other words, the musical interval of $\nu_a$ and $\nu_b$ is extremely harmonic if $f_b=2f_a$. In fact, it is so harmonic that if the two notes are played simultaneously, a person tend to think there is only one note being played:

```
motif = c4 c g g a a g2
piano:
V1: o4 motif motif
V2: o5 motif
```

The audio above is an illustration for octave intervals. As can be heard, the first part of the audio is played in octave intervals while the second part is played in single notes.

Considering that, here comes an amazing idea by which we can kind
of make the sequence $\left\{f_k\right\}$ seem “periodic”.
Let the “period” be denoted as $n$. Because it is not virtually
periodic, we tend to call it an *octave* instead of a period.
After that, the constant $n$ is the length of an octave.

What on earth is an octave defined? It is
\begin{equation*}
\forall k:f_{k+n}=2f_k.
\end{equation*}
Why do we say an octave is like a period? It is because according
to the explanation above, corresponding notes in different octaves
sound so harmonic that a person almost think they are the same.
In this way, for some questions, we only need to consider
a single octave instead of all notes.
Let’s define the *base octave*, notes of which can generate all
other notes by multiplying the frequency by a power of 2:
\begin{equation*}
O_0:=\left\{\nu_k\middle|k\in T\right\},
\end{equation*}
so we can say the frequency assignment has $n$ different tones.
A *tone* is an integer in
\begin{equation*}
T:=\left[0,n\right)\cap\mathbb Z
\end{equation*}
representing where a note is in an octave.

We can thus define a sequence of octaves \begin{equation*} O_m:=\left\{\nu_{k+mn}\middle|\nu_k\in O_0\right\}. \end{equation*} In fact, any octave can be the base octave. They are all the same. For any $m$, all notes can be generated by notes in $O_m$.

\begin{array}{|c|cccccc|}
\hline
T & \cdots & O_{-1} & O_0 & O_1 & O_2 & \cdots
\\ \hline
0&\cdots& \nu_{-n}&\nu_0& \nu_l & \nu_{2n}&\cdots\\

1&\cdots&\nu_{-n+1}&\nu_1&\nu_{n+1}&\nu_{2n+1}&\cdots\\

2&\cdots&\nu_{-n+2}&\nu_2&\nu_{n+2}&\nu_{2n+2}&\cdots
\\

\cdots&\cdots&\cdots&\cdots&\cdots&\cdots&\cdots
\\

n-1&\cdots&\nu_{-1}&\nu_{n-1}&\nu_{2n-1}&\nu_{3n-1}&\cdots
\\ \hline
\end{array}

If we define $p_k:=\log_2f_k$, it is interesting to see that \begin{equation*} \forall k:p_{k+n}=p_k+1. \end{equation*} From that, we can naturally think an excellent frequency assignment be defined as \begin{equation} p_k:=p_0+\frac kn, \label{p_freq_def} \end{equation} which is an elegant arithmetic progression.

# The octave group

Note that here “group” is the group concept in algebra.

Let $O_0$ be isomorphic to the additive group of
$\mathbb Z/n\mathbb Z$, the integers modulo $n$,
under the isomorphism $k\mapsto\nu_k$, which means to
make $O_0$ a cyclic group of order $n$. I call this group an
*octave group*.

To make you have a good sense of what on earth the group looks like, the definition of its group operation can be defined as \begin{equation} \nu_a\circ\nu_b:=\nu_{\left(a+b\right)\mathbin\%n}, \label{group_op_def} \end{equation} where $x\mathbin\%y:=x-y\left\lfloor\frac xy\right\rfloor$.

Note that this binary operator $\circ$ can be extended to be used for the whole $N$ while the definition remains the same as Formula \ref{group_op_def}.

The octave group has a musical meaning which we should take a further look at musical intervals to find out.

# The musical intervals

Taking Formula \ref{p_freq_def}, people find that although it is sometimes subjective whether a musical interval sounds harmonic or not, it does not depend on where the interval is located but on how far the two notes making up the interval are.

Taking this sense, we can consider only those intervals involving $\nu_0$ because we can always translate a interval so that one of its notes is $\nu_0$. Taking this idea, we can conclude that an interval can be represented by a note $\nu_k$ because the interval is equivalent to another interval which consists of $\nu_0$ and $\nu_k$.

We can make this idea even further. Previously, I have stated that a note can always be generated by a note in $O_0$. Therefore, an interval can be represented as a note in $O_0$.

Now, let’s look back to the octave group $\left(O_0,\circ\right)$. Denote the interval $b$ as that represented by $\nu_b$. Then, translate interval $b$ to such a location that its lower note is $\nu_a$. Then, its higher note represents the same interval as $\nu_a\circ\nu_b$.

Well, why do we focus on the group? It is because we need to mention an important concept in group theory, which is “generator”. It has something to do with determining the value of $n$.

The value of $p_0$ does not matter because changing it is just a translation of the whole sequence. What really matters is the value of $n$.

The inventor of the current prevailing frequency assignment (which is the $12$-tone equal temperament shown in Formula \ref{12_equal_def}) may think the generator of the group a vital thing. Actually, people think it a wonderful thing that a note representing a very harmonic interval is a generator of the octave group.

Fortunately, such a goal is achievable. People find that if $p_b=p_a+\frac7{12}$, then the interval (which is the perfect fifth interval if you know music theory) consisting of $\nu_a$ and $\nu_b$ sounds very harmonic:

```
motif = e4 a f2 d4 g c2
piano:
V1: motif
V2: (transpose 7) motif
```

Furthermore, as can be seen in the following table, $\nu_7$ is a generator of the group $O_0$ if $n:=12$. \begin{array}{|c|cccccccccccc|} \hline j&0&1&2&3&4&5&6&7&8&9&10&11 \\\hline \nu_7^{\circ j}& \nu_0&\nu_7&\nu_2&\nu_9&\nu_4&\nu_{11}&\nu_6&\nu_1& \nu_8&\nu_3&\nu_{10}&\nu_5 \\\hline \label{generator} \end{array} Thus, wonderful! Let’s take $n:=12$.

# The $12$-tone equal temperament

The $12$-tone equal temperament is the most popular frequency assignment used nowadays. It is defined as \begin{equation} f_k:=16.3516\cdot 2^\frac k{12}, \label{12_equal_def} \end{equation} which can be derived from Formula \ref{p_freq_def} taking \begin{equation*} p_0:=4.03136\qquad n:=12. \end{equation*}

The frequency assignment has $12$ different tones, $7$ of which
have their names:
\begin{align*}
\mathrm C_m&:=\nu_{12m},\\

\mathrm D_m&:=\nu_{12m+2},\\

\mathrm E_m&:=\nu_{12m+4},\\

\mathrm F_m&:=\nu_{12m+5},\\

\mathrm G_m&:=\nu_{12m+7},\\

\mathrm A_m&:=\nu_{12m+9},\\

\mathrm B_m&:=\nu_{12m+11}.
\end{align*}
The famous “middle C” is $\mathrm C_4$.

This notation is called the
*scientific pitch notation*.

Note that in fact, this definition of $12$-tone equal temperament has some slight error. The accurate value for $p_0$ is \begin{equation*} p_0:=\log_255-\frac74 \end{equation*} because it is stipulated that $f\left(\mathrm A_4\right)=440$, which is standardized as ISO 16 and known as A440.

# Why $\frac 7{12}$

People think if the ratio of two frequencies is a simple rational number, then the interval of the two notes is harmonic.

$2^\frac 7{12}\approx\frac32$, which is a simple ratio. Harmonic, huh.

(Finally, as is a notice, codes appearing above are alda codes, which are used to write music.)