Friday, June 8, 2018

Music Post: More on 20EDL and Other Scales

Table of Contents

1. Introduction
2. Yet Another Traditionalists Post
3. Composing Music in 20EDL
4. Converting 20EDL to EDO Scales
5. Exploring 29EDO
6. What About 28EDO?
7. Converting EDO Scales to EDL Scales
8. Eighth and Sixteenth Notes


This is officially my first summer post. I already wrote that my second summer post will be Friday, June 15th -- just ahead of the start of summer school. So I might as well make my first summer post today, so that both posts are on Fridays.

No announcement has been made regarding whether I'll actually have a summer class or not. And so I'll just use today's post to continue our discussion of various musical scales. Again, all of this is to prepare songs to play during music break in a possible summer Algebra I class.

Yet Another Traditionalists Post

You knew it was too good to be true. Just days after I give up on Barry Garelick and SteveH and blog about some other traditionalists, guess who makes a surprise post today!

It's almost as if Barry Garelick read this blog and suddenly remembered that he hadn't posted anything in a while. Anyway, let's see what Barry Garelick has to say today:

This article talks about a book titled “Systems for Instructional Improvement”   coauthored by the dean of the University of Southern California ed school.  It is described as  “dedicated to improving math instruction in the U.S.”
Why is it that just about every book, article, tweet, and Linked-In polemic that purports to put math education back on track starts from the following assumption:
“For the past 25 years or so, there’s been a growing recognition that students at the middle-school level, in particular, aren’t developing a deep understanding of mathematics,” said Thomas Smith, dean of UC Riverside’s Graduate School of Education. “A big piece of that is because of the way students in the U.S. are taught; current math instruction tends to be highly procedural — as in ‘use these steps to solve these types of problems’ — instead of allowing students to investigate real-life problems and experiment with different types of solution strategies.”

Implied in the quoted paragraph is that traditional math leads to students wondering "Why do we have to learn this?" and "When will we use this in real life?" -- so by switching to reform math and real-life examples, those questions would disappear. Well, let's see what Garelick says about that:

Singapore has boasted high scores on international tests for years, but the problems that students solve there may be held in disdain by math reform types. Perhaps they think they are not relevant to students concerns. If students are not given proper instruction on how to solve such problems, and are expected to discover “strategies” for solving, they will tend to ask “When am I ever going to use this in real life?”   If given proper instruction with scaffolded problems that are variations on the initial worked example, students generally will tackle such problems. The “When will I ever use this” question is generally an expression of frustration.

Hmm. On one hand, I must give Garelick credit for being a middle school teacher in an actual class with real students. If he can really make the "When will I ever use this?" disappear in his classroom by using traditional direct instruction, then I must accept this as fact.

On the other hand, Garelick himself would probably say that much of the "When will I ever use this?" frustration is due to lack of traditional math in elementary school, so that by the time the students get to him, they're already struggling to understand the new material. This implies that he could reduce "When will I ever use this?" even more if the students had better elementary texts (such as Singapore, mentioned in the above paragraph). This, of course, can't be proved, since Garelick has no power to change the elementary texts.

So far, Garelick's post has drawn two comments. Both of these posts are written by, well, the one you know who's been itching to comment for over a month now:

They NEVER explain what this magic “deep understanding” means. In middle school, the process culminates with Algebra I, where “deep” understanding has to do with individual mastery of the problem sets in a good textbook. I never hear them talk about success in those concrete terms because they think that homework and tests are not “authentic.” Real life is not authentic?

Homework and tests are real life?

A person complimented my son last week on his college graduation (one degree was in math) and said it was based on my fatherly philosophy of “the process is the product.” I don’t know where that came from. I never think that way and I don’t even know what it means. This caused me to look up the phrase and I found that I completely disagree – even though you can make it mean whatever you want. A good process may be statistically better, but parents and teachers should individualize the process to achieve better product results – results drive the process. It’s never the case where the product doesn’t matter.

Traditionalists like to claim that they want to "individualize the process" -- if some individuals learn better using traditional math, then they should be taught traditional math, not reform math. But once again, suppose the tables were turned, and traditional math was the dominant paradigm. How would the traditionalists treat those individuals who don't want to learn math traditionally? I reckon the traditionalists would just ignore them -- they'd be the ones saying "the process is the product."

