Thursday, November 23, 2017

Thanksgiving Post: Coding Music on the Computer Emulator

Table of Contents:

1. Pappas and Szpiro
2. Mouse's Tale Song
3. The 3-Limit Waldorf Scale
4. Coding the 3-Limit
5. The 5-Limit Major and Minor Scales
6. Coding the 5-Limit
7. The New 7-Limit Scale
8. Coding the 7-Limit
9. Another Turkey Song
10. Conclusion

Pappas and Szpiro

This is what Theoni Pappas writes on page 23 of her Magic of Mathematics:

"'Contrariwise,' continued Tweedledee, 'if it was so, it might be; and if it were so, it would be: but as it isn't, it ain't. That's logic."
-- Lewis Carroll, Alice in Wonderland

This is the last page of the subsection "The Mouse's Tale." In this page Pappas writes about Lewis Carroll, whose true identity was a mathematician, Charles Dodgson. On this page, she includes one of his poems, A Caucus-Race and a Long Tale. Here is the entire poem:

Fury said to a mouse,
That he met in a house,
"Let us both go to law: I will prosecute you.

"Come, I'll take no denial;
We must have a trial;
For really this morning I've nothing to do."

Said the mouse to the cur,
"Such a trial, dear Sir,
With no jury or judge, would be wasting our breath."

"I'll be judge, I'll be jury,"
Said cunning old Fury;
"I'll try the whole cause and condemn you to death."

I'll have more to say about this poem later in this post. But for now, let's get our other reading book out of the way.

Chapter 6 of George Szpiro's Poincare's Prize is called "From Copenhagen and Hamburg to Black Mountain, North Carolina." Here's how it begins:

"Topological ideas and notions were evident throughout Poincare's early work -- for example, in his study on the sets of solutions to differential equations."

In this chapter, Szpiro discusses algebraic topology, since the conjecture which bears Poincare's name is all about this field. But, as he points out, this isn't Poincare's main field of study:

"Eulogies after his death stressed his contributions to traditional areas of mathematics and physics, with the three-body problem being the most prominent example."

Indeed, it isn't until decades later when algebraic topology is treated as a separate field, and then Poincare's contributions are recognized:

"In his pathbreaking monograph, Treatise on Topology, Solomon Lefschetz wrote, 'Perhaps on no branch of mathematics did Poincare lay his stamp more indelibly than on topology.'"

The author writes about one of Poincare's first lectures on topology:

"'One knows of the important role that a surface's order of connection plays in the theory of functions, even though the notion is borrowed from a wholly different branch of mathematics, namely the geometry of situation or analysis situs,' Poincare told the members of the Academie."

But even the mathematician himself doesn't consider topology to be a major part of his work:

"When asked in 1901 by the Swedish mathematician Gosta Mittag-Leffler to summarize his work up to that point in his life, he devoted no more than 4 pages, out of 103, to analysis situs. (Moreover, these four pages are absent in the eleven-volume collected words of Poincare.)"

Szpiro tells us about Poincare's first paper on topology:

"We also see that Poincare's approach to algebraic topology was intuitive. Unfortunately, intuition often goes hand in hand with lack of rigor."

We begin by defining some key terms, such as manifold:

"Flying carpets correspond, to use technical language, to bounded, two-dimensional manifolds embedded in three-dimensional space."

And here's a word whose definition I alluded to in an earlier post:

"Poincare also explains the notion of homeomorphism: Two shapes are said to be homeomorphic, or topologically equivalent, if one can be deformed into the other by pulling and creasing and crumpling, without tearing and gluing. A carpet is homeomorphic to a quilt but not to a poncho."

His paper attempts to prove the duality theorem, which deals with the Betti numbers of a manifold:

"The duality theorem states that for closed manifolds the k-th Betti number and the (n-k)-th Betti number are identical, The astonishing implication of this theorem is that the orders of connection of such manifolds in various dimensions are not independent of each other but must conform to certain rules."

Here are some examples of Betti numbers, where the leftmost number is the 0th Betti number:


  • circle: (1, 1)
  • sphere: (1, 0, 1)
  • bagel: (1, 2, 1)
  • 3D bagel in 4D space: (1, 3, 3, 1)
Now we get to meet some other early topologists. The "Copenhagen" in the chapter title refers to the Danish doctoral student Poul Heegaard. According to Szpiro, it's surprising that Heegaard would study math, since growing up, he is what I'd call a "dren":

"Until he entered high school, he believed that seven plus eight equals seventeen and he had to use his fingers to add numbers. But little by little, it turned out that he had quite a talent for abstract mathematics."

After he receives his bachelor's degree, he travels to study math in Paris, and seeks to meet Professor Darboux, the dean, in person:

"Heegard waited in the anteroom for forty-five minutes before a secretary told him he might as well leave, because monsieur le professeur had tossed the letter of introduction into the wastebasket."

Fortunately, he receives a much kinder reception in Gottingen, Germany:

"Heegaard found the atmosphere at the University of Gottingen stimulating and conducive to research."

He eventually discovers that Poincare's proof of the duality theorem is, in fact, wrong:

"Heegaard constructed an example of a three-dimensional manifold -- an intersection of a certain cone with a cylinder -- whose Betti numbers are (1, 1, 2, 1). This contradicts the duality theorem."

In the end, Poincare learns of his error and corrects it. As it happens, there are two types of Betti numbers -- reduced Betti numbers, for which the theorem holds, and connectivity numbers, for which the theorem fails.

I don't want to spend too much more time in this chapter, so let me say just a little more. Heegaard eventually tries to prove the four color problem, mentioned in Lesson 9-8 of the U of Chicago text:

"It stated that any geographical map could be painted with no more than four colors such that no two adjacent countries are of the same color."

