Software Stuff

SID CONTROL REGISTERS

There are 29 eight-bit registers in SID which control the generation of sound. These registers are either WRITE-only or READ-only and are listed below in Table 1.

Table 1. SID Register Map

REG #	DATA                                           REG NAME TYPE
(Hex)	d7    d6    d5    d4    d3    d2    d1    d0
- --------------------------------------------------------------------

Voice 1:

00     F7    F6    F5    F4    F3    F2    F1    F0    FREQ LO  Write
01     F15   F14   F13   F12   F11   F10   F9    F8    FREQ HI  Write
02     PW7   PW6   PW5   PW4   PW3   PW2   PW1   PW0   PW LO	Write
03     -     -     -     -     PW11  PW10  PW9   PW8   PW HI    Write
04     Noise Pulse ///   /\/\  TEST  RING  SYNC  GATE  CONTROL  Write
05     ATK3  ATK2  ATK1  ATK0  DCY3  DCY2  DCY1  DCY0  ATK/DCY	Write
06     STN3  STN2  STN1  STN0  RLS3  RLS2  RLS1  RLS0  STN/RLS  Write

Voice 2:

07     F7    F6    F5    F4    F3    F2    F1    F0    FREQ LO  Write
08     F15   F14   F13   F12   F11   F10   F9    F8    FREQ HI  Write
09     PW7   PW6   PW5   PW4   PW3   PW2   PW1   PW0   PW LO	Write
0A     -     -     -     -     PW11  PW10  PW9   PW8   PW HI    Write
0B     Noise Pulse ///   /\/\  TEST  RING  SYNC  GATE  CONTROL  Write
0C     ATK3  ATK2  ATK1  ATK0  DCY3  DCY2  DCY1  DCY0  ATK/DCY	Write
0D     STN3  STN2  STN1  STN0  RLS3  RLS2  RLS1  RLS0  STN/RLS  Write

Voice 3:

0E     F7    F6    F5    F4    F3    F2    F1    F0    FREQ LO  Write
0F     F15   F14   F13   F12   F11   F10   F9    F8    FREQ HI  Write
10     PW7   PW6   PW5   PW4   PW3   PW2   PW1   PW0   PW LO	Write
11     -     -     -     -     PW11  PW10  PW9   PW8   PW HI    Write
12     Noise Pulse ///   /\/\  TEST  RING  SYNC  GATE  CONTROL  Write
13     ATK3  ATK2  ATK1  ATK0  DCY3  DCY2  DCY1  DCY0  ATK/DCY	Write
14     STN3  STN2  STN1  STN0  RLS3  RLS2  RLS1  RLS0  STN/RLS  Write

Filter:

15     -     -     -     -     -     FC2   FC1   FC0   FC LO	Write
16     FC10  FC9   FC8   FC7   FC6   FC5   FC4   FC3   FC HI    Write
17     RES3  RES2  RES1  RES0  FILEX FILT3 FILT2 FILT1 RES/FILT Write
18     3 OFF HP    BP    LP    VOL3  VOL2  VOL1  VOL0  MODE/VOL Write

Misc.:

19     PX7   PX6   PX5   PX4   PX3   PX2   PX1   PX0   POT X    Read
1A     PY7   PY6   PY5   PY4   PY3   PY2   PY1   PY0   POT Y    Read
1B     O7    O6    O5    O4    O3    O2    O1    O0    OSC3/RND Read
1C     E7    E6    E5    E4    E3    E2    E1    E0    ENV3     Read

VOICE 1

 
FREQ LO/FREQ HI (Registers 00,01)
 

Together these registers form a 16-bit number which linearly controls the frequncy of Osscillator 1. The frequency is determined by the following equation:

Fout = (Fn * Fclk / 16777216) Hz

Where Fn is the 16-bit number in the frequency registers and Fclk is the system clock applied to the Phi2 input (pin 6). For a standard 1.0 MHz clock, the frequency is given by:

Fout = (Fn * 0.059604645) Hz

It should be noted that the frequency resolution of SID is sufficient for any tuning scale and allows sweeping from note to note (portamento) with no dicernable frequency steps.

 
PW LO/PW HI (Registers 02,03)
 

Together these registers form a 12-bit number (bits 4-7 of PW HI are not used) which linearly controls the pulse width (duty cycle) of the pulse waveform on Oscillator 1. The pulse width is determined by the following equation:

PWout = (PWn/40.95) %

Where PWn is the 12-bit number in the Pulse Width registers. The pulse width resolution allows the width to be smoothly swept with no discernable stepping. Note that the pulse waveform on Oscillator 1 must be selected in order for the pulse width registers to have any audible effect. A value of 0 or 4095 ($FFF) in the pulse width registers will poroduce a constant DC output, while a value of 2048 ($800) will produce a square wave. [A value of 4095 will not produce a constant DC output].

 
CONTROL REGISTER (Register 04)
 