I congratulate SteveH's son for graduating with his BS in math. Of course, SteveH will be the first to say that his son's success was due to his pushing the youngster to learn traditional math beyond what his secondary schools taught him. And SteveH would suggest that if only the schools would push traditional math, eighth grade Algebra I, and senior-year Calculus, then maybe four or five more of his middle/high school classmates would have earned their math degrees last week as well.

In fact, in his second comment SteveH proceeds to write more about his son's very early education:

Note that my involvement in the “Math Wars” started when my son was in preschool and the teacher told me that our school used MathLand, a product so bad it was wiped off the face of the internet. It was replaced in our schools by Everyday Math [U of Chicago elementary texts -- dw], which tells teachers to keep moving and to “trust the spiral” (process). If the product is not achieved, then blame students, parents, peers, society, not enough engagement, or whatever. Meanwhile, they never ask us parents of their best students what we had to do at home. This foolishness has been going on for decades now. It’s what they have been pushing. They own it. It disappears in traditionally-taught high school AP Calculus tracks – the only path to a STEM career. So let’s redefine it as STEAM so that everyone can be successful and they can ignore all individual lost educational opportunities because the process is the product.

SteveH tells us that his son actually enjoyed the traditional problem sets (p-sets) that he completed as a teenager. But once again, how many students sitting in his son's classes agreed that these traditional p-sets are enjoyable? For every "SteveH's son," there are four or five students who don't enjoy these p-sets, and one student who, when assigned a p-set, doesn't even look at #1 or #2. The students don't care about "individual lost educational opportunities" to earn a math or STEM degree -- they just to see something different in secondary math other than endless p-sets.

My upcoming summer school class consists of students who failed Algebra I during the year. Most likely, these students don't enjoy math and probably didn't do many of the p-sets -- otherwise they probably wouldn't have failed the class. And these are high school students -- not eighth graders. If they failed Algebra I as freshmen, imagine how they would have fared if they'd been forced onto SteveH's vaunted "AP Calculus track" and took eighth grade Algebra I.

Traditionalists will be happy that there's no time for projects in my class. But they hold online courses like Edgenuity in disdain. I'm the first to admit that Edgenuity isn't a perfect program, but I reckon that students are more likely to answer questions on the computer (even if they're just guessing) than they are to write down #1 or #2 from the p-set in the text.

By the way, since I'll need to supplement Edgenuity with some written material anyway, some traditionalists might wonder, why can't I use a text that they approve of, such as Dolciani? Well, that the particular Dolciani text that I purchased at the book sale two months ago isn't an Algebra I text or even Pre-Algebra, but more like pre-Pre-Algebra. The Order of Operations doesn't appear, and the Distributive Property is listed only as one of six "Properties of Multiplication" in Lesson 3-3, so there's not enough coverage there either.

Composing Music in 20EDL

Let's review the 20EDL scale -- currently the scale of the week:

The 20EDL scale:
Degree     Ratio     Note
20            1/1         green C
19            20/19     khaki C#
18            10/9       white D
17            20/17     umber D#
16            5/4         white E
15            4/3         green F
14            10/7       red F#
13            20/13     ocher G
12            5/3         white A
11            20/11     amber B
10            2/1         green C

10 CLS
20 N=8
30 FOR A=0 TO 6
40 B=4
50 X=A-INT(A/2)*2
60 IF X=0 THEN D=20 ELSE D=19
80 L=RND(B)
90 SOUND 261-N*D,4*L
100 IF L>1 THEN FOR I=1 TO L-1:PRINT "   ";:NEXT I
110 B=B-L
120 IF B>0 THEN D=21-RND(11):GOTO 70
140 NEXT A
150 PRINT 20
160 SOUND 261-N*20,16

Don't forget to click on "Sound" to turn it on!

This randomizer is based on C and C# chords. I've suggested 20:16:13 as a possible C major chord, but what chord can be built on C#? We probably should at least use note 16 so that the fawn minor third 19/16 can be played. But neither 20 nor 19 has a perfect fifth above it. At this point we might prefer to use a D minor chord (18:15:12), or even F major (15:12:10), as these are chords that at least sound more compatible with C major. (Of these, Dm is considered easier to play on the guitar.)