Unfortunately, his proof is fatally flawed, and the theorem isn't proved until later. Meanwhile, the "Hamburg" in the chapter title refers to German mathematician Max Dehn:

"On the train back, the two men talked about the foundational problems of topology. Dehn suggested an axiomatic approach to this new mathematical science: Postulate as few axioms as possible and let the rest flow from there."

Even though Dehn's family converts to Protestantism, his mother is ethnically Jewish. So the last location mentioned in the chapter title refers to where the mathematician goes to flee the Holocaust:

"Dehn wandered around the United States until he finally found permanent employment at Black Mountain College in North Carolina in 1945."

Szpiro ends the chapter with a certain conjecture of Poincare's:

"Consider a ring-shaped region bounded by two concentric circles. Now transform that region so that the points on the inner circle advance in the clockwise direction, the points on the outer circle, and everything in between is twisted in a smooth fashion. Poincare claimed that there are at least two points in the region that stay at rest."

No, this transformation is clearly not an isometry. And no, this is not the famous Poincare Conjecture, because this one is ultimately proved by George David Birkhoff just a few years later:

"Birkhoff's proof was published in the Transactions of the American Mathematical Society in January 1913 and established him as the foremost American mathematician of the early twentieth century."

And yes, we should recognize the name Birkhoff -- he's the mathematician who formulated the Ruler Postulate, the first postulate in many Geometry texts (though not the U of Chicago text).

Mouse's Tale Song

OK, it's one thing to keep writing about music theory, with Pythagorean thirds and syntonic commas and harmonic sevenths and this and that. It's another thing to hear some actual music -- since, after all, music is all about what sounds right. All the theory in the world is meaningless without sounds.

And so, without further ado, let's program the computer emulator to play some real music. Here's a link to our emulator:

http://www.haplessgenius.com/mocha/

Enter the following program:

10 DIM S(9)
20 FOR X=0 TO 9
30 READ S(X)
40 NEXT X
50 DATA 54,105,96,90,84
60 DATA 81,72,70,63,60
70 N=2
80 FOR X=1 TO 32
90 READ A,B,C
100 SOUND 261-N*S(A),4
110 SOUND 261-N*S(B),4
120 SOUND 261-N*S(C),8
130 NEXT X
140 DATA1,2,1,2,1,3,5,2,3,4,6,0
150 DATA8,9,9,7,8,5,6,6,5,2,4,1
160 DATA1,2,1,2,1,3,5,2,3,4,6,0
170 DATA8,9,9,7,8,5,6,6,5,2,4,1
180 DATA1,4,7,4,5,4,3,3,4,7,7,5
190 DATA5,6,8,9,0,6,9,9,7,5,8,7
200 DATA1,2,1,2,1,3,5,2,3,4,6,0
210 DATA8,9,9,7,8,5,6,6,5,2,4,1

Notice that lines 140, 160, and 200 are identical, as are lines 150, 170, and 210. Before running this program, make sure the "Sound" box is checked. Then type in the magic word:

RUN

The lyrics to this song are in fact Carroll's "Mouse's Tale" poem. If you want, you can try to sing along by scrolling up to the lyrics on this tab and then running the program again on the emulator tab.

How does this program work? Well, lines 10-60 set up our scale. Line 30 tells the computer to "read" the "data" given in lines 50-60 and store them in array S. The numbers in line 30 are the degrees corresponding to our chosen notes.

Then lines 80-210 actually play the song. We see more "read" and "data" lines -- these correspond to the notes to play in the song. For example, the first data line is:

140 DATA1,2,1,2,1,3,5,2,3,4,6,0

This means "play the first note in the scale, then the second note, then the first note, second note, first note, then the third note, the fifth note, and so on." Notice that the numbers stored in the array are degrees -- they must be subtracted from bridge 261 in order to be sounds that the computer can play.

You may ask, why not just store the codes for the sounds in the array, so that the computer doesn't have to keep subtracting degrees from bridge 261? Well, try changing line 70 to:

70 N=1

This raises the whole song by an octave. As you can see, the degrees are multiplied by N, which can equal either 1 or 2, before we subtract them from bridge 261. Recall that N=1 here means that the "string" is shorter (higher notes), while N=2 means that the "string" is longer (lower notes). If we had coded the sounds directly, it would be harder to raise or lower the song by an octave. Instead, by doing it my way, we can change the octave simply by editing a single line, line 70.

Our song has a simple pattern -- two eighth notes (quavers) followed by a quarter note (crochet). I chose this pattern because it fits Carroll's poem. Let's look at the first stanza again:

Fury said to a mouse,
That he met in a house,
"Let us both go to law: I will prosecute you.

The two eighth notes fit the two-syllable name "Fury," while the quarter note fits "said." Then the two eighth notes fit the two short words "to a," with a quarter note for "mouse." This pattern doesn't fit the song perfectly -- for example, the three-syllable word "prosecute" doesn't fit the rhythm. But this simple pattern is close enough -- otherwise, we'd have to include the note lengths into the "data" lines rather than just the notes of the scale.

Oh, and the song follows an AABA pattern -- A for the main verse and B for the "bridge," or middle part of the song (not to be confused with "bridge 261"). This also fits the song, where the man is speaking during the A part and the mouse is speaking during the B part.

All that's left is to explain the scale that I used -- the brand new scale that I devised. The rest of this post is devoted to music theory, and how I determined which notes to include in my new scale.

The 3-Limit Waldorf Scale

We begin with the 3-limit -- that is, degrees based on factors of 2 or 3. The 3-limit is also known as "Pythagorean," since this was the basis of how Pythagoras played music on the lyre.

