A musician will call the frequency of a sound its pitch. When the frequencies of two pitches differ by a factor of two, we say they harmonize. We call this interval between the two pitches an octave. This perception of harmony happens because the two sounds reinforce each other completely. Indeed, some people have trouble telling two notes apart when they differ by an octave.
This trivial example of harmony is true for all powers of two, including .
Classical European music divided that perfectly harmonious “factor of two” interval into eight asymmetric steps; for this historical reason, it is called an octave. Other cultures divide this same interval into different numbers of steps with different intervals.
More modern European music further subdivides the octave, creating a 12-step system. The most modern version of this system has 12 equally spaced intervals, a net simplification over the older 8-step system. The pitches are assigned names using flats () and sharps (), leading to each pitch having several names. We’ll simplify this system slightly, and use the following 12 names for the pitches within a single octave:
The eight undecorated names (A through G and an A with a frequency double the original A) form our basic octave; the additional notes highlight the interesting asymetries. For example, the interval from A to B is called a whole step or a second, with A being half-way between. The interval from B to C, however is only a half step to begin with. Also, it is common to number the various octaves as though the octaves begin with the C, not the A. So, some musicians consider the basic scale to be C, D, E, F, G, A, B, with a C in the next higher octave. The higher C is twice the frequency of the lower C.
The tuning of an instrument to play these pitches is called its temperament. A check on the web for reference material on tuning and temperament will reveal some interesting ways to arrive at the tuning of a musical instrument. It is suprising to learn that there are many other ways to arrive at the 12 steps of the scale. This demonstrates that our ear is either remarkably inaccurate or remarkably forgiving of errors in tuning.
We’ll explore a number of alternate systems for deriving the 12 pitches of a scale. We’ll use the simple equal-temperament rules, plus we’ll derive the pitches from the overtones we hear, plus a more musical rule called the circle of fifths, as well as a system called Pythagorean Tuning.
Interesting side topics are the questions of how accurate the human ear really is, and can we really hear the differences? Clearly, professional musicians will spend time on ear training to spot fine gradations of pitch. However, even non-musicians have remarkably accurate hearing and are easily bothered by small discrepencies in tuning. Musicians will divide the octave into 1200 cents. Errors on the order of 50 cents, 1/24 of the octave, are noticable even to people who claim they are “tone deaf”. When two tunings produce pitches with a ratio larger than 1.0293, it is easily recognized as out of tune.
These exercises will make extensive use of loops and the list data structure.
The equal temperament tuning divides the octave into twelve equally sized steps. Moving up the scale is done by multiplying the base frequency by some amount between 1 and 2. If we multiply a base frequency by 2 or more, we have jumped to another octave. If we multiply a base frequency by a value between 0 and 0.5, we have jumped into a lower octave. When we multiply a frequency by values between 0.5 and 1, we are computing lower pitches in the same octave. Similarly, multiplying a frequency by values between 1 and 2 computes a higher pitch in the same octave.
We want to divide the octave into twelve steps: when we do a sequence of twelve multiplies by this step, we should arrive at an exact doubling of the base frequency.
The steps of the octave, then, would be .
This step value, therefore is the following value.
If we multiply this 12 times for each of the 12 steps, we find the following.
For a given pitch number, p, from 0 to 88, the following formula gives us the frequency. We can plug in a base frequency, b of 27.5 Hz for the low A on a piano and get the individual pitches for each of the 88 keys.
Actual piano tuning is a bit more subtle than this, but these frequencies are very close to the ideal modern piano tuning.
Equal Temperament Pitches. Develop a loop to generate these pitches and their names. If you create a simple tuple of the twelve names shown above (from A to G ), you can pick out the proper name from the tuple for a given step, s, using int( s % 12 ).
Check Your Results. You should find that an “A” has a pitch of 440, and the “G” ten steps above it will be 783.99 Hz. This 440 Hz “A” is the most widely used reference pitch for tuning musical instruments.
A particular musical sound consists of the fundamental pitch, plus a sequence of overtones of higher frequency, but lower power. The distribution of power among these overtones determines the kind of instrument we hear. We can call the overtones the spectrum of frequencies created by an instrument. A violin’s frequency spectrum is distinct from the frequency spectrum of a clarinet.
The overtones are usually integer multiples of the base frequency. When any instrument plays an A at 440 Hz, it also plays A’s at 880 Hz, 1760 Hz, 3520 Hz, and on to higher and higher frequencies. While we are not often consciously aware of these overtones, they are profound, and determine the pitches that we find harmonious and discordant.
If we expand the frequency spectrum through the first 24 overtones, we find almost all of the musical pitches in our equal tempered scale. Some pitches (the octaves, for example) match precisely, while other pitches don’t match very well at all. This is a spread of almost five octaves of overtones, about the limit of human hearing.
Even if we use a low base frequency, b, of 27.5 Hz, it isn’t easy to compare the pitches for the top overtone, , with a lower overtone like : they’re in two different octaves. However, we can divide each frequency by a power of 2, which will normalize it into the lowest octave. Once we have the lowest octave version of each overtone pitch, we can compare them against the equal temperament pitch for the same octave.
The following equation computes the highest power of 2, , for a given overtone multiplier, , such that .
Given this highest power of highest power of 2, , we can normalize a frequency by simple division to create what we could call the first octave pitch, .
The list of first octave pitches arrives in a peculiar order. You’ll need to collect the values into a list and sort that list. You can then produce a table showing the 12 pitches of a scale using the equal temperament and the overtones method. They don’t match precisely, which leads us to an interesting musical question of which sounds “better” to most listeners.
Overtone Pitches. Develop a loop to multiply the base frequency of 27.5 Hz by values from 3 to 24, compute the highest power of 2 required to normalize this back into the first octave, , and compute the first octave values, . Save these first octave values in a list, sort it, and produce a report comparing these values with the closest matching equal temperament values.
Note that you will be using 22 overtone multipliers to compute twelve scale values. You will need to discard duplicates from your list of overtone frequencies.
Check Your Results. You should find that the 6th overtone is 192.5 Hz, which noralizes to 48.125 in the fist octave. The nearest comparable equal-tempered pitch is 48.99 Hz. This is an audible difference to some people; the threshold for most people to say something sounds wrong is a ratio of 1.029, these two differ by 1.018.
When we look at the overtone analysis, the second overtone is three times the base frequency. When we normalize this back into the first octave, it produces a note with the frequency ratio of 3/2. This is almost as harmonious as the octave, which had a frequency ratio of exactly 2. In the original 8-step scale, this was the 5th step; the interval is called a fifth for this historical reason. It is also called a dominant. Looking at the names of our notes, this is “E”, the 7th step of the more modern 12-step scale that starts on “A”.
This pitch has an interesting mathematical property. When we look at the 12-step tuning, we see that numbers like 1, 2, 3, 4, and 6 divide the 12-step octave evenly. However, numbers like 5 and 7 don’t divide the octave evenly. This leads to an interesting cycle of notes that are separated by seven steps: A, E, B, F , C , ....
We can see this clearly by writing the 12 names of notes around the outside of a circle. Put each note in the position of an hour with A in the 12-o’clock position.
You can then walk around the circle in groups of seven pitches. This is called the Circle of Fifths because we see all 12 pitches by stepping through the names in intervals of a fifth.
This also works for the 5th step of the 12-step scale; the interval is called a fourth in the old 8-step scale. Looking at our note names, it is the “D”. If we use this interval, we create a Circle of Fourths.
Write two loops to step around the names of notes in steps of 7 and steps of 5. You can use something like range( 0, 12*7, 7 ) or range( 0, 12*5, 5 ) to get the steps, s. You can then use names[s % 12] to get the specific names for each pitch.
You’ll know these both work when you see that the two sequences are the same things in opposite orders.
Circle of Fifths Pitches. Develop a loop similar to the one in the overtones exercise; use multipliers based on 3/2: 3/2, 6/2, 9/2, .... to compute the 12 pitches around the circle of fifths. You’ll need to compute the highest power of 2, using (2), and normalize the pitches into the first octave using (3).
Save these first octave values in a list, indexed by s % 12; you don’t need to sort this list, since the pitch can be computed directly from the step.
Rational Circle of Fifths. Use the Python rational number module, fractions to do these calculations, also.
Check Your Results. Using this method, you’ll find that “G” could be defined as 49.55 Hz. The overtone analysis suggested 48.125 Hz. The equal temperament suggested 48.99 Hz.
When we do the circle of fifths calculations using rational numbers instead of floating point numbers, we find a number of simple-looking fractions like 3/2, 4/3, 9/8, 16/9 in our results. These fractions lead to a geometrical interpretation of the musical intervals. These fractions correspond with some early writings on music by the mathematician Pythagoras.
We’ll provide one set of commonly-used list of fractions for Pythagorean tuning. These can be compared with other results to make the whole question of scale tuning even more complex.
Pythagorean Pitches. Develop a simple representation for the above ratios. A list of tuples works well, for example. Use the ratio to compute the frequencies for the various pitches, using 27.5 Hz for the base frequency of the low “A”. Compare these values with equal temperament, overtones and circle of fifths tuning.
Check Your Results. The value for “G” is .
The subject of music is rich with cultural and political overtones. We’ll try to avoid delving too deeply into anything outside the basic accoustic properties of pitches. One of the most popular alternative scales divides the octave into five equally-spaced steps. This tuning produces pitches that are distinct from those in the 12 pitches available in European music.
The original musical tradition behind the blues once used a five step scale. You can revise the formula in (1) to use five steps instead of twelve. This will provide a new table of frequencies. The intervals should be called something distinctive like “V”, “W”, “X”, “Y”, “Z” and “V” in the second octave.
Five-Tone Pitches. Develop a loop similar to the 12-tone Equal Temperament (Equal Temperament) to create the 5-tone scale pitches. Note that the 12-tone scale leads to 88 distinct pitches on a piano; this 5-tone scale only needs 36.
Compare 12-Tone and 5-Tone Scales. Produce a three column table with the 12-tone pitch names and frequencies aligned with the 5-tone frequencies. You will have to do some clever sorting and matching. The frequencies for “V” will match the frequencies for “A” precisely. The other pitches, however, will fall into gaps.
The resulting table should look like the following
|name 12||freq.||name 5||freq.|