As for actual songs in 20EDL, I keep saying that I want to stay away from just converting ordinary (12EDO) songs to 20EDL, but this week I sang the Quadratic Formula song ("Pop Goes the Weasel") and it's tempting to convert this to the new scale. This song is a good song to convert to 20EDL -- the scale's lack of perfect fifth is less important since the note G isn't stressed in the song:

10 CLS
20 N=8
30 FOR X=1 TO 27
50 SOUND 261-N*D,T
70 DATA 20,8,20,4,18,8,18,4
80 DATA 16,4,13,4,16,4,20,12
90 DATA 20,8,20,4,18,8,18,4
100 DATA 16,12,20,12
110 DATA 20,8,20,4,18,8,18,4
120 DATA 16,4,13,4,16,4,20,12
130 DATA 12,12,18,8,15,4
140 DATA 16,12,20,12

Notice that this song is in 3/4 time, and so a measure consists of three quarter notes. This contrasts with the 4/4 songs that the randomizer produces.

By the way, if you want the randomizer to produce 3/4 music, then change the following lines:

40 B=3
160 SOUND 261-N*20,12

Recall that I prefer minor scales for most classroom music. Therefore I'm more likely to use 12EDL or 14EDL (or possibly the neutral 16EDL) than 18EDL or 20EDL.

Converting 20EDL to EDO Scales

Recall that we've been using the following Mocha program to convert EDL scales to EDO scales:

20 A=0:B=L
30 A=A+1: E=0
40 FOR X=L/2+1 TO L-1
50 C=LOG(L/X)/LOG(2)*A
60 D=INT(C+.5)
70 E=E+ABS(C-D)
100 GOTO 30

If we input 20 into this program for 20EDL, then the following EDO's are produced:

1, 4, 5, 7, 8, 12, 13, 27, 29, 53, 72, 217, ...

Since 20EDL contains ten notes, nothing less than 10EDO should even be considered. Thus the first nontrivial EDO's in the list are 12EDO and 13EDO.

The presence of 12EDO in this list might be surprising. After all, 20EDL contains both 11 and 13, and both of these are poorly approximated in 12EDO. On the other hand, we see that the first few notes of 12EDO approximate the 20EDL scale. In fact, 20EDL begins gC, kC#, wD, uD#, wE, gF, rF#, and so playing C to F# in 12EDL sounds good enough,

In fact, every EDL has an EDO that approximates its first few notes. For 14EDL we have 9EDO, for 16EDL we have 10EDO, and for 18EDL we have 11EDO. We know that in terms of cents, the notes of an EDL are more spread apart as we ascend the scale. Thus for 14EDO, the first step 14/13 is 128.3 cents, a little less than 9EDO's step size of 133.3 cents. For 16EDO, the first step 16/15 is 111.7 cents, a little less than 10EDO's step size of 120 cents, and so on.

In the case of 20EDL, the first step 20/19 is 88.8 cents, the second step 20/18 (= 10/9) is 182.4 cents, and the third step 20/17 is 281.4 cents. Each of these is fairly close to the steps of 12EDO. We notice that 13EDO also appears in the list, since its step size (92.3 cents) is even closer to 20/19.

But since the step sizes of an EDL increases in cents as we ascend the scale, the higher notes of the 20EDL scale no longer match 12EDO or 13EDO. Thus 20/15 (= 4/3) is far from the corresponding size of 13EDO. Of course, the perfect fourth still sounds accurate in 12EDO, but two steps later is 20/13, which is no longer accurate in 12EDO. Thus 12EDO and 13EDO are accurate enough for the lower parts of the 20EDL scale, but not the entire octave.

So the first reasonable EDO's for 20EDL are 27EDO and 29EDO. We've already seen 27EDO as a good approximation for 14EDL. This tells us that 27EDO is reasonable enough for 13-limit, even though 17 and 19 aren't quite as good as 13 in 27EDO. Therefore we will now take a closer look at the next scale, 29EDO.

Exploring 29EDO

Here is a link to 29EDO on the Xenharmonic website. (All links will be dead after July.)

29edo divides the 2:1 octave into 29 equal steps of approximately 41.37931 cents. It is the 10th prime edo, following 23edo and coming before 31edo.