Our basic 3-limit intervals are:


  • the tonic or perfect unison, 1/1
  • the perfect fourth, 4/3
  • the perfect fifth, 3/2
  • the octave, 2/1
Suppose we had a geometric sequence starting at degree 32 and common ratio 3/2, the perfect fifth:

Degree: 32, 48, 72, 108, 162, 243

These are degrees, not sounds. We convert them to sounds by subtracting them from bridge 261:

Sound: 229, 213, 189, 153, 99, 18

Recall that sounds move in the same direction as the pitch (while degrees move in the opposite direction), so these are descending perfect fifths. We can reverse the order to make them ascending:

Sound: 18, 99, 153, 189, 213, 229

Let's write a program to play these notes. Recall that to start a new program, we must type in:

NEW

Now let's type in a short program for perfect fifths:

10 SOUND 18,16
20 SOUND 99,16
30 SOUND 153,16
40 SOUND 189,16
50 SOUND 213,16
60 SOUND 229,16

When I compare these sounds to my musical keyboard, the second note on the computer (Sound 99) matches up with Middle C on the keyboard. This allows us to make the following correspondences:

Sound     Degree     Note
18           243           F
99           162           C (middle)
153         108           G
189         72             D
213         48             A
229         32             E

We notice that there is no B available in this scale, nor are there any sharps or flats.

The entire 3-limit consists of all degrees which are 3-smooth -- that is, their only prime factors are two and three. The lowest note we can play is Sound 1 (Degree 260), while the highest note we can play is Sound 255 (Degree 6). Between 6 and 260 there are 24 numbers that are 3-smooth, hence there are 24 playable Pythagorean notes. We can name these by multiplying or dividing the degree by 2 (the octave) until we get a note on the list above:

The Entire Playable 3-Limit

Sound     Degree     Note
5             256           E
18           243           F
45           216           G
69           192           A
99           162           C (middle)
117         144           D
133         128           E
153         108           G
165         96             A
180         81             C
189         72             D
197         64             E
207         54             G
213         48             A
225         36             D
229         32             E
234         27             G
237         24             A
243         18             D
245         16             E
249         12             A
252         9               D
253         8               E
255         6               A

As we can see, not all notes are available in all octaves. A note with an odd degree can't be raised an octave, since we can't take half of an odd number and obtain a whole number. This is why the Pythagorean F is only available in the lowest octave, while the two highest octaves have only the notes D, E, and A available.

OK, so this list contains the entire 3-limit, but how can we make a scale out of it? We can't try to make a C major scale because there's no B, nor can we make F major without a B-flat (Bb). And besides, we couldn't make a major scale in the 3-limit anyway, since the just major scale is defined to contain 5-limit intervals, such as 5/4, the major third. In this scale, the interval C-E is a Pythagorean major third, 81/64, which we can see by comparing the degrees in the chart above (that is, Degree 81 is C while Degree 64 is E).

Meanwhile, one scale that has fascinated me recently is the Waldorf scale. Recall that a Waldorf school (mentioned on this blog in a May 2016 post) is a school with a radically different pedagogy from most public schools -- most notably, at K-8 Waldorf schools, students have the same teacher from first all the way up to eighth grades.

Anyway, young first and second grade Waldorf students are taught to play a pentatonic recorder. Here are the notes playable on the Waldorf recorder:

D-E-G-A-B-D-E

There are five different notes here, so this is definitely a pentatonic scale -- but exactly which pentatonic scale? The pattern G-A-B-D-E suggests the G major pentatonic scale, but then again, with an E note below the low G, maybe it's an E minor pentatonic scale.

Well, the official answer is that the Waldorf scale is a "symmetrical" pentatonic scale. The tonic is the "center" note, which is A. We shouldn't interpret the interval G-B as a major third, because 5/4 can't be divided equally into two tones -- instead, one of G-A and A-B would be a major tone 9/8, and the other would be a minor tone 10/9. And besides, making G-B a major third 5/4 would make it seem as if it were G major pentatonic after all. For the same reason, E-G is not the 6/5 minor third.

The easiest way to make the scale symmetrical is to make all the notes Pythagorean. Then we would have B a major tone 9/8 above the center A and G 9/8 below A. The note D is a perfect fourth above the center A and E is a perfect fourth below it. There is also a note E a perfect fifth above the center A with D a perfect fifth below it. The scale is now perfectly symmetrical.

So the Waldorf scale will be our sample 3-limit scale. The only problem is that, once again, the scale requires the note B, which is not available on the computer. Well, that's no problem -- we just drop everything by a perfect fifth. The new center is now the note D:

G-A-C-D-E-G-A

All the notes are now playable on the computer:

The Waldorf Pentatonic Scale:

Sound     Degree     Note
45           216           G
69           192           A
99           162           C (middle)
117         144           D
133         128           E
153         108           G
165         96             A
180         81             C
189         72             D
197         64             E
207         54             G
213         48             A

Notice that there are two possible D notes for the center of this scale.

The original scale D-E-G-A-B-D-E matches the actual Waldorf recorder. It's also more convenient for the guitar, since these notes match the open strings. In fact, we can make as many as four of these notes correspond to the open strings D-G-B-E. On the other hand, our version G-A-C-D-E-G-A is more symmetrical on a piano, since the middle notes C-D-E surround two black keys while the low and high G-A are in among three black keys.

Coding the 3-Limit

As usual, we type in the following command to start a new program:

NEW

Now let's enter the following program:

10 DIM S(7)
20 FOR X=1 TO 7
30 READ S(X)
40 NEXT X
50 DATA 108,96,81
60 DATA 72,64,54,48
70 N=2
80 A$=INKEY$
90 IF A$="" THEN 80
100 A=VAL(A$)
110 IF A>0 AND A<8 THEN SOUND 261-N*S(A),2
120 IF A>7 THEN N=A-7: PRINT "OCTAVE"; N
130 IF A=0 THEN END
140 GOTO 80

