Classic Computer Magazine Archive HI-RES VOL. 1, NO. 2 / JANUARY 1984 / PAGE 40

Music Theory Drills

by Duane Tutaj

My wife and I teach private music lessons in our home. While our students wait for their lessons to begin, they use an Atari computer to test their note reading ability, or their knowledge of music theory.

This month I'll start a series of articles and programs which offer the reader the fundamentals of music theory. Later, we'll talk about creating computer music of your own.

Music Theory Drills is one of a series of programs that I've written that can be used by any student or music teacher. It drills a student on the names of the lines and spaces in both treble and bass clef staffs. You can add advanced features, such as ledger lines and sharps and flats to create a complete drill program.

The Music Staff

A music staff has five lines and four spaces, each represented by a letter or note. The names of the lines in the treble clef staff are E,G,B,D,F (counted from the bottom). The treble clef is commonly called the G-clef and centers on the second line of the staff, the G. The bass clef, a comma-shaped insignia followed by two A dots, resides on a staff below the treble. The bass clef line names are G, B, D, F, A.

fig. 1.

The spaces between these lines are named as well. The treble clef spaces are F,A,C,E. The bass clef spaces are A,C,E,G. On an imaginary line between these two staffs rests middle C. See Fig. 1.

The musical alphabet contains the letters A, B, C, D, E, F and G. To determine the name of a note above or below the staff, continue the musical alphabet up or down until you reach your goal.

The Music Theory Drill program starts by displaying two title screens and playing a short arcade-type song. This is followed by the menu, which shows the options of play available. See Fig. 2.

The user can choose option 1: treble clef notes only; option 2: bass clef notes only; or option 3: a combination of both treble or bass clef notes.

When you enter your choice, the computer will randomly generate 20 questions. You will be shown a treble or bass clef with a whole note on a line or space in the staff (see Fig. 3). Middle C is also tested, as well as the first space notes above and below the staff.

The computer asks you for the name of the note. Entering your answer, you will either hear a high happy sound or a low raspberry-type sound, indicating right or wrong. The screen also prints: That's correct or Sorry, that is not correct. The correct answer is ---.

A new screen will appear after 20 questions, showing your test results and percentage score. You'll also have a chance to play again.

After my students have mastered the treble and bass clef note names, they advance to a more difficult version of this drill which includes ledger lines, sharps and flats. The students save the results of these drills on disk, so that I can recall them later and find out which students need to review this drill and which students can go on to the next.

I've written drills on key signatures, kinds of notes, note values in various time signatures, pitch recognition, etc. My advanced students use the computer as a means of exploring sound and music composition.

In future issues I'll cover the different rhythms used in music and provide a program that will teach all the different types of notes. After that, I hope to go into more detail about how the opening arcade music in this program was put together.

Fig. 2. A menu from Music Theory Drills.

Program Description

The program starts by initializing some arrays and filling them with a location variable, sound values and note names. The keyboard is opened up for the Get command. Array YY(4) is used in the arcade sound routine at line 25000. Array NNN(24) is used for keeping track of the location variable that plots the notes to the staff. Array PP(23,3) holds three important items: the low byte, high byte, (used in 16-bit music generation) and name of the note.

I was forced to use the 16-bit sound generation, because of the low notes in the bass clef. The sound statement would not produce the correct pitch. More on 16-bit sound later.

Lines 10 through 80 contain several subroutines that call the title screens, play the arcade music, check for number of questions, plot the staff and get the first note.

Next, I determine whether to print the treble or bass staff (lines 2000 to 2027) and then plot either the treble clef sign (lines 2029 to 204 1) or the bass clef sign (lines 2049 to 2090).

After I have drawn the whole screen, I call the sound routine and turn on the screen again with a Poke 559,34.

The logic for the answer occurs in lines 2210 to 3032. Lines 3050 to 3330 plot the individual notes, by comparing the random number with the corresponding number in the note arrays and then plotting the correct points to the staff.

Fig. 3. A sample screen from Music Theory Drills.

Next is the 16-bit sound routine. While I won't go into a complete description of all the techniques of 16-bit sound production, I will explain how to use this routine in other programs.

If you have used the Sound statement before in Atari Basic, you know about the chart of pitches in the various reference manuals. By using the numbers in the charts, you are able to produce about three and a half octave range. The 16-bit sound generation increases the range to more than seven octaves with the tuning more exact.

To use 16-bit sound generation, execute a Sound 0,0,0,0 statement to turn on the Pokey chip. Poke 53768,120 turns on the audio-mode control register (Audctl). The number 120 combines channels 1 and 2 as one voice and 3 and 4 as the other voice with a clock frequency of 1.79 MHz.

Poke 53763,168 to set the distortion and volume levels. Frequency is set in the Pokes to 53760 (lo byte) and 53762 (hi byte). If you wish to use this technique in your programs compare the values in array PP(23,3) to determine the pitch and name of the note.

Be aware that any use of the sound statement, after you have set up 16-bit generation, will cancel the 16-bit sound.

Lines 4000 to 4100 are the right answer routine message followed by lines 5000 to 5110 which contain the wrong answer routine.


(4) Arcade music array.
Plot note variable.
16-bit note sound variables and
names of notes.
Temporary variables.
Option of game drills.
Random staff variable.
Input variable.
Name of note.
Plot note variable.
Correct answer variable.
Wrong answer variable.
Question counter.
Total question variable.
Percentage score variable.

Table 1: A list of variables I used in Music Theory Drills.

Lines 7000 to 7010 determine which staff should be drawn and then jump to that routine. The staff lines are drawn with the routine at lines 8000 to 8080.

Lines 13000 to 13007 contain the routine that draws the note on the staff. This is based on the variable which was placed in the array NNN(23).

Lines 18100 to 18200 contain the sounds that go with a correct or incorrect answer.

Lines 20000 to 20175 print the title screens and call the arcade music subroutine. The Menu is also printed to the screen. After a selection is made, the main variables are given values, and the program returns to the main loop.

Lines 22000 to 22160 check for whether 20 questions have been completed or not, and when this level has been reached, the score for the quiz is printed to the screen, and an option is given for doing the quiz again.

Lines 25000 to 26155 are the subroutine that plays the arcade music at the start of the program. Each note is placed in an array, and then all four voices are played. The technique is not hard, but a good knowledge of music notation is required, to have the rhythms turn out correctly. More on this technique in a future article.

If you wish to see the notes and staff drawn on the screen, without the screen going black, eliminate the Poke 559,0 in line 8000 and the poke 559,34 in line 2201.

Duane Tutaj writes on educational subjects for Hi-Res. He lives in Addison, Illinois.

Listing: MUSICDR1.BAS Download