29 is the lowest edo which approximates the 3:2 just fifth more accurately than 12edo: 3/2 = 701.955... cents; 17 degrees of 29edo = 703.448... cents. Since the fifth is slightly sharp, 29edo is a positive temperament -- a Superpythagorean instead of a Meantone system.

Let's see the link between 29EDO and Kite's color notation:

Combining ups and downs notation with color notation, qualities can be loosely associated with colors:
qualitycolormonzo formatexamples
downminorblue{a, b, 0, 1}7/6, 7/4
minorfourthward white{a, b}, b < -132/27, 16/9
upminorgreen{a, b, -1}6/5, 9/5
"jade{a, b, 0, 0, 1}11/9, 11/6
downmajoramber{a, b, 0, 0, -1}12/11, 18/11
"yellow{a, b, 1}5/4, 5/3
majorfifthward white{a, b}, b > 19/8, 27/16
upmajorred{a, b, 0, -1}9/7, 12/7
All 29edo chords can be named using ups and downs. Here are the blue, green, yellow and red triads:
color of the 3rdJI chordnotes as edostepsnotes of C chordwritten namespoken name
blue6:7:90-6-17C Ebv GC.vmC downminor
green10:12:150-8-17C Eb^ GC.^mC upminor
yellow4:5:60-9-17C Ev GC.vC downmajor or C dot down
red14:18:270-11-17C E^ GC.^C upmajor or C dot up