In this program, we convert our computer keyboard into a musical keyboard. The "key" function in line 80 is INKEY$This function allows the user to press a key and store it in a string variable, A$. If the user isn't pressing a key, then the empty string "" is returned. Line 90 tells the computer to return to line 80 until a key is actually pressed.

By the way, on the TI graphing calculator, this function is called getkey. If we want the calculator to pause until a key is pressed, we enter:

:Repeat getkey
:End

This means repeat (or wait, since there is actually nothing to repeat) until getkey is true (nonzero), since instead of an empty string, getkey returns zero if no key is pressed. If, on the other hand, we need to determine which key is being pressed, we use:

:Repeat A
:getkey->A
:End

The variable A doesn't need to be initialized, since the Repeat loop is always executed once. (The name Repeat actually goes back to the computer language Pascal.) The TI doesn't have string variables, and so A contains a number, a special code corresponding to the pressed key.

Returning to BASIC, we do have strings, and so A$ contains the actual pressed key. But we don't want a string -- we need a number so we can enter it into the array. Therefore I decided to let the "1" key denote the first note of the scale, the "2" key denote the second note, and so on. Yet we must still convert strings like "1" and "2" into numbers 1 and 2. To do this, we use VAL in line 100.

Since there are seven notes in the Waldorf scale, 1-7, we use "8" and "9" to switch octaves. The "8" key is octave 1 (the high octave) and the "9" key is octave 2 (the low octave).

Ordinarily, the "Esc" key (called "Break" on the old computer) ends the program. But recall that while waiting for a key to be pressed, we loop between lines 80 and 90. If we're on line 90, then "Esc" indeed ends the program, but if we're on line 80, the "Esc" key is stored into A$ and so the program doesn't end. So pressing "Esc" yields only a 50-50 chance of ending the program! To safeguard against this, the "0" key is used to end the program in line 130. Notice that if a letter or other key is pressed, VAL in line 100 returns 0, and so pressing any key other than 1-9 will also end the program.

The 5-Limit Major and Minor Scales

There are three ways to program music on the emulator -- and in fact, all three types of music have been pre-programmed into the emulator.

Let's choose "Music 6" from the "Mount Disk" menu, and then click "Mount Disk." Here "disk" refers to the floppy diskettes that old computers used. Then we enter the command:

DIR

This lists all of the music programs available on the "disk." Let's choose to load one of the following three programs:

LOAD "BIRTHDAY.BAS"
LOAD "SONGTIME.BAS"
LOAD "ALPHSONG.BAS"

Whichever program we choose, let's list it:

LIST

You'll see that this program uses commands like SOUND, DATA, and READ -- and these are the commands that we've used to code our music so far. If we load any other program that ends in .BAS

LOAD "JUG.BAS"
LOAD "BACH.BAS"
LOAD "JETPLANE.BAS"
LOAD "COUNTRY.BAS"

then the PLAY command is used instead of SOUND. Of course, you may recall that PLAY is designed to play music, so with a PLAY command, why would anyone go back to the clumsy SOUND used in the first three songs? (We're using SOUND because we eventually wish to invent a new scale.) I think it's because the first three songs were written on an even older version of the computer, where the command PLAY wasn't yet available.

The third method is to use .BIN files and machine language. Machine language allows us to bypass the limitations of BASIC -- for example, both SOUND and PLAY limit us to playing one note at a time (melody) instead of several notes at a time (harmony). To load a machine language file, we type:

LOADM "WTELL32.BIN"

and to run it, instead of RUN, we type in:

EXEC

Once we EXECute a .BIN file, we must click "Reset" to stop the program.

But let's get back to SOUND. Analysis of the first three programs reveal the following scale:

The "Disk" Scale:


Sound     Degree     Note
89           172           C (middle)
108         153           D
125         136           E
133         128           F
147         114           G
159         102           A
165         96             Bb
176         85             C

We see that this doesn't correspond to the 3-limit scale we found earlier. The middle C here is Sound 89, while we found it to be Sound 99 earlier. Indeed, Sound 89 is nearly a semitone below Sound 99, and so Sound 89 would be closer to B on my musical keyboard than middle C. And indeed, the note F here is Sound 133, which we already found to be Pythagorean E, and likewise the note Bb here is Sound 165, which we already found to be Pythagorean A.

Well, the note names I came up with match my home musical keyboard -- and besides, it's more convenient to call Sound 133 E and Sound 165 A, because all the other notes are named using perfect fourths starting from E and A. If we named these notes F and Bb instead, all the other Pythagorean notes would have flats in their names, since we'd be moving in perfect fourths from Bb.

We also notice that the two C notes are Sounds 89 and 176. The difference between these two notes is the ratio 172/85, which is not a perfect octave. If we instead used Sound 175 for the high C, then the ratio would be 172/86 = 2/1. Recall that to find the ratio between sounds, we must first convert them to degrees by subtracting them from Bridge 261.

This raises the question -- how sure are we that the bridge is actually 261? For example, if we were to use Bridge 263 instead of 261, then Sounds 89 and 176 would indeed be a perfect octave apart, as indicated in the "disk" program.

Well, let's write a NEW program to determine whether the bridge is really 261 or 263. (That's right -- make sure you type in NEW first.)

10 B=263
20 FOR X=3 TO 7
30 SOUND B-2^X,16
40 NEXT X