This register contains eight control bits which select various options on Oscillator 1.

One of the output waveforms must be selected for oscillator 1 to be audible, however it is NOT nescessary to de-select waveforms to silence the output of voice 1. The amplitude of voice 1 at the final output is a function of the envelope generator only.

NOTE: The oscillator output waveforms are NOT additive. If more than one output waveform is selected simultaneously, the result will be a logical ANDing of the waveforms. [Transcriber's note: This is most probably wrong. Some claim that it is the "min" function that is used, but my experience is that it is more complex than that].

Although this technique can be used to generate additional waveforms beyond the four listed above, it must be used with care. If any other waveform is selected while noise is on, the noise output can "lock up". If this occurs, the noise output will remain silent until reset by the TEST bit or by bringing RES (pin 5) low.

 
ATTACK/DECAY (Register 05)
 

Bits 4-7 of this registers (ATK0-ATK3) select 1 of 16 ATTACK rates for the voice 1 envelope generator. The ATTACK rate determines how rapidly the output of voice 1 rises from zero to peak amplitude when the envelope generator is gated. The 16 ATTACK rates are listed in Table 2.

Bits 0-3 (DCY0-DCY3) select 1 of 16 DECAY rates for the envelope generator. The DECAY cycle follows the ATTACK cycle and the DECAY rate determines how rapidly the output falls from the peak amplitude to the selected SUSTAIN level. The 26 DECAY rates are listed in Table 2.

 
SUSTAIN/RELEASE (Register 06)
 

Bits 4-7 of this register (STN0-STN3) select 1 of 16 SUSTAIN levels for the envelope generator. The SUSTAIN cycle follows the DECAY cycle and the output of voice 1 will remain at the selected SUSTAIN amplitude as long as the gate bit remains set. The SUSTAIN levels range form zero to peak amplitude in 16 linear steps, with a SUSTAIN value of 0 selecting zero amplitude and a SUSTAIN value of 15 ($F) selecting the peak amplitude. A SUSTAIN value of 8 would cause voice 1 to SUSTAIN at an amplitude one-half the peak amplitude reached by the ATTACK cycle.

Bits 0-3 (RLS0-RLS3) select 1 of 16 RELEASE rates for the envelope generator. The RELEASE cycle follows the SUSTAIN cycle when the gate bit is reset to zero. At this time, the output of voice 1 will fall from the SUSTAIN amplitude to zero amplitude at the selected RELEASE rate. The 16 RELEASE rates are identical to the DECAY rates.

NOTE: The cycling of the envelope generator can be altered at any point via the gate bit. The envelope generator can be gated and released without restriction. For example, if the gate bit is reset before the envelope has finished the ATTACK cycle, the RELEASE cycles will immediately begin, starting from whatever amplitude had been reached. If the envelope is then gated again (before the RELEASE cycle has reached zero amplitude), another ATTACK cycle will begin, starting from whatever amplitude had been reached. This technique can be used to generate complex amplitude envelopes via real-time software control.

Table 2. Envelope Rates

VALUE  	ATTACK RATE	DECAY/RELEASE RATE
	Time/Cycle	Time/Cycle
- ------------------------------------------
 0	  2 ms		  6 ms
 1	  8 ms		 24 ms
 2	 16 ms		 48 ms
 3	 24 ms		 72 ms
 4	 38 ms		114 ms
 5	 56 ms		168 ms
 6	 68 ms		204 ms
 7	 80 ms		240 ms
 8	100 ms		300 ms
 9	240 ms		750 ms
10	500 ms		1.5 s
11	800 ms		2.4 s
12	  1 s		  3 s
13	  3 s		  9 s
14	  5 s		 15 s
15	  8 s		 24 s

Picture 3. 6581 Envelope

6581 Envelope

NOTE: Envelope rates are based on a 1.0 MHz ø2 clock. For other ø2 frequencies, multiply the given rate by 1 MHz/ø2. The rates refer to the amount of time per cycle. For example, given an ATTACK value of 2, the ATTACK cycle would take 16 ms to rise from zero to peak amplitude. The DECAY/RELEASE rates refer to the amount of time theses cycles would take to fall from peak amplitude to zero.

VOICE 2

Registers $07-$0D control voice 2 and are functionally identical to registers $00-$06 with these exceptions:

  1. When selected, SYNC synchronizes oscillator 2 with oscillator 1.
  2. When selected, RING MOD replaces the triangle output of oscillator 2 with the ring modulated combinations of oscillators 2 and 1.

VOICE 3

Registers $0E-$14 control voice 3 and are functionally identical to registers $00-$06 with these exceptions:

  1. When selected, SYNC synchronizes oscillator 3 with oscillator 2.
  2. When selected, RING MOD replaces the triangle output of oscillator 3 with the ring modulated combinations of oscillators 3 and 2.

Typical operation of a voice consists of selecting the desired parameters: frequency, effects (SYNC, RING MOD) and envelope rates, then gating the voice whenever the sound is desired. The sound can be sustained for any length of time and terminated by clearing the gate bit. Each voice can be used separately, with independent parameters and gating, or in unison to create a single, powerful voice. When used in unison, a slight detuning of each oscillator or tuning to musical intervals creates a rich, animated sound.

FILTER

 
FC LO/FC HI (Reigster $15, $16)
 

Together these registers form an 11-bit number (bits 3-7 of FC LO are not used) which linearly controls the cutoff (or center) frequency of the programmable filter. The approximate cutoff frequency ranges from 30 Hz to 12 KHz.

 
RES/FILT (Register $17)
 

Bits 4-7 of this register (RES0-RES3) control the resonance of the filter. Resonance is a peaking effect which emphasizes frequency components at the cutoff frequency of the filter, causing a sharper sound. There are 16 resonance settings ranging linearly from no resonance (0) to maximum resonance (15 or $F).

Bits 0-3 determine which signals will be routed through the Filter:

 
MODE/VOL (Register $18)
 

Bits 4-7 of this register select various filter mode and output options:

NOTE: The filter output modes ARE additive and multiple filter modes may be selected simultaneously. For example, both LP and HP modes can be selected to produce a notch (or band reject) filter response. In order for the filter to have any audible effect, at least one filter output must be selected and at least one voice must be routed through the filter. The filter is, perhaps, the most important element in SID as it allows the generation of complex tone colors via subtractive synthesis (the filter is used to eliminate specific frequency componenets from a harmonically rich input signal). The best results are achieved by varying the cutoff frequency in real-time.

Bits 0-3 (VOL0-VOL3) select 1 of 16 overall volume levels for the final composite audio output. The output volume levels range from no output (0) to maximum volume (15 or $F) in 16 linear steps. This control can be used as a static volume control for balancing levels in multi-chip systems or for creating dynamic volume effects, such as tremolo. Some volume level other than zero must be selected in order for SID to produce any sound.

MISCELLANEOUS

 
POTX (Register $19)
 

This register allows the microprocessor to read the position of the potentiometer tied to POTX (pin 24), with values ranging from 0 at minimum resistance, to 255 ($FF) at maximum resistance. See the Pin Description section for information on pot and capacitor values.[This register is supposed to be updated every 512 cycles].

 
POTY (Register $1A)
 

Same as POTX for the pot tied to POTY (pin 23).

 
OSC 3/RANDOM (Register $1B)
 

This register allows the microprocessor to read the upper 8 output bits of oscillator 3. The character of the numbers generated is directly related to the waveform selected. If the sawtooth waveform of oscillator 3 is selected, this register will present a series of numbers incrementing from 0 to 255 ($FF) at a rate detmined by the frequency of oscillator 3. If the triangle waveform is selected, the output will increment from 0 up to 255, then decrement down to 0. [Transcriber's note: This is 0,1,..,254,255,255,254,..1,0,0,1..]

If the pulse waveform is selected, the output will jump between 0 and 255. Selecting the noise waveform will produce a series of random numbers, therefore, this register can be used as a random number generator for games. There are numerous timing and sequencing applications for the OSC 3 register, however, the chief function is probably that of a modulation generator. The numbers generated by this register can be added, via software, to the oscillator or filter frequency registers or the pulse width registers in real-time. Many dynamic effects can be generated in this manner. Siren-like sounds can be created by adding the OSC 3 Sawtooth output to the frequency control of another oscillator. Synthesizer "Sample and Hold" effects can be created by adding the OSC 3 Sawtooth output to the Filter Frequency control registers. Vibrato can be produced by setting Oscillator 3 to a frequency around 7 Hz and adding the OSC 3 triangle output (with proper scaling) to the Frequency control of another oscillator. An unlimited range of effects are available by altering the frequency of oscillator 3 and scaling the OSC 3 output. Normally, when oscillator 3 is used for modulation, the audio output of voice 3 should be eliminated (3 Off = 1).

 
ENV 3 (Register $1C)
 

Same as OSC 3, but this register allows the microprocessor to read the output of the voice 3 envelope generator. This output can be added to the filter frequency to produce harmonic envelopes, WAH-WAH, and similar effects. "Phaser" sounds can be created by adding this output to the frequency control registers of an oscillator. The voice 3 envelope generators must be gated in order to produce any output from this register. The OSC 3 register, however, always reflects the changing output of the oscillator and is not affected in any way by the envelope generator.