Music
Melodies
This section uses Atari Logo to make tunes, to combine them to make
bigger ones, and to manipulate melodic elements by playing them back-
ward and transposing them upward and downward. The section concludes
with a pitch and rhythm sequencer.
Playing a Tune
lets you play single-voice melodies. It takes two inputs, a list
notes to play and a duration, and plays each note in the list with that
duration.
The notes are represented as positive or negative integers. The letter
R in a list is interpreted as silence (that is, a rest).
Try the following melody. Type:
The melody you just played is "Twinkle, Twinkle Little Star." The ampli-
tude (loudness) of each of the notes of the melody cannot change.
Duration Using
TUNE gives the same duration to each note in the list. You might try different
durations with the same list of notes. For example:
By Greg Gargarian.
MELODIES 231
or
IJ r TJ
i m
The difference in these two melodies is that the first is played twice as fast
as the second.
Numeric Pitch Representation in
Here's how to translate between musical notations. Beneath each note is
the letter for the note as well as the number that uses for that note.
i
ct=
The following is a melody using this notation. You see the traditional
music notation for "Twinkle, Twinkle Little Star" along with the traditional
note names. Underneath is the list of numbers TUNE uses to reproduce that
melody.
9
3 =
J
- f —
«
1—-—»
— " —
0 m » m m - i
As we mentioned earlier, is interpreted as a rest. What really
does when it sees an is make the frequency of the note so high that you
can't hear it! (That's what the high frequency of 15,000 is doing in
Putting Melodies Together
You can give a list of notes a name. For example:
Now type:
You can put different melodies together. Here we will stay with "Twin-
kle, Twinkle" and make another list of notes as a continuation of the mel-
ody. Let's give it the name
MUSIC
Now type:
Because this part of the melody is normally repeated, it's exactly half as long
as You can use the command to play it twice. Type:
The procedure combines and to make the
entire melody.
To hear it, type:
The tempo of (that is, the rate at which the notes follow each
other) is determined by its duration input. To play at a faster tempo,
type:
How Works
goes through its list of notes, one element at a time, and plays each
note at the duration you specified. calls for each note.
PITCH converts each note number in the notes list to its corresponding
frequency. PITCH uses PITCHl to help.
The note in this program is A at frequency 220. The A an octave above
it has a frequency of 440. In fact, frequencies of notes an octave apart are
MELODIES 233
always related to each other in this way: going an octave<higher doubles the
frequency, going an octave lower halves the frequency. The variable : BASE
is doubled or halved to perform this octave-changing function.
There are twelve chromatic steps in an octave. Therefore, the fre-
quency of each note in the scale is the twelfth root of two higher than the
next. Multiplying a note by 1.0595 gets the next note in the scale. The
chromatic steps in between the octaves are determined by multiplying
: BASE by 1.0595 n times, where n is the number of chromatic steps.
's note numbers start at a frequency of 220. That A is 1, and all
the notes in the scale go up or down from there.
Symmetry in Melodies
One way to listen to the characteristics of a melody is to hear it backward.
(This is similar to the kind of analysis sometimes done in a painting class.
People will often look at a painting sideways or upside down in order to
concentrate on the shapes and colors rather than the figures themselves.)
You use to put list of notes in reverse order. Try it by typing:
You should get:
as your result. You can compare the sound of a list of notes forward and
backward using with and without Type and listen to the
following:
To hear the reverse of it, type:
Also try:
You can use to build a symmetrical melody from a short one.
The procedure takes a list of notes and plays it in the given
order, then plays it in reverse order. (By the way, this reversing process is
usually called taking the retrograde of the phrase.)
234 MUSIC
Listen to the following examples, the first using our four-note phrase
and the second using the tune list :
In the next example, we construct a substantial melody with only two
four-note phrases. We use the same four notes played before and make up
another melody. Type the following:
Now we put these two melodies together in the procedure
Play it by typing:
With eight notes we have been able to construct a twenty-four-note
song! Try other melodies of your own design.
Transposing a Melody
A melody has a certain shape or contour that can be preserved regardless
of the pitch at which the melody starts. If you add or subtract a musical step
(or several steps) from each note in a melody, you don't change its overall
shape. This process of raising or lowering all the notes equally is called
transposing.
Transposing Up
transposes all the notes of a phrase up.
works by adding its second input to each of the numbers in its input list.
Try:
This is equivalent to typing:
MELODIES 235
Listen to the difference between the list, before and after it has been
transposed up.
Type:
and then
An Effect Using
and use to create the effect of a tune
climbing. takes a list of notes as its first input and transposes it
up step by step as many times as you want. The number of steps is 's
second input.
Try:
Transposing Down
is similar to except that the melody is
transposed down.
Type:
Then listen to each of the following:
236 MUSIC
A Single- Voice Music Sequencer
A music sequencer is an instrument that will repeat a sequence of notes for
an indefinite period of time. We can make one by modifying
Type:
m
Press BREAK to stop.
T h e big difference b e t w e e n and is that
repeats your tune over and over. It won't stop until you press BREAK. In
the first note is played, then removed on the recursive call.
Short Durations
If the duration of the notes gets very short, you may want to change the
"envelope" of the voice—that is, the rate at which the sound goes to silence
(or decays) after its duration has been expended. This prevents a note from
"spilling" into the next note.
's first input determines the voice. Since we're using voice 0 in
the first input to should be 0. It's the second input to
that determines the decaying time for the note. Try
1, which is a quick decay.
Type:
Try other values. To restore values, type:
A Single-Voice Rhythm Sequencer
is a single-voice rhythm sequencer that makes bongolike
sounds. This procedure expects its list of notes to include only the letters
and (for high, medium, and /ow) and (for rest). Type the following
two lines and listen to the result, pressing BREAK to stop.
H
M-
L
1 I
MELODIES 237
Press BREAK to stop.
The second input is the duration for each of the notes in the list.
Traditionally speaking, rhythm usually implies periodic or repeating
patterns. The list of elements that you have given becomes
such a pattern as it continues to repeat. For example, type:
This is a five-beat pattern that gets its rhythm from the sequencing
action alone.
A second way to produce rhythmic patterns is to use rests in different
ways. Since RHYTHM . SEQ doesn't have many notes, you can concentrate on
how far apart to space them in time. For example, type:
This has an internal feeling of three (waltzlike), yet it is a ten-beat
pattern. Both rhythms seem to coexist.
A third way in which to construct patterns is with the low, medium, and
high pitches. They can be used to either reinforce the existing patterns or
they can serve as counterpoint to them. For example, type:
H
M-
L
J 3 1 i m
This rhythm reinforces the patterns of the previous ten-beat pattern by
repeating the low-medium-high sequence almost three times (there's a rest
in the middle of one of them) and by adding an additional rest between one
of these repetitions to get the ten-beat phrase. Try the previous rhythmic
sequences at a faster tempo by typing:
[L
HOW Works
was designed by modifying The most conspicuous
difference is that uses a procedure called instead of
to produce the frequencies.
+
+
+
238 MUSIC
15,000.
PROGRAM LISTING
[J]
EAR TRAINING 239
+
+
+
Ear Training
How to Use the Ear Training Tutorial
m 9m
\>0
9+
m ~
By Greg Gargarian.
240 MUSIC
Running the Program
Those of you who feel bold can run the tutorial without reading this section.
Type:
The following is a step-by-step description of how to use the program.
The program prints out the following instructions.
(a sound here)
(a sound here)
Then the program gives you two notes and states:
Let's say you type:
MAJOR.6
There are two possibilities: either you are right, in which case it re-
sponds:
or you are wrong, in which case it responds:
If you had typed ? and RETURN the program would have informed
you of the interval you had just heard.
The program then gives you instructions.
EAR TRAINING 241
Pressing RETURN gives you a new interval. If, when you hear an
interval, you are not sure of the answer, you may listen a second time. When
the program states:
pressing RETURN causes the same interval to be repeated, this time with
the notes played together as well as one after the other.
PROGRAM LISTING
[]
[]
[]
[]
[]
[]
242 MUSIC
Sound Effects
This write-up presents a palette of sound effects to give you ideas for using
sound in your own projects. We've kept our discussion brief. Instead, we ask
you to use your ears. Some of these sound effects are new, others are taken
from projects found elsewhere in this book. You might want to try them out
and use those effects you like in your own projects, either as they are or in
modified form. The procedures in this collection use the Atari Logo music
primitives and
A European Ambulance Siren
Typing the following lines results in a European ambulance sound.
By Greg Gargarian and Margaret Minsky; with contributions by Max Behensky.
SOUND EFFECTS 243
Advancing and Retreating Sounds
The procedures and make sounds like something is rush-
ing toward you or retreating from you. When sound sources advance to-
ward you, you hear their pitch rising slightly and their volume increasing.
When they retreat, you hear a falling pitch and decreasing volume. That
is what these procedures try to do.
and take two inputs. The first is a starting pitch for
their sound and the second is or for the speed of the advance
or retreat. These procedures make sounds in both voice 0 and voice 1.
Here are the procedures for
Try:
Here are the procedures for
244 MUSIC
Try:
You might want to try some other inputs.
You can try putting them together.
This one sounds like a monster snoring.
Making Sliding Sounds: Glissandi
The procedure makes a sound that slides "smoothly" from a starting
pitch to an ending pitch.
Try:
You get the idea. The first input is the starting frequency, the second
is the ending frequency, and the third determines the rate of the slide. The
bigger the third input, the faster the slide.
Try:
SOUND EFFECTS 245
A Motorcycle Sound
A More Continuous Sliding for an Ambulance Siren
:S
:S :S "S :S
A Spaceship Sound
246 MUSIC
For a zigzag sound, try the following:
For a spaceshiplike sound, try:
Try:
A Boing-ng-ng Sound
BOING works best in the low register . . . boings usually do!
BO I NG's first input is the frequency of the boing and the second input
is the duration (in sixtieths of a second).
Try:
SOUND EFFECTS 247
Trills and Thrills
More with Trill
248 MUSIC
Bird Sounds
and are two different kinds of bird sounds.
uses to make a short and upward-gliding sound at a high
frequency.
Try:
Try:
Bird Music
makes a birdlike song using and To create
variety and are played alternately, each a random
number of times.
Listen to it by typing:
Press the BREAK key to stop!
Sound for Jack and Jill
is the music finale to the Jack and Jill project found in this book.
SOUND EFFECTS 249
Try:
Since does you might want to restore by saying:
Playing with and Amplitudes
' S input is for the frequency. As the note gets faster, its
amplitude gets quieter and, near the end, its envelope gets shorter.
Try:
You can shorten the longer durations of the bounce by lowering the
duration input to (that is, by changing to a smaller number).
250 MUSIC
An Echo Effect
is similar to but doesn't get faster as it gets quieter. It
uses to gradually change the decay of the repeating notes and
to produce the frequency, starting envelope, and pulsing rate of the
echoed note.
Try:
Now type:
Press BREAK to stop!
NAMING NOTES 251
Naming Notes
In the Melodies project, notes are represented by numbers that are later
converted to appropriate frequencies. It takes time to do this for each note.
If you want to play notes very rapidly one after the other, you can use
another technique described in this project. The idea is to precompute the
frequencies that correspond to the notes. In this project, we do this by
giving names to these frequencies. The names we chose in this project come
from traditional music notation, for example A#4, which represents the
A-sharp in the fourth octave of piano pitches. We might make this a name
by doing
Thereafter (as in the Argue program) you can use THING to refer
quickly to the frequency of a note. For example, if : is then
is Using this scheme, your music procedures would
contain lines like
You might have to name a lot of notes. This means there will be a lot
of variables, and they will use up quite a bit of Logo's workspace. Sometimes
it is worth it.
This project shows a program that automatically creates note names
like and figures out the right frequencies. It does this for several oc-
taves.*
Naming Notes
This program uses the naming technique just described to allow fast sym-
bolic access to musical notes. The names follow a convention similar to
standard music notation where, for example, would be the name for G
in the third piano octave.
Some examples:
Since we want to have names like these for many notes, we create
procedures that automatically calculate and name frequencies.
*It is nice to use names like A#4, but the same technique can work with numbers (or
anything else) as the names of variables for the notes. The main advantage of this project's
technique is the use of variables for fast access to precomputed values. You could, for example,
do MAKE 38 4 6 6 to give the name 38 to the frequency 4 6 6.
By Max Behensky and Margaret Minsky.
252 MUSIC
Procedures for Naming Notes
calls to make the variables for each octave.
Each note name is created (in by making a new word out of
the appropriate prefix and the octave number. Then updates
the octave number and the lowest frequency for the next octave. This
continues until eight octaves of pitches have been named.
In the twelfth root of two is used in the following formula
to compute the frequency of a note one half-step above another.
(frequency of a note) twelfth root of 2) = (frequency of next note)
Playing Melodies with Named Notes
Run to create the note variables. Now you can use a procedure
such as to play a melody.
You could name lists that represent phrases of songs and play them
with Here are some examples.
NAMING NOTES 253
For more ideas about what you can do with melodies and rhythms, see
the Melodies project.
Making Turtles Move to Your Song
Here's a program that makes a turtle show the "ups and downs" of your
song. You can use it by trying the procedure with a list of notes
as its input. For example, try
Here are the procedures.
254 MUSIC
These procedures draw lines on the screen whose lengths represent
pitches. They fit best for notes in the range from : (110) to : (640).
Using the Atari Keyboard as a Music Keyboard
is another example of using the precomputed notes; it makes the
Atari keyboard act like a music keyboard. Start it up by typing
The program takes a while to set itself up, then it types
Now you can play music by pressing keys. Notes are assigned to the
keys according to a layout that is like that of a piano keyboard:
INSERT DELETE
1 BACKS I
D E F G A B C D E
1 0 P
|fl
TAB W E T Y
1 1 1 |a 1B
G A C D
AI
c D E F B
SHIFT
Z X c V M
NAMING NOTES 255
In order to make the layout similar to that of a piano, some of the keys
do not play any note. Reminder: Take care not to press the Atari (/|\) key.
The Music Keyboard Procedures
also creates variables for fast reference. It creates variables
whose names are names of Atari keyboard keys (for example and
whose values are names of notes. This is done by For exam-
ple, : becomes
then calls waits for you to press keys. It
converts the name of the key you pressed to the name of a note and calls
to play it. converts the name of the note to a frequency and calls
the Logo primitive to make the sound.
There are a couple of fine points in this program. The length of time
each note sounds is controlled by the global variable : which is
set up in the procedure and by the commands in the proce-
dure Also, the input to makes it possible for you
to press two keys in quick succession and hear both notes. The
procedure calls itself alternating between 0 and 1 as values for : This
allows the program to alternate the playing of notes between the Atari
sound hardware voices 0 and 1. Thus one note keeps sounding in one voice
while the program starts a second note sounding in the other voice.
Reminder: After using the program, you may want to restore
the music envelope decay to its initial state by saying and
256 MUSIC
PROGRAM LISTING
NAMING NOTES 257