Recall that the ^ symbol is really the up-arrow and denotes exponent. We're using powers of two, and so the notes should sound like descending octaves. But if we use Bridge 263 (as indicated in line 10), then the notes sound nothing like octaves -- the first note is a high A, while the lowest notes sound more like E (or maybe F if we use the "disk" scale, but definitely not A). If we change line 10:

10 B=261

then the notes actually sound like true octaves. For no other bridge value do all the notes sound like descending octaves. That settles the matter -- it's Bridge 261.

Finally, you may wonder why what is apparently a C major scale uses Bb instead of B. Well, the birthday song is in the key of F major, which requires Bb. The other songs are all in C major, but the note B is omitted in all of them. The scale C-D-E-F-G-A-Bb-C is also called "Mixolydian mode" and sometimes appears in bluesy songs -- more on that later.

Anyway, let's try to construct a just 5-limit major scale. Here it's important to distinguish between "otonal" and "utonal" intervals. An interval is otonal if the "new primes" appear in the numerator rather than the denominator, while only "old primes" are in the denominator. (In the 5-limit, the new prime is 5, while the old primes are the Pythagorean 2 and 3.) And so 5/4 (the major third) and 5/3 (the major sixth) are both otonal. In utonal intervals, the new primes are in the denominator, and so 6/5 (the minor third) and 8/5 (the minor sixth) are both utonal.

The EDL scale on which our computer sounds are based is utonal. This is because we keep the numerator fixed while we vary the denominator. Therefore, it's easier to play utonal intervals, and scales based on these, than otonal intervals. Major intervals are otonal while minor intervals are utonal, and therefore it's easier to play a just minor scale than a just major scale.

The 5-limit intervals often differ from their 3-limit counterparts by the syntonic comma 81/80. As the ratio implies, Degrees 81 and 80 (Sounds 180 and 181) differ by a syntonic comma. Sound 180 is already labeled C, and so Sound 181 is labeled, C+, which is C raised by a syntonic comma.

We can label the other 5-limit notes by moving in 3-limit intervals starting from C+. It's also worth noting that the interval from C+ to the E above it is 80/64 = 5/4, the just major third. Therefore if we move down a major third, another comma + must appear. This means that degrees that are multiples of 25 (two factors of five) require two commas ++, while degrees that are multiples of 125 (three factors of five) require three commas +++.

Here are the 23 notes of the 5-limit that are not available in the 3-limit:

Additional Playable 5-Limit Notes:

Sound     Degree     Note
11            250          Fb+++
21            240          F+
36            225          Gb++
61            200          Ab++
81            180          Bb+
101          160          C+ (middle)
111          150          Db++
126          135          Eb+
136          125          Fb+++
141          120          F+
161          100          Ab++
171          90            Bb+
181          80            C+
186          75            Db++
201          60            F+
211          50            Ab++
216          45            Bb+
221          40            C+
231          30            F+
236          25            Ab++
241          20            C+
246          15            F+
251          10            C+

