n = 0 1 2 3 4 5 6 7 8 9 10 11 12
C D E F G A B C
C = (Middle C) A=440 (hz)
The distance between each number is a "half step" in music.
Frequency Function
$$
\begin{equation}
f(n) = 440 \cdot 2^{\frac{1}{12}(n-9)} (\text{Hz})
\end{equation}
\tag{Eq 1}
$$
Using the note A=440 Hz as reference, Eq (1) gives the frequency of the note. (In 12-TET tuning) The number n is the
pitch class .
Pitch Class Function Derivation
$$
\begin{align*}
f(n) &= 440 \cdot 2^{\frac{1}{12}(n-9)}\\
\frac{f(n)}{440} &= 2^{\frac{1}{12}(n-9)}\\
\log_2\left(\frac{f(n)}{440}\right) &= \frac{1}{12}(n-9)\\
12\cdot \log_2\left(\frac{f(n)}{440}\right) &= n-9\\
n &= 12\cdot\log_2\left(\frac{f(n)}{440}\right) +9\\
F &= f(n)
\end{align*}
$$
$$
\begin{equation}
P(F) = 12\cdot\log_2\left(\frac{F}{440}\right) +9 = n
\end{equation}
\tag{Eq 2}
$$
Eq (2) may be used to extract the pitch class n from a given frequency.
The Sound of a Fifth
Multiples of a Base Frequency:
Octave 2
Fifth 3/2
Fourth 4/3
Major Third 5/4
Minor Third 6/5
-- 7/6
-- 8/7
Whole Step 9/8
n = 0 1 2 3 4 -- 5 6 7 8 9 10 11 --12
1 2 3 -- 4 5 6 7 -- 8
C D E -- F G A B -- C
Base Third Forth Fifth Octave
Evaluating Eq (1) at n=0 and n=7 the frequency of two notes C and G can be determined. Playing notes C and G together is the sound of a "perfect" fifth. Perfect because the ancient greeks liked the ratio 3/2. You might notice that \(C\cdot 3/2\) does not exactly equal G, it is off by 0.4429 Hz. I tried playing the notes together (both \(G_1\) and \(G_2\)) with C and I can't hear the difference.
$$
\begin{align*}
C &= f(0) = 261.626 (\text{Hz})\\
G_1 &= f(7) = 391.995 (\text{Hz})\\
G_2 &= C\cdot3/2 = 392.438 (\text{Hz})
\end{align*}
$$
Notes C and \(G_1\) played together.
Notes C and \(G_2\) played together.
Different Ratios of C
Octave (2)
Fifth (3/2)
Fourth (4/3)
Major Third (5/4)
Minor Third (6/5)
Ratio (7/6)
Ratio (8/7)
The last 2 ratios are not part of the standard 12 note scale. There are ways to express these notes but the 5 line staff is not built for them. You could keep going as well.
The Sound of a Whole Step
$$
\begin{align*}
C &= f(0) = 261.626 (\text{Hz})\\
D_1 &= f(2) = 293.665 (\text{Hz})\\
D_2 &= C\cdot9/8 = 294.329 (\text{Hz})
\end{align*}
$$
The diference here is .664 Hz. (I can barely hear it)
Whole Step(9/8)
(Notes C and \(D_2\) played together.)
Whole Step(Pitch Class Difference of 2)
(Notes C and \(D_1\) played together.)
The Sound of a Half Step
$$
\begin{align*}
C &= f(0) = 261.626 (\text{Hz})\\
C\# &= f(1) = 277.183 (\text{Hz})\\
\end{align*}
$$
(Notes C and C# played together.)
The Sound of 1Hz
$$
\begin{align*}
C &= f(0) = 261.626 (\text{Hz})\\
C_1 &= C+1 = 262.626 (\text{Hz})\\
\end{align*}
$$
(Notes C and \(C_1\) played together.)
Matlab Code
fs = 44100;
t = 0 : 1/fs : 10; %10 seconds
F = @(n) 440*2^((n-9)/12); %Pitch Class to Freq function
S = @(f) 0.1*sin(2*pi*f*t); %time domain signal function
f1 = F(0); %Middle C (12TET)
f2 = F(7); %G
f3 = f1*3/2; %G = (C*3/2)
s_TET = S(f1) + S(f2); %12TET fifth
s_PY = S(f1) + S(f3); %pythagorean fifth
audiowrite('CG_TET.mp4',s_TET,fs)
audiowrite('CG_PY.mp4',s_PY,fs)