Making Friends with SID
Author: Paul Higginbottom
The synthesizer chip in your Commodore-64 computer is affectionately known as SID. SID is in fact an acronym for Sound Interface Device. I doubt that many people realize just how powerful this chip is, but I intend to unleash some of its power for you.
If you read some of the documentation for the Commodore-64 about its sound capabilities and are new to synthesizer jargon (as I was), you probably thought to yourself, “I’m never going to figure that out!” Well, l am the sort of person who gets more determined to figure something out when it seems harder than ever to do so.
So, step by step, I, like any beginner, set about learning how to control the SID’s sound capability. The Jargon If your mind is like mine and tends to go blank when confronted with a barrage of alien jargon about something, then hopefully I can gently “break you in” with the terms associated with music synthesis using SID.
The SID chip is comprised of three sections essentially:
1) Oscillator section
2) Envelope section
3) Filter section
There are a few other bits and pieces, but more on those later. SID has three voices. That means to you and me that up to three tones can be played at the same time. Each voice is separately controlled by its frequency (the pitch of the tone), and more importantly, its envelope.
The envelope of a voice, determines how its volume rises, sustains, and falls, like a musical instrument, or other sounds we hear in our lives. For example, a violinist will maybe play a note by pulling the bow across a string slowly at first (the volume starting out low), and as the player starts to increase the speed and pressure of the bow on the string, so the volume increases, and as the player ends the note, he or she slows the rate and pressure of the bow again, and the volume fades away to silence. With a single violinist, the tone may fade away rather abruptly, but I’m sure you’ve heard this rising and falling effect of volume with a piece of orchestration (many string instruments). That is one example of an envelope.
If we consider another example to allow you to grasp different types, think of hitting a cymbal. The rise to its maximum volume is almost instant, as the CRASH or the cymbal begins, and from that point, the sound simply fades away slowly to silence again.
An example of a cymbal type of sound that does rise slowly first and then fade away would be a wave approaching the beach. You hear the slowly increasing volume of the wave moving up the beach, then as the wave trips over itself and hits the beach the loudest part of the noise is heard, and then the sound fades away as the wave slides up the beach, and the next one approaches again.
Well, enough of the examples, back to the technical stuff. This “behaviour” of the volume (or amplitude) of a voice, can be defined in 4 parts, and this terminology is common amongst professional synthesizers costing many times the prices of your Commodore-64 computer!
The Four Parts of an Envelope
You may have noticed by now, that to define this changing in volume, we simply need to define the TIME it takes for a sound to go from one volume, to get to another volume.
For example, the violin might have taken half a second to go from no volume (silence) to its maximum volume, and then 2 seconds to fade away again (silence again) The cymbal took no time to reach its maximum volume (starts with the CRASH), but 10 seconds to fade away. The wave is different again, in that it might take 5 or so seconds to build up to maximum volume (as it moves up the beach), and then only 1 second to die away (as the wave falls over and crashes on the beach).
Part 1 – ATTACK – This is the time taken to go from silence (0 volume) to the maximum volume SID is set to.
Part 2 – DECAY – This is the time taken to go from the maximum volume SID is set to, to a given “mid-point” volume, or, sustained level of volume.
Part 3 – SUSTAIN – This is not a time value, but is a level of volume the voice sustains at after the ATTACK and DECAY.
Part 4 – RELEASE – This is the time taken to go from the sustained volume to silence once again. In those definitions, I mentioned “the maximum volume SID is set to”, and that is the maximum overall volume (just like the overall volume control on your television or stereo)
How We Control SID
Before I go any further, I want to explain how we actually tell SID exactly what weird and wonderful sounds we want it to make (so we can drive everyone crazy!)
The SID chip has an amount of memory in it, and simply by putting numbers into those memories, we give SID all the information it needs to produce an infinite number of sounds.
We put numbers into memories with the BASIC command “POKE”. We give the POKE command two numbers; the memory number (or “address”), and the number we want to put into that memory (one memory location can hold any whole number between 0 and 255).
SIDs address is quite a big number. He starts at 54272, and he occupies that memory location and the next 28 also, up to 54300.
I want to show that it really is not that difficult to train SID, and that you don’t have to be a genius at programming.
Making your First Beep
To make a noise, we must do 4 things:
1) Set the maximum overall volume
2) Set the envelope of the voice we wish to use
3) Set the frequency of the voice to the desired pitch 4)
And only then “tell” SID to do it.
I put quotes around “tell” in part 4 because I want to examine that closer.
When we tell SID to make a sound, we tell it to firstly do the ATTACK (rise up to maximum volume) and then the DECAY (go down) to a SUSTAINed level of volume. When we tell SID to do that part, the noise will stay at the SUSTAINed level of volume forever if you don’t tell it to go on, and do the last part: the RELEASE (go down from the sustained level of volume, to nothing).
So to recap, we tell SID to do the ATTACK-DECAY-SUSTAIN part first, and then when we’re ready, we tell it to finish the envelope with the RELEASE part.
You could get a person to demonstrate this for you. Ask them to take a DEEP breath when you tap them on the shoulder and then hum a note at first quietly building up to a loud level, and the going down to a comfortable level. You have made a person do the Attack-Decay-Sustain part of an envelope. I said the sound will continue indefinitely if you don’t tell it to release, so when you tap the person again on the shoulder, they can slowly quieten their hum down to nothing. Of course if you decide to make them sustain for two long, they’ll go blue in the face, and pass out! (Also, you may want them to stop before they get to the release, because their hum is so obnoxious! (Fortunately, you can also do this with the Commodore-64!)
For now, let’s just concentrate on ONE voice. Each voice has 7 memories inside SID, to control it. Voice 1’s memories are in fact, the first 7 memories; voice 2, the second 7, and voice 3, the next 7. That, If you’ve been doing your math, is the first 21 memories in SID. The other 8 (there are 29 in all) are for the filter section which I haven’t talked about yet, and other bits and pieces, inc
luding the overall volume control which I have mentioned).
The 7 memories for each voice are all organized the same way, for example, the first two of each block of 7, control the frequency (pitch) or the voice.
The 7 Memories for a Voice
The first two as I just mentioned, control the frequency of the voice, that is, the pitch of the sound. The second two are to control one particular type of sound, which will be covered later The fifth memory is the controlling memory or the voice, the one which will tell SID to start the note, stop it, and choose the type of sound. The sixth memory controls the duration of the Attack and Decay. The seventh memory controls the Sustain level, and the Release time. The fifth of the seven I just described, I now explain further.
I mentioned there that apart from telling to play the envelope, it also controls the type of sound. (Another piece of jargon coming up!) The type of sound is known as the Waveform. You are probably aware that sound is comprised of air being compressed and stretched. By, for example, a speaker cone, which moves in and out, and the speed (the FREQUENCY) at which it moves in and out, determines the pitch. The way in which air is compressed and stretched is cyclic (repeats itself), and this cycle is known as the waveform.
The Waveforms
SID allows you to choose from one of four waveforms, and it is the fifth of the seven memories in each voice, which you set to tell SID which waveform you wish to use.
Triangular (shaped like this: ) This waveform, due its smoothness produces a mellow, soft flute-like sound (very pleasant to the ear!)
Sawtooth (shaped like this: ) This waveform, due to its abrupt ending produces a brighter, brass-like sound.
Variable width pulse (shaped anything from this: , to this , or this: . [which if you look is simply the first one upside-down]) This waveform as you can see from the description in parentheses can be varied, but is essentially an ON and OFF waveform, and as such is very abrupt and produces anything from a hollow, organ-like sound, to a very quiet, reedy sound.
As you can see from the symbols of this waveform, it is comprised of pulse, or varying widths (hence the name), and memories 2 and 3 which I mentioned earlier were for a specific type of sound, do in fact control the width of the pulse when this waveform is chosen. Of course, memories 2 and 3 have no effect when any other waveform is selected.
Noise – I won’t try to do a little drawing of this waveform, since it is in fact a RANDOM waveform, and has no defined harmonic qualities, but because the frequency can be altered, will produce any sound from a hiss (like you hear from poor quality cassette recorders), to a low rumble (good for special effects in games). Please note the format of the memory locations used. I mentioned that the first TWO bytes are used to select the frequency, but did not say how one would know what values to put in one and the other.
The easiest way to look at it, I would expect would be thus: Since one memory location can only contain a number from 0 to 255, to represent larger numbers, they are stored as 0 to 255 in the first byte (known as the low byte), and multiples of 256 added to this in the second byte (known as the high byte}, which means two bytes can hold a number from 0 (0 in both locations) to 65535 (255 in the first one, plus 255 times 256 in the second one). The ATTACK-DECAY memory and the SUSTAIN-RELEASE memory are comprised as follows.
The ATTACK, DECAY, SUSTAIN, RELEASE parameters can all be one of 0 to 15. To form the ATTACK-DECAY value for memory location 6 in a voices 7 memory locations, simply multiply the ATTACK by 16 and add the DECAY value. This again gives a combined value from 0 (0*16 + 0) to 255 (15*16+ 15). The control register works differently still. The value is calculated as follows: Add 1 to begin Attack-Decay-Sustain cycle; don’t add 1 to begin the Release cycle. Add 16 to select triangular wave form, 32 for sawtooth, 64 for variable width pulse, or 128 for noise waveform. There are other parts to add to this value, but they won’t be covered here.
The Beep Program Turn on your Commodore 64, and type in the following program:
10 sid=54272
20 for i = 0 to 28 : poke sid + i, 0 : next
30 poke sid + 24, 15
40 poke sid + 1, 20
50 poke sid + 5, 0*16+0
60 poke sid + 6, 15*16+9
70 poke sid + 4, 1 + 16
80 poke sid + 4, 16
Description of the Program
Line 10 defines a variable SID, to the start of SID’s memory locations. Line 20 should be included in all of your sound programs. A FOR..NEXT loop to simply set all of SID’s memory locations to 0 to ensure that no previous programs will affect our efforts.
Line 30 sets memory location 24 in SID, to 15. Register 24 controls the overall volume of SID (and some other things which need not be known here), and 15 is the maximum volume (from 0 to 15).
Line 40 sets the upper byte of the frequency value of voice 1 to 20, which means a setting of 0 + 20*256 = 5120.
Line 50 sets the ATTACK value of voice 1 to 0, and the DECAY value also to 0, which means when we tell SID to do its ATTACK-DECAY-SUSTAIN cycle, it will simply go straight to the SUSTAIN volume, since we’ve told it not to do any ATTACK or DECAY at all.
Line 60 sets the SUSTAIN value of voice 1 to 15 (maximum volume), and the RELEASE value also to 9, which means when we tell SID to do its RELEASE cycle, it will take about three quarters of a second to fade away to nothing.
Line 70 sets the control register of voice 1 to do the Attack-Decay-Sustain sequence, with the triangular wave-form selected (+ 16).
Line 80 sets the control register of voice 1 to do the Release part of the envelope, again with the triangular waveform selected (+ 16).
Having typed in this program, type: RUN And the familiar: READY [] Message will come back almost immediately, with the mellow sound fading away (provided you have the volume control on your television set up reasonably high so you can hear it!)
Well, there’s a LOT of new things for you to absorb in this article before we can go on to further things. We’ve only done a PING so far, but we’ll have SID playing Bach soon enough (or maybe a little Genesis?)
“This article was first published on The Transactor volume 4 issue 02 (January 1983) by Paul Higginbottom. I recently found him and asked for permission to reproduce this article here, and he was very kind to give it. After reading tons of texts about SID, his article was the first that actually I could understand, so I really wanted to share here. Paul Higginbottom can be found on his blog (higginbottom.com) and, since 2005 he has been creating websites and other media, and providing professional technology consulting to individuals, businesses and other organizations across the world through his company Reora, Inc. “
Thanks for re-publishing my article, and hope your readers enjoy it.