Admittedly, a note name like Fb+++ is strange. It contains three commas +++ because its degree has three factors of five. You may wonder why we name the note Fb instead of E. Well, the notes E and Fb are enharmonic (that is, they're the same note) only in the usual 12EDO scale. In other scales (including 19EDO and 31EDO, and especially in just intonation), E and Fb are not enharmonic. The note Fb+++ can be raised a major third to Ab++, raised another major third to C+, and raised yet another major third to E. The notes E and Fb+++ differ by the interval 128/125, called a "diesis."

OK, that's all fine and dandy, but where's our major scale? Because the major intervals are otonal, we can't build a major scale starting on any Pythagorean note. Instead, we must start on a degree that has five as a factor (so that we can build the 5/4 major third on it).

As it turns out, only one just major scale is playable on the emulator. Its tonic, or starting note, is Degree 180 (Sound 81), which is Bb+ major:

The Playable Just Major Scale:

Sound     Degree     Note    Ratio     Interval (from root note)
81           180           Bb+     1/1        tonic
101         160           C+       9/8        major tone
117         144           D         5/4        major third
126         135           Eb+     4/3        perfect fourth
141         120           F+       3/2         perfect fifth
153         108           G         5/3        major sixth
165         96             A          15/8      major seventh
171         90             Bb+      2/1       perfect octave

It's unfortunate that our only playable major scale had to be Bb+ major rather than C major, but then again, many band instruments played in schools are compatible with concert Bb. (Yes, I still recall the infamous Bb-A-Bb practice song!)

On the other hand, there are three playable just minor scales -- and the roots of all of these scales are Pythagorean notes. The first of these is D minor, built on Degree 72 (Sound 189):

The Playable Just Minor Scale:

Sound     Degree     Note    Ratio     Interval (from root note)
189         72             D         1/1        tonic
197         64             E         9/8        major tone
201         60             F+       6/5        minor third
207         54             G         4/3        perfect fourth
213         48             A         3/2        perfect fifth
216         45             Bb+     8/5        minor sixth
221         40             C+       9/5        minor seventh
225         36             D         2/1        perfect octave

The second playable scale is obtained by multiplying all the degrees by two, which lowers the scale by 2/1, the perfect octave. The third playable scale is obtained by multiplying all the degrees by three, which lowers the scale by 3/1, a perfect twelfth (or "tritave"). In this case it becomes G minor. We can't lower the scale by 4/1 since 72 * 4 is 288, while the lowest playable note is Degree 260.

Notice that the so-called "harmonic minor" scale uses a major seventh rather than minor seventh. But this isn't playable on the computer, since the 15/8 major seventh is otonal.

Coding the 5-Limit

The easiest way to play a major scale is simply to use the PLAY command. It's designed to play any major scale available in 12EDO, not just the Bb major scale.

But let's write a NEW program to practice using SOUND, DATA, and READ, as well as INKEY$, to play our scales anyway:

10 DIM S(9)
20 FOR X=0 TO 9
30 READ S(X)
40 NEXT X
50 DATA 72,180,160,144,135
60 DATA 120,108,96,90,80
70 N=1
80 A$=INKEY$
90 IF A$="" THEN 80
100 A=VAL(A$)
110 SOUND 261-N*S(A),2
120 IF A$>="0" AND A$<="9" THEN 80

For this program, we use keys 1-8 to play the Bb+ major scale. I decided to follow the same pattern that we often use for Pi Day digit music, and let "9" denote the high C+ a major ninth above Bb+.

This leaves the "0" key. We mentioned that Pi Day digit musicians have three choices for the zero:


  • Use 0 as a rest.
  • Play the note one step below 1.
  • Play the note one step above 9 (i.e., treat 0 as 10).
Here I decided to treat 0 as 10 and play the note D a major tenth above Bb+, only because the "0" key is to the right of the "9" key.

This means that we can't use the VALue of 0 to end the program. Instead, if a bad key is pressed, Note 0 (the high D) is played, but then the program ends, since line 120 doesn't send the program back to line 80 unless a valid key between "0" and "9" is pressed.

In this program, line 70 is meaningless, since the major scale has only one octave. I kept this line anyway in order to make it easy to change the program to the minor scale. We can keep line 70 the way it is and change only the DATA lines to code the D minor scale:

50 DATA 30,72,64,60,54
60 DATA 48,45,40,36,32

Now line 70 means something. To play the lower octave, we write:

70 N=2

and to play the G minor scale, we write:

70 N=3

For the G minor scale, notice that keys 3-0 almost give us the Bb+ major scale from earlier -- this is because G minor is the relative minor of Bb+ major. The only difference is that G minor contains the note C 4/3 above the root, while Bb+ major contains the note C+ 9/8 above the root. These two notes differ by 162/160 = 81/80, the syntonic comma +.

The New 7-Limit Scale

We now wish to create a new scale, one which incorporates the prime 7. Just as 5-limit intervals differ from their Pythagorean counterparts by the syntonic comma 81/80, 7-limit intervals differ from their Pythagorean counterparts by the septimal comma 64/63. The word "septimal" means seven, as in 7-limit.

Since the septimal comma is 64/63, let's look at Degrees 64 and 63. Degree 64 (Sound 197) is E, and so Degree 63 (Sound 198) is E raised by a septimal comma. Let's use the symbol "7" to denote the septimal comma (since "septimal," after all, means 7). So Degree 63 (Sound 198) is E7, and we can go up or down by 3- or 5-limit intervals from E7 to generate more 7-limit notes. Notice that unlike 64, 63 is a multiple of three, and so we can go up a 3/2 perfect fifth from E7 to reach Degree 42 (Sound 219), which is B7. This is the first B note of any type that is playable -- the 3-limit has no B notes available at all, while the 5-limit has a Bb note but no B note. Some sharp notes are also available in the 7-limit, such as F#7 (Degree 28/Sound 233), a perfect fifth above B7.


Here are the 25 notes of the 7-limit that are not available in the 5-limit:

Additional Playable 7-Limit Notes:

Sound     Degree     Note
9             252           E7
16           245           E+77
37           224           F#7
51           210           G+7
65           196           G#77
72           189           A7
86           175           Bb++7
93           168           B7
114         147           C#77
121         140           D+7
135         126           E7
139         112           F#7
156         105           G+7
163         98             G#77
177         84             B7
191         70             D+7
198         63             E7
205         56             F#7
212         49             G#77
219         42             B7
226         35             D+7
233         28             F#7
240         21             B7
247         14             F#7
254         7               F#7

Multiples of 35 require both the sytonic comma + and the septimal comma 7. Multiples of 49, meanwhile, require two septimal commas 77.

OK, here's a quick question -- what is the interval between Sounds 81 and 135? If you said "major sixth" because 135/81 = 5/3, you're wrong -- those are sounds, not degrees. To find the interval, we must subtract the sounds from Bridge 261 -- we have Degrees 180 and 126. So the correct ratio is 180/126 = 10/7, which is a "septimal tritone," not a major sixth. The notes are Bb+ and E7, and so the interval is clearly a tritone, not a sixth.

Now that we have the full 7-limit, how can we make a scale out of this? Here are a few properties that I'd like our scale to have:

First, we don't want there to be too many notes. Let's stick to ten notes within the octave, so that we can play the scale on the computer keys 1-9 plus "0."

Second, any 7-limit scale should at least be able to play the harmonic seventh chord, 4:5:6:7. That is, the chord consists of notes 5/4, 3/2, and 7/4 above the bass note. This is an otonal chord, and so we must find a common numerator -- 3 * 5 * 7 = 105, so Degree 105 (Sound 156) could be the bass, along with Degree 210 (Sound 51). If we want a full octave, then Degree 210 could be the first note and Degree 105 could be the last note. The bass note is G+7 and the chord is G+7 B7 D+7 F+.

Third, we want as many simple septimal intervals as possible. Clearly we want there to be many perfect fifths and fourths, as well as the basic 7-limit thirds:


  • the septimal minor (or "subminor") third, 7/6
  • the minor third, 6/5
  • the major third, 5/4
  • the septimal major (or "supermajor") third, 9/7
Notice that the minor and supermajor thirds are utonal (with the 5 or 7 in the denominator), while the subminor and major thirds are otonal (with the 5 or 7 in the numerator). So we expect there to be more minor and supermajor triads than major and subminor triads in our scale. (The two highest playable notes, Sounds 254 and 255, differ by 7/6, the subminor third. On the other hand, the two lowest playable notes, Sounds 1 and 2, differ by 260/259. This interval is a little less than seven cents, close to the just noticeable difference or one step of 180EDO. Again, there are many more notes available in the low octaves than the high octaves.)

Fourth, we want this scale to be as different from 12EDO as possible -- otherwise, we would be using PLAY instead of SOUND. The 7-limit interval that's very different from anything in 12EDO is 36/35, which is about half of a semitone. Therefore, this interval is called a "septimal quarter tone."

Here's how we'll create our scale. Let's begin with the notes G+7 and D+7, which differ by a perfect fifth and are part of the harmonic seventh card. Since we want as many perfect fifths in our scale as possible, we could try going a perfect fifth down from G+7 to C+7, as well as up a perfect fifth from D+7 to the note A+7. But neither C+7 nor A+7 is playable, and so this is a dead end.

So instead, let's include the Pythagorean notes G and D as well. The notes G and G+7, as well as D and D+7, differ by the syntonic and septimal commas, which add up to a septimal quarter tone. And so by including all four notes G, G+7, D, and D+7, we satisfy the fourth desideratum of including quarter tones in our scale.

And now we can go a perfect fifth down from G to C, and a perfect fifth up from D to A. So far, our scale includes six notes.

We can't go any further using perfect fifths below C, since F isn't available in the octave starting with G as the root note. But then again, we don't need F, but F+ instead, since it's in the harmonic seventh chord that we want (second desideratum). Meanwhile, we could go up from A to E, but let's try to keep things somewhat symmetrical -- since we added the syntonic comma via F+, let's add the septimal comma via E7 instead of E. So far, our scale includes eight notes.

Finally, let's go one more perfect fifth down from F+ to Bb+, and up from E7 to B7. Now we have ten notes, and so we finally have a complete scale:

The New 7-Limit Scale:

Key     Sound     Degree     Note     Ratio     Interval (from root note)
1.         51           210          G+7      1/1         tonic
2.         69           192          A           35/32     neutral tone
3.         81           180          Bb+       7/6         subminor third
4.         93           168          B7         5/4         major third
5.         99           162          C           35/27     semidiminished fourth
6.         117         144          D           35/24     semidiminished fifth
7.         121         140          D+7       3/2         perfect fifth
8.         135         126          E7          5/3         major sixth
9.         141         120          F+          7/4         harmonic seventh
0.         153         108          G           35/18      semidiminished octave

The first thing you might notice about this scale is that the first and last notes aren't a perfect octave apart -- and that's after I ripped apart the "disk" scale for not being a true octave!

Well, I originally wanted a nine-note scale, with a tenth note one octave above the first note. But then I developed the scale beginning with G and D and moving symmetrically from those two starting notes in perfect fifths. The symmetry required us to have an even number of notes in the scale. But since the scale has two different G's, I could get away with having G+ as the low note and then Pythagorean G as the high note.

In addition to two G's, there are two D's as well, separated by a quarter tone. This means that the scale can't be played exactly in 12EDO or using the PLAY command. But what purpose do the extra G and D notes serve, musically speaking?

In music, we often distinguish consonant intervals from dissonant intervals. Consonant intervals sound pleasant, while dissonant intervals sound like noise. Intervals with simple intervals tend to be more consonant. In the scale above, most of the intervals appear consonant, but the four intervals with the numerator 35 stick out like a sore thumb -- these are dissonant intervals.

In real life, dissonant intervals can be useful. I remember watching old Let's Make a Deal episodes with Monty Hall. Whenever a Zonk is revealed, a horn plays two low notes separated by a tritone, which is considered dissonant (the "devil in music"). Because the interval is dissonant -- as well as descending -- the contestant is made to feel sad for revealing the Zonk.

Another interesting case involving train whistles. I live about two miles from the tracks, and yet later at night I can hear whistles from the freight trains. The whistles play the following three notes:

C-E-G#

This "augmented triad" is a strange case. The interval C-E is a major third, which is consonant, and the interval E-G# is also a major third, which is consonant. The interval C-G# is an augmented fifth, and all augmented intervals are dissonant. But hold on a minute -- the note G# is enharmonic to Ab, and C-Ab is a minor sixth, which is consonant. So theoretically, all three intervals contained in the train whistle are consonant -- and yet the whistle sounds very dissonant.

Once again, G# is enharmonic to Ab only in 12EDO. This is similar to the situation with Fb+++, which is not equivalent to E in just intonation. Two major thirds at 5/4 combine to make 25/16, which differs from the minor sixth 8/5 by the same diesis we mentioned earlier. Because of this, our ears can't match up the partials from all three notes simultaneously and the sound is dissonant. It doesn't matter how we spell the notes:

C-Fb-Ab
C-E-Ab
C-E-G#
B#-E-G#

and so on (with commas + at the right places) -- at most only two of the intervals can be 5/4 and the other must be the dissonant 25/16. Try it on a piano -- playing C-G# sounds consonant because we hear it as C-Ab, but if we add an E it suddenly becomes dissonant. We should be glad that train whistles are dissonant, since if they had sounded fully consonant as in:

C-E-G

we might mistake it for three musicians playing horns rather than a train about to run us over. And on the Wayne Brady version of Let's Make a Deal, the new Zonk music is -- you guessed it -- a descending augmented triad.

Consonance is more relevant in harmony than in melody -- indeed, some intervals are harmonically dissonant, yet melodically consonant (such as the semitone).

In the new 7-limit scale, the two dissonant intervals we worry about are the fourths and fifths that aren't perfect because they match G with the wrong D. With two G's and two D's, we should make sure that G+7 isn't played next to D, nor G played next to D+7. Oh, and of course G shouldn't be played next to G+7, nor D next to D+7. Almost all other intervals are melodically consonant -- even the tritone, since our tritones are either 7/5 or 10/7, which are 7-limit consonances.

In the new 7-limit scale, we could use the other G as the tonic rather than G+7. This gives us:

The New 7-Limit Scale, starting on G:

Key     Sound     Degree     Note     Ratio     Interval (from root note G)
0.         45           216          G          1/1         tonic
1.         51           210          G+7      36/35     quarter tone
2.         69           192          A           9/8        major tone
3.         81           180          Bb+      6/5         minor third
4.         93           168          B7         9/7        supermajor third
5.         99           162          C           4/3        perfect fourth
6.         117         144          D           3/2        perfect fifth
7.         121         140          D+7      54/35     semiaugmented fifth
8.         135         126          E7         12/7      supermajor sixth
9.         141         120          F+         9/5        minor seventh
0.         153         108          G          2/1        perfect octave

This is almost an entire minor scale starting on G, with a few extra intervals.

If we want, we can make this into an extended 12-note scale by adding one more perfect fifth in each direction -- so we go down a perfect fifth from Bb+ to Eb+, and up a perfect fifth from B7 to F#7. I know that this isn't convenient for ten keys on the computer keyboard, but it could work on a retuned musical keyboard, since it already has 12 notes per octave.

The scale is designed to maximize the number of consonant triads. For example, you might wonder why we didn't include Degree 175 (Sound 86), as this note is a 6/5 minor third above G+7. The reason is that this note, labeled Bb++7, can't be raised a perfect fourth or fifth, and in fact the only triad it is part of is G+7 minor. On the other hand, Bb+ is part of a subminor triad on G+7 and a just minor triad on G, and is itself the root of both a just major and a supermajor triad. If we're going to include a note in a scale, it should be part of four consonant triads, not just one.

Coding the 7-Limit

The first song we played today is in the New 7-Limit Scale. So let's combine the lines where that scale is created with the code for INKEY$ so we can play the scale ourselves. (We only need to change lines 50-70 if we haven't erased the previous program.)