Once again, 29EDO isn't meantone, and so the major third isn't C-E (instead, it's C-Ev). We keep this in mind as we convert 20EDL to 29EDO:

The 20EDL scale (converted to 29EDO, starting on C):
Degree     Ratio     Note
20            1/1         C
19            20/19     Db
18            10/9       Dv (D-down)
17            20/17     D^ (D-up)
16            5/4         Ev (E-down)
15            4/3         F
14            10/7       F#
13            20/13     G^ (G-up)
12            5/3         Av (A-down)
11            20/11     A#
10            2/1         C

Here's a video of a song in 29EDO. Just as I don't want to do (but did anyway), the author just took a song in 12EDO and converted it to 29EDO:

What About 28EDO?

You might remember that two months ago, I posted an Easter song in 28EDO. The notes of this Easter song are based on the dates of Easter.

When we look at the list of good EDO's for 20EDL, we notice that both 27EDO and 29EDO make the list, but not 28EDO. Indeed, 28EDO hasn't made the list for any EDL at all. The reason for this is that 28EDO is inferior to both 27EDO and 29EDO for representing just intonation.

There is one interval that is approximated extremely well in 28EDO -- 5/4, the major third. A just 5/4 works out to be 386.3 cents, while nine steps of 28EDO make 385.7 cents. Indeed it's approximated better in 28EDO than in any lower EDO. Since 5/4 sounds good in 28EDO, its inversion 8/5, the minor sixth, must also play well in 28EDO. Furthermore, since nine steps makes up the major third, it follows that three steps are a trienthird (1/3 third), 14/13.

The reason that 27EDO and 29EDO are superior to 28EDO is that the first two EDO's have much better perfect fifths -- which are more important than thirds. This may seem strange when considering 20EDL since this EDL has a major third but no perfect fifth. Yet 20EDL does have a perfect fourth -- the inversion of a perfect fifth. And so 20EDL's perfect fourth sounds better in 27EDO and 29EDO than in 28EDO.

Moreover, all EDO's contain several copies of the simplest intervals -- when we consider all of the intervals of scale, not just the ones on the base. In fact, we see that 20EDL contains three perfect fourths/fifths -- Degrees 20/15, Degrees 18/12 (perfect 5th), and Degrees 16/12 (perfect 4th). On the other hand, the scale contains only two major thirds -- Degrees 20/16 and Degrees 15/12. Thus even in 20EDL, perfect fourths/fifths are more prevalent than major thirds.

In the end, this means that EDO's that approximate the perfect fifth well are more likely to show up in lists for approximating EDL's, even if they fail at other intervals. We see that 29EDO has an excellent perfect fifth -- its fifth is more accurate than any lower EDO, including 12EDO. On the other hand, 28EDO has a comparatively poor fifth.

The fifth of 28EDO is the same as that of 7EDO (that is, 28 is contorted in the 3-limit) -- 686.7 cents, much flatter than a just 3/2 of 702 cents. A circle of fifths contains only seven notes -- in other words, B-F is a fifth, and the difference between F-F# or Bb-B is tempered out. So in 28EDO, we must use ups and downs, since sharps and flats are tempered to the unison.

The fifth of 28EDO is so flat that the interval C-E (which means, by definition, four fifths reduced by two octaves) is flatter than a major third (even though 81/64 is sharper than M3). In other words, 28EDO is not meantone since it doesn't temper out the syntonic comma -- instead, the syntonic comma is mapped to -1 (negative one) step. This is one of the weird things that happen when we use an EDO with an inaccurate perfect fifth.

So why, then, did I choose 28EDO for the Easter song? The truth is, 28 = 4 * 7, and both 4 and 7 are important in calculating the Easter date. (The significance of seven is obvious -- the seven days of a week from Sunday to Sunday. I explained why four is important back in my Easter post).

In fact, suppose we define an Easter interval to be the difference between consecutive Easters. (This year Easter was on April 1st and next year it's on April 21st, so 20 is an Easter interval.) Then 28EDO is the only scale in which the inversion of an Easter interval is itself an Easter interval. For example, in 28EDO, the inversion of 20 is 8, which is an Easter interval. (Compare the consecutive Easters April 12th, 2020 and April 4th, 2021). But in 27EDO, the inversion of 20 is 7, which is not an Easter interval. (No consecutive Easters can be seven days apart, since both dates obviously can't land on Sundays in both years.)

Thus 28EDO is the best EDO for the Easter song, even though as a musical scale, it's inferior to its neighbors 27EDO and 29EDO.

Here's what Xenharmonic has to say about 28EDO. It's not as extensive as 27EDO and 29EDO, for reasons that I've made clear:

Basic properties

28edo, a multiple of both 7edo and 14edo (and of course 2edo and 4edo), has a step size of 42.857 cents. It shares three intervals with 12edo: the 300 cent minor third, the 600 cent tritone, and the 900 cent major sixth. Thus it tempers out the greater diesis 648:625. It does not however temper out the 128:125 lesser diesis, as its major third is less than 1 cent flat (and its inversion the minor sixth less than 1 cent sharp). It has the same perfect fourth and fifth as 7edo. It also has decent approximations of several septimal intervals, of which 9/7 and its inversion 14/9 are also found in 14edo.

Converting EDO Scales to EDL Scales

When I wrote the Easter song, I played it in Mocha. But the Easter song is written in an EDO scale (28EDO), while Mocha can play only EDL scales.

Just as it's possible to convert EDL's to EDO's, the reverse conversion is possible. And we can write the program for finding the best EDL scale for a given EDO in Mocha itself:

20 A=0:B=L
30 A=A+2: E=0
40 FOR X=1 TO L-1
50 C=2^(-X/L)*A
60 D=INT(C+.5)
70 E=E+ABS(C-D)
100 GOTO 30

Once again, we press the up-arrow for the ^ symbol in Line 50. This gives us the powers of two used in the given EDO. The list of EDL's begins with the trivial 2EDL and then counts up by two, since we're assuming that octaves are available.

Just like the EDL->EDO program, this EDO->EDL program runs forever, so we must press the Esc key in order to stop the program. It's also possible to have the program stop at 260EDL (since Mocha only goes up to Degree 260). Then we can actually have Mocha play the winning EDL scale, which we'll keep track of in variable W:

100 IF A<260 THEN 30
120 FOR X=0 TO L
130 C=2^(-X/L)*W
140 D=INT(C+.5)
150 PRINT D;
160 SOUND 261-D,4
170 NEXT X

Here I have the computer print the Degrees of each note in the winning scale. If you'd rather the computer print the Sounds of each note instead, then change Line 150 to print 261 - D rather than D.

For the simplest nontrivial EDO (2EDO), Mocha prints out the following list:

2EDO: 2, 4, 10, 24, 58, 140, ...

This means that 140EDL is the best scale in which to play the 600-cent tritone -- the only nontrivial interval of 2EDO. The Degrees played are 140-99-70 -- which means that the ratios 140/99 and 99/70 are being used to approximate this tritone. Notice that these are both rational approximations of sqrt(2) (the exact ratio of the tritone).

Here are the EDL lists for a few selected EDO's:

4EDO: 2, 4, 6, 10, 20, 44, 106, 232, ...
5EDO: 2, 4, 6, 8, 12, 24, 38, 54, 94, 132, 256, ...
8EDO: 2, 4, 8, 12, 14, 20, 44, 62, 74, 88, 170, 202, ...
10EDO: 2, 10, 14, 16, 26, 54, 164, 256, ...
12EDO: 2, 4, 6, 8, 16, 18, 20, 24, 64, 126, 232, ...
16EDO: 2, 8, 22, 24, 26, 42, 74, 214, ...
18EDO: 2, 16, 24, 26, 28, 84, 98, 246, ...
20EDO: 2, 10, 26, 28, 30, 32, 54, 94, 108, 112, 116, 164, 224, ...
23EDO: 2, 12, 32, 34, 36, 102, 122, 126, 188, 256, ...
28EDO: 2, 24, 38, 40, 42, 64, 74, 128, 210, ...
30EDO: 2, 16, 18, 40, 42, 44, 46, 54, 138, 148, 170, 228, 256, ...
31EDO: 2, 16, 40, 44, 46, 48, 60, 82, 136, 152, 170, 234, ...
32EDO: 2, 28, 46, 48, 50, 74, 156, 232, ...

In this list, we see that both 5EDO and 10EDO are approximated by 256EDL. This is logical, since 5EDO is a subset of 10EDO. Likewise 30EDL (another multiple of 5EDO) has as 256EDL as the best approximation. But 20EDL isn't approximated by 256EDL despite being a multiple of 5EDL, while 23EDL is approximated by 256EDL despite not being a multiple.

As for 12EDO, we see that it's approximated by 232EDL, as is 4EDO. Another multiple of 4EDO has its best approximation in 232EDL, namely 32EDO. But the other multiples of 4EDO aren't closely approximated by the 232EDL scale.

Here's what 12EDO looks like in 232EDL. Degree 232 itself is closest to F#/Gb, and so we simply fill in the other notes of 12EDO:

12EDO as approximated by 232EDL:
Degree     Note of 12EDO
232          F#/Gb
219          G
207          G#/Ab
195          A
184          A#/Bb
174          B
164          C
155          C#/Db
146          D
138          D#/Eb
130          E
123          F
116          F#/Gb

But only estimating macrotonal EDO's (that is, those less than 12EDO, where each step is more than 100 cents) is recommended. As the number of steps increases, the EDL's are less accurate. This is because the step sizes in EDL's (in cents) increase as we ascend the scale, while the step sizes in EDO's are all equal.

Since step sizes are smaller near the low parts of the scale, the assumption is that approximating an EDO by EDL is more accurate if the degree is large. The above list of EDO's (from 4EDO to 32EDO) shows only those where an EDL close to 256 appears in the list. Interestingly enough, more even EDO's appear than odd EDO's. (On the other hand, another way to determine the accuracy is to look at the variables E, for error, and B, for minimum errors. As it turns out, odd EDO's have smaller values of B/L -- the average minimum error for each step -- than even EDO's, thus implying that it's the odd EDO's that are more closely approximated.)

If a microtonal EDO (past 12EDO) must be played, then only 16EDO or 18EDO are recommended, since the accuracy quickly drops off from there. (If we wish to play 12EDO itself, then there's already a PLAY command available for this scale.)

This means that 28EDO is not a recommended scale to play, as the accuracy is not good. Yet I play the Easter song in this scale -- only because I have no instrument that can play 28EDO and is more accurate than Mocha. Again, the computer is designed to play EDL scales, not EDO scales. And according to the list, the best approximation to 28EDO is 210EDL. Therefore, the Easter song in Mocha is actually written in 210EDL.

Eighth and Sixteenth Notes

The Mocha randomizer that I've been using so far chooses among four different lengths for the notes, namely quarter, half, dotted half, and whole notes. But real songs -- ones which fit lyrics -- often need faster notes such as eighth and sixteenth notes.

In fact, sometimes I've used the randomizer, and was disappointed because Mocha randomly chose to play three whole notes in a row. It's difficult to sing lyrics over long whole notes. The song "Pop Goes the Weasel" above uses quarter, half, and dotted half notes (since it's in 3/4 time), but the other songs I coded in the past month (the Dren and Packet songs) used mainly quarter notes.

Well, here's a program that adds eighth and sixteenth notes to the arsenal:

10 CLS
20 N=8
30 FOR A=0 TO 6
40 B=4
50 L=RND(B)
60 BB=4
80 D=21-RND(11)
90 P=A*32+(4-B)*8+(4-BB)*L*2
100 D$=RIGHT$(STR$(D),2)
110 PRINT @ P,D$
120 SOUND 261-N*D,L*LL
130 BB=BB-LL
140 IF BB>0 THEN 70
150 B=B-L
160 IF B>0 THEN 50
170 NEXT A
180 PRINT @ 224,"20"
190 SOUND 261-N*20,16

Here's how this program works -- no, it doesn't randomly choose a length from 1 (the sixteenth note) to 16 (the whole note). This is because some note lengths, such as 5 (a quarter note plus a sixteenth note) or 7 (a double-dotted quarter note) are rare.

Instead, it chooses a note length L, from 1 to 4. But then whichever note length is chosen is itself divided into four parts, LL, which also ranges from 1 to 4. For example if L = 2, then this denotes a half note. Then LL = 1 indicates an eighth note (1/4 of a half note), LL = 2 is a quarter note, LL = 3 is a dotted quarter note, and LL = 4 is a half note. If L = 1, then sixteenth notes and dotted eighth notes are possible. If L = 4, then it runs like the old program, where LL = 1 is a quarter note and LL = 4 is a whole note.

The only rare note length that this produces is when L and LL are both 3. Then the total note length is 9/16 (a half note plus a sixteenth note). Hopefully, L = LL = 3 will be rare enough that this won't make too much difference. (Such a note will always be preceded or followed by a dotted eighth note to add up to three whole beats.) But if it causes to many problems, then we can add extra lines to make sure that L and LL can't both be 3. For example, you might change Lines 30-40 to:

30 FOR A=0 TO 13
40 B=2
180 PRINT @ 448, "";

This effectively changes the song to 2/4 time, and by doing so, this will also block all dotted half notes and whole notes (except for the very last note, which is always a whole note). Then again, this might be desirable if we have long lines of lyrics and we want to be sure to avoid long notes. (We must also change Line 180 -- the final note no longer prints at the wrong place, but fortunately we already know what the final note is so we don't need to print it.)

Lines 90-110 are there to print the Degrees on the screen in columns to imply the note lengths. The idea is that once we create a random song that we like, we write it down on paper and then write a new program that plays the song we created. Every two columns corresponds to a sixteenth note, and the string commands (using $, the dollar sign) are there to make sure that the Degrees print correctly.

The program is currently set up for 20EDL. We can change these to other EDL's as follows:

80 D=13-RND(7)
80 D=15-RND(8)
80 D=17-RND(9)
80 D=19-RND(10)

for 12EDL, 14EDL, 16EDL, 18EDL respectively. In the first line, RND(7) is a random number from 1 to 7, so 13-RND(7) is a random Degree from 12 to 6 -- the Degrees of 12EDL. As usual, N in Line 20 tells us which key the song is in. Larger values of N are lower keys -- the maximum value of N is chosen to that N times the size of the EDL is no larger than 260. Once again, for 12EDL, N can be as large as 21, while for 20EDL, the max value of N is 13. Oh, and if we change the program from 20EDL, then the 20 in lines 180 and 190 (for the final note) must be replaced with the proper value.

For this program, I dropped the rule that the notes alternate between chords (for example in 12EDL, the first measure starts with 12, 10, or 8 while the second measure starts with 11, 9, or 7). The program is hard enough to write without keeping track of the chords. We'll just have to figure out which chords to play on the guitar after the song is written.

Oh, and the following change again allows us to write songs in 3/4 time instead of 4/4:

40 B=3

Also, change the final 16 in the last line to 12 to make the last note sound as a dotted half note.

Now I believe I have all the code I need to create my own songs. My next post will be on Friday, June 15th -- the day I hope I'll get in my summer school classroom. If that happens, then in that post I'll write about one final EDL scale, as well as my plans for classroom management.

No comments:

Post a Comment