Do you want more realistic sounds
than beeps? This article gives you five short programs that let your
Atari produce some interesting, subtle sounds.

There are many packages available for making the Atari a music box. All
provide some degree of musical verisimilitude; that is, they sound
good. However, these packages don't really help those who are tired of
hearing the same old beeps in their programs.
Let's consider how tones are generated in the real
world and try to duplicate them on the computer. And take heart: It
will all be done in BASIC. You won't even find a page 6 subroutine. You
can improve on what I have done once you understand what is going on.

Frequencies And
Amplitude
Sound is generated by vibrating objects. Each object sounds different
because it has a different set of resonant frequencies. Also, each
object has a different set of loss parameters that determine how
quickly the amplitude of the sound will rise and fall. Other factors
such as the noise content add to the character of each individual sound.
The resonant frequency of an object is the dominant
characteristic, so let's take it first. Strike a bell or play a note on
a piano and you don't hear just one frequency, you hear a wide range of
frequencies. The lowest frequency is called the fundamental frequency.
Most objects also support harmonics of this frequency. The even
harmonics are two, four, six, eight, and so forth times as high as the
fundamental. The odd harmonics are three, five, seven, nine, and so
forth times as high.
The mix of these frequencies and whether they are
odd or even are components of the character of the sound. A piano is
rich in even harmonics; a woodwind is rich in odd harmonics. There is
one further complication: Most objects have more than one fundamental
frequency, and each fundamental frequency may have its own set of
harmonics. It is thus obvious why simple beeps lack the complexity of
real sounds.
The next factor is how fast the amplitude of these
frequencies rises and falls. When a drum is struck, it gives a short,
loud sound, so its amplitude rises and falls quickly. A piano note is
loud, but is sustained for some time. A woodwind rises slowly in
amplitude and falls slowly.
The simplification used for electronic simulation of
musical instruments is called the ADSR envelope (shown in the figure).
These letters stand for Attack, Decay, Sustain, and Release. Across the
top are times 1 through 4 and amplitudes 1 and 2. A struck instrument
has a very short t1 and a somewhat longer t2. For a piano, t3 and t4
are relatively long and for a drum, t3 and t4 are short. Also for
struck instruments the amplitude al will be at least twice as great as
a2, but in a woodwind they may be the same.

Noise And Tone
The third factor is the amount of noise. This is easily heard in a
snare drum, which contains added wires to make noise. It is less
obvious in woodwinds, where the very act of blowing creates some noise.
Blowing is similar to whispering, where there is little tonal content
and the lips and tongue are modulating noise. A "breathy" speech
pattern is comparable to a horn or woodwind. Thus a low amplitude
component of noise can add to the realism.
With these three factors in mind, let's examine a
woodwind in detail. The artist is aware that the instrument has a slow
attack time, so he will blow harder at the beginning of a note to give
it a definite start. In doing so he will increase the noise level. The
initial breath will start the instrument vibrating, and the various
fundamentals and harmonics will be heard. If the instrument is being
played loudly, some of the harder-to-excite frequencies will be heard
too.
Once the instrument has established its note, the
artist will blow more softly, so the tone content will be up, but the
noise component will be down. Finally the note will end, and the artist
will stop blowing. The noise component will stop immediately, but the
tonal component will continue for a short time. If all this doesn't
sound complex enough, imagine what goes on in a slide trombone.
Real sounds are complex, but computergenerated tones
are not. So we must make them complex to make them realistic. For a
perfect simulation of a piano or clarinet, a Moog synthesizer is
definitely preferred. To make do with the Atari sound chip, machine
language might be preferable. But if you draw a line with one end being
the beeps and the other end the Moog, we'll see that BASIC can get us
more than halfway toward the Moog.

Experimenting With
Sound Qualities
The following programs are examples of some complex sonic effects.
These programs directly POKE the audio control registers with amplitude
information. The amplitude varies from 0 (off) to 15 (loudest). These
amplitude levels are stored in S0$ in pairs of numbers. These are
converted to numbers in line 21 and POKEd in line 22. The cycle through
the loop provides automatic timing for note duration. Q=1 ^ 1 is used
for timing pure tones.
Program 1 is a direct comparison between notes with
and without an ADSR amplitude envelope. The S0$ envelope here is that
of a struck instrument. Note that the first value in S0$ is 15 for
shortest Attack, then a 12 to provide a slower decay, three 08's for
sustain, and then 04 and 00 for a slower release. You will certainly
notice the difference in tones when you run the program; in fact, the
switch from envelope to no envelope is itself a pleasing effect.
Program 2 offers a somewhat different effect by
playing two chords with and without the envelope.
Program 3 introduces the effect of harmonics on a
single note and again gives a side-by-side comparison. These are the
even harmonics found in pianos. Note several points here. In most
instruments the fundamental frequency is the loudest, then the
harmonics. And the fourth harmonic may be louder than the second. In
real instruments there are both odd and even harmonics. A string
plucked in the center produces a different sound than a string plucked
near the end. I have ignored both of these points in this program.
Program 4 is similar to Program 3 except that it
provides odd harmonics with and without the ADSR envelope. Program 5
compares even and odd harmonics with the envelope. In both programs I
have ignored the complications-or let's say that I have created a
musical sound that cannot be duplicated by a musical instrument.
Remember, the objective of this article was to show
ways to add color to your sounds, not to synthesize the Boston Symphony
Orchestra. So let me give you some further suggestions. In any of these
programs, change line 20 to FOR I=8 TO 1 STEP - 1 and you will have a
sound that can be duplicated only by playing a tape recorder backwards.
How about adding odd and even harmonics of the same fundamental
frequency? Perhaps instead of having the Release part of the envelope
go to 00, it would go back up to 15. How about using one of the sound
channels to add the slight bit of noise that goes along with some
instruments?

Please refer to "COMPUTE!'s Guide To Typing In Programs" before
entering these listings.