10 DIM S(9)
20 FOR X=0 TO 9
30 READ S(X)
40 NEXT X
50 DATA 54,105,96,90,84
60 DATA 81,72,70,63,60
70 N=2
80 A$=INKEY$
90 IF A$="" THEN 80
100 A=VAL(A$)
110 SOUND 261-N*S(A),2

120 IF A$>="0" AND A$<="9" THEN 80

This also explains why the top note of our scale is Degree 108 rather than Degree 105. All the scale degrees are even, so we can raise it a full octave by changing line 70 as usual to N=1. On the other hand, Degree 105 can't be raised an octave.

Another Turkey Song

Today is Thanksgiving, but I haven't said much about the holiday yet. Well, the song we played can easily be changed to one about a turkey. Let's try it:

Fury said to a turkey,
In a house, dark and murky, [OK, you try to rhyme "turkey." Maybe the house was "jerky"?]
"Let us both go to law: I will prosecute you.

"Come, I'll take no denial;
We must have a trial;
For really this morning I've nothing to do."

Said the turkey to the cur,
"Such a trial, dear Sir,
With no jury or judge, would our breath be wasting."

"I'll be judge, I'll be jury,"
Said cunning old Fury;
"I'll try the whole cause and you soon I'll be tasting."
[If we're condemning the turkey to death on Thanksgiving, of course we're going to eat it!]

