SOUND AND MUSIC PROGRAMMING ON THE ST by Richard Karsmakers
Originally published in ST NEWS Volume 1 Issue 3, launched on
August 16th 1986.
Most people think that the ST's sound chip isn't really much, but
it's not that bad at all; you'd better listen to the music in
Epyx' "Winter Games" and you'll know that a lot more can be done
with the ST's YM 2149 sound chip. All right, it's not as good as
the Amiga soundchip, but that one works through a complete
different principle; it "knows" a lot of sounds, which are kind
of "digitized" inside its memory. When the programmer asks for it,
it just spits it out with variable pitch, tone height, etc. People
should also know that many Yamaha keyboards actually use the YM
2149 soundchip, like ICG's Yamaha PSR 40. The sound coming from
that keyboard isn't bad at all!
Some of us might remember the intro from Psygnosis' "Brataccas";
it uses nice sound effects, as well as something that might be
described as "ring-modulation". It just shows that more can be
done than most people think on the field of music.
Back on the Commodore 64, some professional musicians started
programming music on it, like Rob Hubbard. They knew how to make
good music and they also knew the principles of programming the
built-in SID soundchip. Other music programmers, like Martin
Galway and Ben Dalglish, also knew what they had to do to make
good music and sound effects on it. I am sure that good
programmers might get almost as much out of the ST's sound chip as
that they did on the SID. The Atari 800 XL is also said to have
used the YM 2149 and I have heard of quite stunning music on those
Some of us already know that the ST system was originally designed
around another sound chip, the "AMY". Instead of the AMY, Atari
decided to build in the YM 2149 and the MIDI interface. Antiware's
digital preprogrammed synthesizer sounds really great when using
MIDI! But more about the AMY; here you will read a part of an
interview with Atari's vice president of research and development,
Shiraz Shivji. It is taken from a brochure of "Personal Computer
World". When you want to get it, together with a software list of
ST programs and lots more, please write to: SILICA Shop Ltd., 1-4
The Mews, Hatherley Road, Sidcup, Kent DA14 4DX, England. This
part of the interview was made by BYTE's Phil Robinson, in
December of last year....
BYTE: What about the sound capabilities?
Shivji: We had a project here started during Alan Kay's tenure - a
chip called AMY. And the ST was designed to have the AMY. But the
AMY did not happen. We had silicon, the first pass, in October or
November, and we had severe problems with it. It was kind of an
orphan project. There were a lot of people that had worked on it.
And if you have a chip that takes six or eight people who have
worked on it at different times, the chances of the chip working
are slim. But it's a good design.
BYTE: What does it do? What's so special about it?
Shivji: The approach of others is that during horizontal refresh
you go out to some place and put some memory out automatically,
and that goes through a DAC (digital to analog converter, RED)and
you have sound. Essentially, you're sampling at 15.75 kHz, which
is the typical frequency. So it's like a digital tape recorder.
You have a digitized sound and you're just putting it out. And it
needs enormous amounts of memory. The key is: how do you encode
sound? Form an information-theoretic point of view, there are two
problems with this approach. One is it's an enormous waste of
memory. Because you could encode whatever sound you're going to
play, as far as data is concerned in a sound piece, the data rate
is extremely low. And doing it in the digital tape recorder way,
you're wasting an awful lot of bandwidth and a lot of memory. The
second problem with other implementations is that you have only 8
bits and it's not really that good. Especially with CD's coming
Amy was a chip that had 16 bits of information coming out. So
you could have 96 decibels of range. What you could hear! Amy was
a complete digital sound chip. It's called an additive-digital
synthesizer. It had an adder and 64 independent oscillators. It
has a model for sound and you feed it the parameters. But if you
do that you have to do an awful lot of preprocessing. We had hired
a lot of people. We had a VAX 780 devoted to it. We had equipment,
fast floating point array processors, and so on, to analyze notes.
We would get a tape of piano playing and then the VAX would
analyze it and would take the Amy model and give the parameters.
To play anything you needed to have parameters tables and feed it
to the chip.
BYTE: Is it still a possibility, then?
Shivji: It is still a possibility. We were going to have the Amy,
and then it didn't happen. Then we said, look, we have a base
machine that's a good machine. Every really doesn't care about
great sound, right? (The ACC thinks Mr. Shivji went terribly
wrong here! RED) So let's not penalize people that don't really
care. Let's put something that will allow people who really care
about sound to be able to play things . That's how the MIDI came
in. And so if you get Amy, we would even have it out as a MIDI-
chip. It's a great chip. Essentially all you do is load it up. Off
line you're doing an analysis of all the different things, and
then you have it in table form. And you can play it any time you
want. And you're not using up the bus that much.
BYTE: If it has that kind of processing capability, it probably
could build models for voice, too.
Shivji: Exactly. We actually could reproduce opera sound. As a
matter of fact, we had a sound lab. The type of sound that you
could hear from that chip was just incredible. Again, 16 bit.
Actually, the chip could even give you 17 bits if you wanted it
to. The problems are it uses too much memory and it hogs the
bandwidth. The bandwidth you could probably get around. However,
that's not the whole thing. You still have to move all that data
around. Of course you don't get the right data at the right place
for free. For example, you have to move it somehow from a disk
BYTE: So the Yamaha chip is there just to give it the basic sound?
Shivji: Yes. Just the basic sounds you need. Though, of course,
the ports are very usefull (the YM 2149 in the ST has two 8 bit
wide data ports, RED).
Mr. Shivji didn't give all the reasons for not using the Amy in
the ST; another reason was the manufacturer of the chip; he simply
couldn't produce it in large enough volume.
According to Data Becker's "ST Intern" (ISBN 3-89011-119-X; Data
Becker GmbH, Merowingerstraße 30, 4000 Düsseldorf, West Germany),
the YM 2149 sound chip is a "soundchip der spitzenklasse", so a
very good soundchip. It is compatible with General Instruments' IC
AY-3-8910, and it's called a PSG, which stands for Programmable
Sound Generator. It has 40 pins. The qualifications of the YM 2149
are (in short) are written on the next page.
- Three independent programmable tone-oscillators
- A programmable noise-genarator
- Complete software-controlled Analog output ports
- Programmable mixer for tones and noises
- Programmable waveforms
- two bi-directional 8 bit dataports
- Simple 5 volts operating conditions
The YM 2149 has 16 registers, whose functions are explained here:
Registers 0 and 1:
These registers determine the frequency of the tone signals
coming from ANALOG A. Not all 16 bits are used; only all 8 bits
of register 0 and the low 4 bits of register 1 are used. With
the bits of register 1 one can determine the note roughly, while
register 0 enables fine tuning. The total 12-bit value of these
registers determines the height of the tone; the lower the
value, the higher the tone.
Registers 2 and 3:
The functions of these registers are the same as those of
registers 0 and 1, but now for channel B.
Registers 3 and 4:
The functions of these registers are the same as those of
registers 0 and 1, but now for channel C.
This registers manipulates the noise generator with its lower 5
bits. Also here: the lower the value, the higher the noise fre-
In this multi-function register, the individual bits determine
Bit 0: Tone from channel A on (0) or off (1)
Bit 1: Tone from channel B on (0) or off (1)
Bit 2: Tone from channel C on (0) or off (1)
Bit 3: Noise for channel A on (0) or off (1)
Bit 4: Noise for channel B on (0) or off (1)
Bit 5: Noise for channel C on (0) or off (1)
Bit 6: Port A is an output (1) or input (0) port
Bit 7: Port B is an output (1) or input (0) port
The lower 4 bits determine the volume of the signal coming from
channel A. Bit 4 has a special meaning. When it set (also, when
it is 1), the volume is determined by the waveform register.
Bits 0 to 3 (also the lower 4 bits) are then ignored.
Just like Register 8, but now for channel B
Just like Register 8, but now for channel C
Registers 11 and 12:
All 16 bits of these registers determine the length of the
waveform. The contents of register 11 are treated as a low
byte, that of register 12 as the high byte.
Bits 0 to 3 (agains the lower 4 bits) of this register are used
to determine the waveform of the waveform-generator as follows:
B3 B2 B1 B0 Waveform:
0 0 - - \__________________
0 1 - - /__________________
1 0 0 0 \\\\\\\\\\\\\\\\\\\
1 0 0 1 \__________________
1 0 1 0 \/\/\/\/\/\/\/\/\/\
1 0 1 1 \------------------
1 1 0 0 ///////////////////
1 1 0 1 /------------------
1 1 1 0 /\/\/\/\/\/\/\/\/\/
1 1 1 1 /__________________
Registers 14 and 15:
These registers belong to the two 8-bit ports. Port A has
register 14, whereas port B has register 15. Is a port
programmed for output (see bits 6 and 7 of register 7), then
the value to be put out can be determined by these registers.
This is the same as they are programmed for input.
So....now we know everything there is to know about the YM 2149
sound chip in the ST systems. But how can the soundchip be
controlled from BASIC (the language most people regularly use)? To
achieve sound in BASIC, it has two commands: SOUND and WAVE. SOUND
isn't really difficult to understand: it needs five parameters to
go with it, seperated by a comma:
SOUND register, volume, note, octave, length
The register can be 1,2 of 3, for channel A,B and C respectively.
The volume is determined by 4 bits, so this value can be between 0
and 15 (15 is the maximal volume). The value for the note can be
between 1 and 12 (I suppose there are 12 notes in each octave),
whereas the value for the octave can be between 1 and 8 (because
the YM 2149 has 8 octaves). The length of the note can be between
0 and 255. "1" stands for 1/50 of a second.
Now the WAVE command....that's more difficult, but not too
difficult if you've read the register-part of this article.
The WAVE command also needs five parameters, seperated by a comma:
WAVE channel, determine, waveform, period length, length
Through the "channel" parameter you can determine which channels
should be on, and to which channels noise should be added. You
must look at this parameter binary; it sets or clears bits 0-5 in
register 7. An example: value 37 (that is binary %100101) does the
following: you have to know that when a bit is cleared in register
7, the actual channel is activated. In the WAVE command, you have
to set the bits to set the channels (and to clear register 7). You
see that bits 0,2 and 5 are set with the value 37. This means that
channels A and C are activated, while noise is added as well to
the latter channel (channel C). Get it? Now, let's go on with the
second parameter. That determines whether the volume is set by
the volume parameter in the SOUND command, or by the waveform in
the WAVE command (that way, the volume differs during the whole
note). So it sets or clears bits 4 of registers 8 to 10. This
parameter also has to be treated as a binary value of three bits -
so the range would be between 0 and 5. Bit 0 of this value is for
channel A, bit 1 for channel B and - of course - bit 2 is for
channel C. If a bit is cleared, the volume of the corresponding
channel is determined by the SOUND command for that channel. When
a bit is set, however, the waveform determines the volume. So a
value of 0 lets all volumes be determined by the SOUND commands.
The third parameter affects register 15 (see the above), to enable
the programmer the choose from 16 waveforms (so the value of this
parameter will be between 0 and 15). Look at these waveforms above
and you will have to experiment a little, too. The fourth
parameter determines the length of a period (vibration) of a
musical note. It can be between 0 and 65535, where you might get
additional frequencies of the value choosen turns out to be
smaller than about 1000. Remember: the shorter the period, the
higher the frequency! The fifth parameter, to close this part of
this article, determines - like the SOUND command - the total
length of the note. I suppose this value can also be between 0 and
We hope to have told you all you need to know for programming
sound on the Atari ST's sound chip. If you think you have made a
terrific piece of music (better than "Temple Trilogy",
"Brataccas", etc.), please let us know. If it's not too big, we
might even publish the source code (or BASIC listing) in a future
issue of ST NEWS....
The text of the articles is identical to the originals like they appeared in old ST NEWS issues. Please take into consideration that the author(s) was (were) a lot younger and less responsible back then. So bad jokes, bad English, youthful arrogance, insults, bravura, over-crediting and tastelessness should be taken with at least a grain of salt. Any contact and/or payment information, as well as deadlines/release dates of any kind should be regarded as outdated. Due to the fact that these pages are not actually contained in an Atari executable here, references to scroll texts, featured demo screens and hidden articles may also be irrelevant.