THE WIZARDS PART III - PROFESSIONAL SOUND PROGRAMMING
by Erik and Jochen of TEX
Finally, now the time has arrived for which all you computer
freaks have been waiting such an incredibly long time: The third
part of the amazing series in which the hacking group "The
Exceptions" explains all about their programming tricks. This
time: Professional music programming on the ST, together with
some amazing SOURCE stuff for a really good synthesizer!!! Many
thanks need to go to Mr. Tarik Ahmia of 68000'er/ST Magazin for
giving his permission for us to use these articles in ST NEWS.
This time, there's a special bonus for those among you that
uptil now always doubted the simple musical capabilities of the
ST: An exclusive music routine for ST NEWS that you can use in
your own programs and that is supplied with several special
You know the recipe: First I, Erik, will talk a bit with you
about the background story of TEX, and then the specialist,
Jochen, will tell you how it is possible to get decent music from
That this is very difficult, nobody knows better than Jochen
himself. Our second demo (LSD, Little Sound Demo; we talked about
that in ST NEWS Volume 3 issue 6) was barely ready when he
already started improving his synthesizer routine. Heated up by
real 'sound orgies', that were especially celebrated by the
English music programmer Rob Hubbard on the Commodore 64, 'Mad
Max' eagerly sought to get similar effects from the prehistoric
soundchip of the ST. Some things have to be said in advance:
When looked at objectively, our ST surely has the worst
soundchip of all current home computers (exceptions later). The
Commodore 64 as well as the Amiga are way ahead. But, immodest as
it may sound, Jochen doesn't allow hardware limitations to
impress him much, just like the rest of our strange group. Soon,
my old C-64 moved to our music freak more and more often, to
assist him with reference during the conversion of Rob Hubbard's
game music; since we had received some positive reactions to our
demos, the motivation grew to make a third program of this kind
to put all previous once in the shade. Whilst my nothingness
started making a small portrait of the mentioned Rob Hubbard, and
Udo was busy working out some new ideas for new effects, Jochen
didn't do nothing either. Perhaps, the way in which music was
converted from the 64 to the ST might be interested for some of
you. At the time of the creation of our third demo, this was
still very tiring. Jochen knew how to read Hubbard's C-64 note
format like other people read comics, but the whole thing had to
be typed and converted in the head to Jochen's note format, and
then typed into the ST. Next, he had to try to make the sounds
arising from the 'bread toaster' sound as much like the 64 as
possible, with the modest capabilities of the Yamaha soundchip.
That's how 8 pieces of music were developed that were
desperately looking for some competition back then. Further, the
creation of the third demo was quite the same as that of the
other two. We worked for weeks and then, on one night and the
morning after that, we mashed the whole thing together to the
best TEX-Demo then existing. Except for the good sound, there
were two astounding things to note in the new demo: A 'Three-
channel-LED-VU-metre display' and a scroll line that displayed
dozens of colors (thus giving the third demo its name: 'LCD' or
'Little Color Demo'). After that, there was peace and tranquility
for some time. Like people can still read in the 'LCD', we didn't
want to produce any demos for a while (boy, were we naive!),
mainly because Udo and myself were working some time already on a
commercial program - a game, of course. At the moment that you
read these lines, it will still probably not be for sale
anywhere. Nobody is surpised by that, and we in the least,
because we couldn't resist to throw away our time making more
demos of course.
First, it was impossible to resist the temptation of making a
slideshow for Neochrome pictures, as a friend of ours from
Mannheim (working under the pseudonym ALYSSA) had discovered how
it is possible to display graphics in the lower border of the ST.
Next, Udo succeeded in displaying complete pictures, scrolling in
the lower border, setting rasters, playing music with digital
sound effects and loading pictures with the operating system -
all simultaneously! But more about that in a later article.
Now, we are interested in music, and everybody who knows our
demos should now immediately think of our 'B.I.G. Demo', since it
contains 127 different pieces of music. The one that this time
started it all was our good friend Richard Karsmakers from
Holland, now ex-editor (but special correspondent) of just about
the best disk magazine for the Atari, ST NEWS (thanks, guys!
ED.). After he had convinced us (or, rather, Jochen) to supply
his disk magazine with background music, he started bombarding us
with plans for a demo that should put everything else that had
then been finished in the shade! He plainly stated that it would
be very nice for a demo to contain ALL the musical compositions
ever made by the music programmer that he (and we) admired: Rob
Hubbard! Before we, others, only had the chance to breathe, 'Mad
Max' had already agreed. He had surely not done that if we had
not made an interesting tool. Because while I was soldering a
cable for data transfer from 64 to ST, Udo had programmed a bit
on both computers so that the whole RAM memory of the 64 could be
stuffed into the upper part of the ST's RAM. The tedious typing
that Jochen had to do was now definite history, and what else
could he do then to write a conversion routine to convert
Hubbard's note format directly to his? Some work is still left
then, however, since not everything can be translated, and the
seperate voices have to be manually adjusted - still today. But
this data transfer cable was the condition needed to start with
something crazy like the 'B.I.G. Demo' in the first place.
Additionally, TEX had gained some powerful support by means of
Michael (Daryl) and Gunter (6719). The production time of this
project was, just allow me to use an eufemism, long.
Over three months we worked, more or less intensively, on our
5th demo, and in the end it turned out that we had all put more
work in it than we had wanted to and than that was good for our
game. The program-technical and graphical tricks that we used in
this program will be revealed some other time. With regard to the
sound and music, the endless list of musical compositions wasn't
enough to satisfy us. In the 'B.I.G.-Demo', there was a world
premier of one of Jochen's new programs: The digital sound
synthesizer! It could do nothing less than creating musical notes
through the same principle that the Amiga soundchip uses to
But one thing after the other. Let's first talk about Jochen's
'normal' synthesizer program, and how it creates music with the
built-in soundchip. This soundchip was developed by Yamaha and
listens to the name 'YM 2149'. At the time it was introduced, it
was a blessing for all Coin-up producers and was now able to
supply the newest arcade games with sounds never heard before. We
hereby mean current arcade hits like Pac-Man, Asteroids and other
oldies that we now think back about with tears of emotion. Tears
of sadness, however, can be seen in one's eyes when one discovers
that this ancient technical piece is again found in one of the
hottest home computers at the end of the eighties. Probably, Jack
Tramiel's developers treated the YM like a port chip anyway, that
accidentally had some music generating circuits attached to it.
Yeah, all right, I will stop this now. It just had to be said
once. The technical data of the chip speaks for itself: The
mentioned ports, two in number, switched as in-and output ports,
take over data exchange with the disk drive and the printer. For
the creation of music, they don't do much, as you will
The following specifications can be set for any of the three
sound channels still left:
1. Volume. Can be specified from 0-15.
2. Frequency. Selectable from 30 - 150.000 Herz (?)
3. ADSR tables. One of 10 pre-defined ADSR types selectable.
The waveform specifies how a tone handles its Attack, Decay,
Sustain and Release, so that one often talks about an ADSR-
waveform. A piano, for example, has a rapid attack, doesn't keep
the tone going for long and takes a long time to disappear. This
is almost everything one needs to say about these tables, since
the sounds produced by these tables don't sound all too well, and
are almost all equal as well.
The YM-2149 knows only one true waveform, which is the
rectangular waveform. Additionally, one (and the same) noise
generator can be added to the voices. That's about it. Really,
there isn't any more!
To illustrate that it really isn't much, we will have a brief
look at the SID, the soundchip of the C-64. It also has just
three voices, that all have to share the same volume register.
Additionally, it has:
1. Four different ADSR tables (rectangle, triangle, sawtooth
2. With rectangle: Variable puls width (relation of the
negative and the positive wave parts)
3. Ring modulation (a second voice can be modulated by the
frequency of another)
4. Selectable high-and low pass filters
5. Limitless specifiable waveforms
All these features can be specified for each individual voice.
This assures that a more widely varied sound pattern can be
created - and just think that this C-64 computer exists since
You might now perhaps wonder why a regular ST freak talks so
badly about his machine's musical capabilities. The reason for
this is the fact that we find that it should be common knowledge
that the ST hasn't particularly been supplied with superb stuff
with regard to sound production. When you often read, in reviews
of music programs or games, that the "sound is almost never worse
than on the C-64", this proves that mankind and particularly the
software reviewers (no, not you, Boris!) do not have much
knowledge of the above said. It is especially irritating when a
programmer takes much trouble to get better sound from the ST and
that this is recognized nowhere (I am hereby thinking e.g. of
"Sapiens", a French program with good, three-voice digital music
in the background). Enough smalltalk. Since there are, like you
surely must have heard or noticed, methods to create something
better than obnoxious bleeping on the YM-2149. As usual, the
software has to do the work here. So let's look at the principal
operation of a synthesizer routine.
First, the program should run on the background, 'on interrupt',
so that the music can be played simultaneously with the program
(of which the music in ST NEWS is an excellent example). This
also has the advantage that the sound processing routines are
executed regularly. In the ST, the 200Hz timers can be used for
this, or, like with our program, the VBL (Vertical Blank
Interrupt); this one is executed 50 (or 60) times per second (70
times in monochrome mode, ED.). Principally, such a program
doesn't do much more than getting notes and note lengths from a
table and writing this (converted through a frequency list) to
the soundchip. Since the routine is executed regularly, it is
also possible to change the soundchip data regularly - this
creates the effects that can normally not be done by the
soundchip itself. In the synthesizer routine that is added on
this ST NEWS disk, the following effects are built in:
1. Frequency modulation. By regularly changing the current
frequency a bit, a new sound pattern is created. One could
describe this as 'pingling' (sorry for the word, folks!
German is 'klingeln')
2. Vibrato. This seperately mentioned way of frequency
modulation causes the note to 'float'.
3. Custom ADSR-waveforms. What one doesn't have, one has to
program! Working through a table of soundchip volume values,
the ADSR of a note can be specified.
All these manipulation possibilities together bring a remarkable
effect from your speaker; just listen to the small demo song that
is added at the end of the listing on the disk. Before Jochen
will start explaining all there is to know about working with his
program, I will talk briefly about the operation principles of
the 'digital synthesizer' I mentioned earlier.
This miracle of programming art (cough cough) gives the ST
similar sound capabilities than the Amiga, but it costs of lot of
processor time. In memory, just a single digitized sound of any
instrument is needed, and the software can play that on various
lengths or frequencies. Up to four of these voices are then mixed
together and played through the soundchip. Only the volume
register, that is misused as Analog-Digital converter, is applied
here. The whole thing still runs 'on interrupt', but one has to
know that this method of creating sound costs about 70-80% of the
total available processor time. How it functions precisely, will
for a time remain our secret - we don't want to give away all the
cookies! Instead of that, I will now give the keyboard to Jochen,
who will now talk about the principles of his listing.
Greetings to all you music freaks! This is Jochen on the
keyboard. In the next piece, you will be able to read everything
about how to use the assembler source that is added on the ST
NEWS disk (in the folder "PROGRAMS"; it is called something like
SYN68000.S). I am afraid you have to type in all notes and
effects directly in the assembler, as I didn't have the time to
write a user interface for this synthesizer. By the way, I do it
manually with my 'big' synthesizer programs as well, that I use
for our demos and for commercial pieces of music. All songs are
directly edited in the assembler. So here we'll go...
USER MANUAL for the 68000 synthesizer (by Mad Max from TEX)
This program should only be used by people that have experience
with programming in assembler.
The synthesizer commands and their syntax:
Three pointers to the sequence tables.
The sequence tables:
Every voice can create seperate sequences after each other, just
like in a string. Each time, they have to be ended with the byte
$FF. The numbers specify the numbers of the sequences meant.
However, when the seventh bit is set, then a 'transpose' byte is
meant. The lower 6 bytes then specify the height.
Example: $8C <------ The voice is transposed with $C half tone
^ steps up
bit 7 set...
These pointers point to their own sequences.
The sequences; the actual note input
Every note starts with a signal byte of which every bit takes
over a function.
Is the signal byte $FF, than the sequence ends here.
Bit 0 to 4 specify the note length -1 (0 to 31) and are
always before a note.
A whole note is 32-1, so that would be 31 ($1F)
A half note is 16-1, so that would be 15 ($0F)
When bit number 5 is also set, this note will be attached
to the previous one.
Syntax : Signal byte, Note
or : Signal byte, Waveform number, Note
When bit 6 is set, the program knows that this is a pause.
The syntax of pause is: Signal byte.....
When bit 7 is set, the progrmam expects the number of the
Syntax : Signal byte, Waveform number, note
Every note has a number between $0C (12) and $6C (108).
The program counts in half-note steps...
$0c is a deep C
$0d is a C#
$0e is a D
$0f is a D#
$10 is an E
$11 is an F
$30 is a C''
Example for a sequence
At the start of each sequence, one should select the waveform
anew, or else the old one will be used.
Let's look at the first note...
In the signal byte, bit 7 is set, i.e. a waveform number must be
specified (in our small example, this is $00). The lower five
bits form number $07, i.e. a quarter note ($08-1).
Then, the note always follows. $18 means a C'.
The next signal byte is again $07, so yet another quarter note...
This continues several times until the $FF byte - the sequence
The Arpeggio tables:
Arpeggio's are rapidly following note heights, that have to be
set in this table (with Arpeggio's, it is possible to simulate
An Arpeggio exists of a number of note steps, that are called
after each other. Every Arpeggio step function just like the
same principle as Transpose (see Transpose). If one would want
to simulate a Dur-chord, for example, the numbers should look
$0c $07 $04 $00
This is like you're playing a chord with four fingers. For
example C-moll: First finger C' ($0C)
Second finger G ($07)
Third finger E ($04)
Fourth finger C ($00)
How you use Arpaggio tables in the program, I will explain with
1. Next, you have to put a pointer to the Arpeggio table so that
the program knows where the table is in memory. This, you
have to do with the 'Arpeggiotab' label.
2. You have to set the speed at which the table should be
3. Type the table after each other in the listing.
4. End the table with the byte $FF.
dc.b $01,$0c,$07,$04,$00,$ff ---> End mark $ff
^ ---------Our Dur-Table
maximal speed (1 -> fast 3... -> slow)
The specification number can be calculated by the position it
has in the list, minus one (in our example on the fifth
position, so 5-1 is 4!).
This specification number will have to put in the 'wavetab'
The waveform tables
They are built up much like the Arpeggio tables.
wavetab: dc.l pointer on the wave tables....
1st Byte - > The Arpeggio specification
2st Byte - > The speed with which the
waveforms should be
3rd Byte - > Vibrato speed
(1 = fast,100 = slow)
4th Byte - > Vibrato-strength
(1 = weak,100 = strong)
From now on, the ADSR waveforms follows,
according to the volume registers of the
This table also end with the byte $FF.
So far everything's alright. I hope it can be understood. Have
fun with trying and experimenting!
So that's yet another part of "The Wizards", dear readers. Next
time, we will not spoil the ear, but the eye: Graphical tips and
tricks can be expected. 'Till then, bye!
A last note for those among you who do not know much of working
After having loaded the SEKA assembler, you can load the source
by typing 'R' (return), and then the file name (followed by
return). Then, you type 'A' (followed twice by return). Now, you
must switch to supervisor mode. This can be done by typing 'XSR'
(return) and '$2300' (return). Now, you can start the program by
typing 'G' (followed twice by return). You will then hear the
If you have questions or stuff like that for The Exceptions,
please write to:
D-6702 Bad Dürkheim
Don't forget to add an International Reply Coupon (or several,
depending on the weight of your package).