Easy Logo keyboard musicby CRAIG McBAIN
A simple but adaptable Logo program that plays a musical scale from the Atari keyboard. Works on all Atari computers of any memory size. Disk or cassette.
Children love to sit in front of a piano keyboard and pound out simple
melodies. The child's joy comes from immediate success at making music
and a rare chance to control the environment.
With an Atari, Logo and just a few short commands, children can have the same kind of musical fun they would have with a piano, but with a little extra learning thrown in.
Turtle Piano converts the computer keyboard's home row-A, S, D, F, G, H, J, K, L, ;, + and *-into a l2-key piano that plays a do-re-me scale in the Key of C without sharps and flats.
It also changes the screen turtle into an eighth note which jumps around to the appropriate spot on a musical staff whenever a note is played. As each note is played, its letter-name is also printed on the screen.
Turtle Piano can also remember your compositions so you may listen to them over and over again.
Though it is not a particularly complex program, Turtle Piano is an engrossing project for young computer users and programmers. So type in Listing 1 and SAVE a copy before you RUN it.
HOW IT WORKS
BEEP, the heart of the program, uses the first sound channel (TOOT 0) to play the notes. After you have typed in the BEEP procedure, if you type BEEP followed by a number greater than 14 you will hear a nice note. The number 260.7 will give you Middle C. Why? A violin string (or anything else) vibrating at 260.7 cycles per second produces a Middle C.
The PLAY procedure ties the home row keys to their assigned pitch values. If a key is pressed which is not one of the home row keys, PLAY will output a frequency of 50000 (too high to hear). So you can use the space bar, for example, as a rest between notes. PLAY, using the SETY command, also draws the turtle on the staff.
Type BEEP PLAY "A to hear Middle C. PLAY takes the input character [A] and searches for its corresponding pitch value (260.7). PLAY passes this value to BEEP, which plays the appropriate note.
Note the relationship between the values for Middle C (260.7) and High C (521.5) in the PLAY procedure. Now, look at the values for the E and F tones. The higher note in each pair is double the pitch value of the lower note. This is always true. BEEP2, the next procedure, uses this fact to produce interesting results.
Try BEEP2 a few times and compare it with BEEP. It uses the second sound channel (TOOT 1) to play a tone which has half the pitch value of the first note. For example, if you press the [A] key, BEEP2 plays Middle C and the tone one octave below it.
We use the GET NOTE procedure to check the keyboard and store our notes. GET. NOTE passes each note to the REMEM procedure, which stores the notes in the variable LINE.
Type [START] to run the program. Now, press the [Y] key to start the piano. This invokes the START procedure. The [C] key calls the CLEANUP procedure which erases the text window and erases all your old tunes stored in LINE. If the [R] key is pressed, the REPLAY procedure will replay the list of notes stored in LINE.
The procedure REPLAY is really tricky This recursive procedure removes the top note from LINE, plays it, and discards it. Then, it starts again, playing the first note on the shortened list. REPLAY continues to remove notes from the top of LINE, play them and discard them until LINE is empty
The graphics portions of the program need little comment except perhaps for the LOGO names "STAFFHI, "STAFFLO, and "NOAT. Don't forget to type these, too. These variables contain lists of numbers which tell the computer how to reshape the turtles into musical notes. The turtles are reshaped in the SETUP procedure with the PUTSH command.
As stated earlier, this program is really pretty simple. Readers are encouraged to make it more special. With a little tinkering, Turtle Piano could flash different colors with each note, extend for another octave or two, or include sharps and flats. The basic structure can accommodate all these changes and more. The only rule is to share your ideas by sending them to Antic.
Craig McBain is a third grade teacher in Mt. Clemens, Michigan. His wife wishes that Atari Logo had never been invented.