Here is a second song I created. I chose the notes at random as well as their lengths, using quarter, half, dotted half, and whole notes. To make it go a little faster, the whole note is 16 rather than 32 as in the previous song. The G's and D's are chosen as to conform to our rules about avoiding dissonant fourths and fifths:

10 DIM S(9)
20 FOR X=0 TO 9
30 READ S(X)
40 NEXT X
50 DATA 54,105,96,90,84
60 DATA 81,72,70,63,60
70 N=2
80 FOR X=1 TO 54
90 READ A,T
100 SOUND 261-N*S(A),T
110 NEXT X
120 DATA 5,16,0,8,4,8,6,4,5,8
130 DATA 1,4,1,4,1,12,1,8,2,8
140 DATA 1,16,1,16,1,16
150 DATA 5,16,0,8,4,8,6,4,5,8
160 DATA 1,4,1,4,1,12,1,8,2,8

170 DATA 1,16,1,16,1,16
180 DATA 2,12,9,4,2,12,4,4
190 DATA 4,12,3,4,1,8,7,8
200 DATA 5,12,4,4,2,12,8,4
210 DATA 4,12,9,4,7,8,7,8
220 DATA 5,16,0,8,4,8,6,4,5,8
230 DATA 1,4,1,4,1,12,1,8,2,8

240 DATA 1,16,1,16,1,16

There are more data lines since they contain more information. This song is also in AABA format, with a main verse and a bridge.

All we need now are lyrics. Let's assume that this is the song I would have sung in class last week as I prepared the students to graph and color a turkey. Let's try these lyrics:

Verse:
Tom Turkey,
Draw him on the graph.
X, Y, scale,
By half.

Bridge:
Big Tom, Small Tom,
Fun dilation.
Big Tom, Small Tom,
Decoration!

This song is based on the original 2015 worksheet, for which Tom was a dilation project. Of course, I changed the actual project twice since then.

Conclusion

Ever since I first learned about microtonal music in Pappas and remembered the SOUND command on my old computer, I've wanted to compose some actual music. I'm glad that I was able to find the emulator and start writing!

In tomorrow's Black Friday post, we'll look at some more songs we can write in the 3-, 5-, and 7-limit scales that we looked at today. This will include converting some of the songs I sang last year into the new scales.

Thus concludes this post. I hope you enjoy the rest of your Thanksgiving!

No comments:

Post a Comment