= Sound chips in 8-bits =

Pavel Tišnovský
2021

Part 3 - SID Sound Chip in Commodore's 8-bit Home Microcomputers

A major competitor to Atari in the development and sale of eight-bit home microcomputers was Commodore Business Machines (CBM), which was behind the development and sale of Commodore's eight-bit home computers, including the famous C64. As was the custom in the past, Commodore (in much the same way as competitor Atari) developed their own custom chips for the chipset of their home microcomputers, including the successful VIC II graphics chip and the SID sound chip described today.

The abbreviation SID is derived from the full English name Sound Interface Device, but this integrated circuit is also known by its numerical designation - the original series produced using N-MOS technology was labeled 6581, and later versions produced using H-MOS technology were labeled 6582 or 8580 (the latter, however, is somewhat different in sound from the original series). The initial digits 65 of course refer to the MOS 6502 microprocessor.

== Developed SID Series ==

The following table lists all developed series of the SID chip:

Series      Chip Labelling  Technology
6581 R2     6581            N-MOS
6581 R3     6581 R3         N-MOS
6581 R4     6581 R4         N-MOS
6581 R4 AR  6581 R4         N-MOS
6582 A      6582 A          H-MOS
8580 R5     8580 R5         H-MOS

== Notes on Individual Chips ==

6581     Original available variant,
         R1 was not sold (therefore
         not in the table).
6581 R3  Produced until 1986, sometimes
         also referred to as 6581 CBM.
6581 R4  Produced during 1986.
6581 R4  Produced from late 1986 to
         1990.
6582 A   Produced around 1992 (some
         also later).
8580 R5  Produced between 1987 and
         1992.

== SID Sound Chip Development ==

The development of the SID sound chip was led by Robert "Bob" Yannes, who later founded Ensoniq, a company that produced sound synthesizers and sound cards for professional and semi-professional use. Due to the very short deadline by which the SID chip was to be completed, a rather unpleasant thing happened, known for example also from software development - the documentation for the final version of the chip was delayed and in fact never completed in its entirety.

This led to an interesting paradox - the sound chip did work (and very well, especially considering its minimalist hardware, attributable to the time of its creation and technological possibilities), but the existing documentation (valid for the development versions) did not correspond to the final product, which for many people meant a form of adventure in finding all the possibilities that this chip provided for music creation.

However, despite this small handicap, the SID became widespread, not least because of the success of the Commodore C64, an eight-bit home microcomputer that sold tens of millions of units. Byte Magazine even ranked the SID among the twenty most important chips in computer history. The SID's unique sound capabilities are still used in some synthesizers today, most notably the SIDStation. In addition, SID is used in HardSID and MSSIAH, and most likely in other similarly designed audio devices.

== Connecting the SID Pins ==

Let's take a look at the pinout of the SID chip (see the picture).

In this wiring we can see that it is a relatively small integrated circuit with 28 pins, unlike the "competitive" 40-pin POKEY (Atari) chip, which had a relatively large number of pins for keyboard, serial bus and other "non-acoustic" purposes. Some of the SID chip pins are digital (two-state), for example the part intended for connection to the address and data bus (the levels correspond to N-MOS and H-MOS technology).

Other pins are analogue, however - audio input, audio output, capacitor connections for filters, etc. In addition, the SID requires two supply voltages, namely the standard 5 V, plus a rather non-standard 9 V for the analog part (newer versions have this voltage reduced, so the chip radiates less heat, not to mention the simpler wiring of the whole computer or audio device).

== Block Structure of the SID Chip ==

The second picture shows the block structure of the SID sound chip. From this figure, it can be seen that there are multiple interconnected blocks in which sounds are created and modified. Some blocks are made up of digital elements, while other blocks are purely analogue, contributing to a unique (and often easily recognisable) sound.

== Brief Description of the Entire Sound Chain ==

The basis of the whole chain, in which the sound is created, consists of three generators of periodic signal, whose shape can be rectangular (with adjustable pulse ratio), triangular or sawtooth (SID cannot automatically generate a sine wave, like many other sound chips of the eight-bit era, on the other hand, the tone generated by the sine wave is flat, i.e. without higher harmonics).

The tone, or more accurately the periodic signal that comes out of the generator, is modified in an amplitude modulator, which can vary the amplitude based on an envelope specified by a quartet of values known collectively as ADSR, or attack, decay, sustain and release.

Before the signal enters the amplitude modulator, two selected audio signals can be subjected to ring modulation, the use of which also results in the creation of unique and SID-specific sounds.

== Analog End Section - Filtering ==

The signal that results from the application of ring modulation and amplitude modulation can either be directly amplified and sent to the output (it can also have an external signal added to it, e.g. from another SID, connoisseurs can even combine SID and POKEY or SID and AY-8910), or it can be further processed in an analog filter block.

Depending on the current chip configuration, a low-pass, high-pass or band-pass filter can be used.

The specific frequency ranges for these filters are determined by the capacitance of the capacitors connected to the SID chip (inputs CAP1A, CAP1B, CAP2A and CAP2B, capacitors with an approximate capacitance of 6.8 nF are used) and by setting an 11-bit value in a pair of control registers.

== Control Registers ==

The SID sound chip can be controlled using 29 eight-bit registers, which are divided into five groups:

== Signal Generators ==

Signal generators form the first part of the entire sound generating chain. The SID chip can produce periodic signals of three types (rectangular, triangular, sawtooth) for each sound channel, or it can use a noise source, which is used in practice, as in the case of the POKEY sound chip described last time, for example to mimic the sound of percussion instruments (some musical compositions use digitized samples of real percussion instruments instead).

The frequency of these signals is derived from the frequency of the clock (the clock signal is fed to pin fi2) and a 16-bit number stored in a pair of control registers - each audio channel can of course be set to a different frequency. Using a 1 MHz clock signal (approximately the same frequency used in eight-bit Commodore home computers), the range of notes generated is almost eight octaves, with a very small step that allows smooth transitions from one note to the next (portamento). Within this eight octave range, one of 65536 different tones can be selected for each audio channel (2^16=65536).

== Rectangular Signal Alternation ==

The rectangular signal, which contains the largest proportion of higher harmonics (the triangular signal, whose shape is most "sine-like", has the least), is special because it is possible to select its pulse ratio, i.e. the ratio between the duration of the low and high levels. The mode does not affect the fundamental frequency of the signal but the spectral characteristics of the higher harmonics.

In the case of the SID, the duty cycle is set from 0 to 100 % using a twelve-bit number stored in a pair of eight-bit control registers (the higher four bits of the second register remain unused).

Setting the value to 2047 generates a rectangular signal with 1:1 inversion, while the highest value (4095) results in only the DC component coming out of the signal generator. The latter is of course not audible by itself, but can still be used, for example for sampling or for unconventional tone generation just by changing the envelope shape (see later chapters). The pitch can be changed very quickly, which is sometimes used, for example, in games to mimic the sounds of certain weapons.

== Envelope Shaping ==

An important part of the sound-generating chain consists of two blocks, which can be used to shape the so-called envelope. The envelope controls the amplitude of the signal at the output of the block labeled Amplitude Modulator. Two signals enter this block:

By utilizing an envelope, it is possible to modify the audio signal so that it resembles the tone of a real musical instrument to a large extent, which is one of the reasons why envelopes of the same type (called ADSR - the reason is given in the next paragraph) are used in many music synthesizers and some other sound chips (the better known ones being OPL-2/Yamaha YM 3812 and OPL-3/Yamaha YMF 262).

The basic envelope shape is determined by four parameters - attack (the duration or steepness of the first edge), decay (the duration or steepness of the second - falling/rising - edge), sustain (the stable level of the envelope signal after the initial rise and fall, usually expressed as a percentage of amplitude), and release (the duration or steepness of the last - falling - edge). Four bits are reserved for each of these parameters in the control registers of the SID sound chip.

The four-bit value of the attack parameter determines the rise time in the range of 2 ms to 8 seconds (it is assumed that a clock signal with a frequency of 1 MHz is connected to the clock input fi2; of course, if the frequency differs, the times will also differ).

The values of the parameters decay and release specify the duration of the falling edges in the range 6 ms to 24 seconds, i.e. although they also use only a four-bit value, all times are three times longer. The value of the sustain parameter represents a fraction of the amplitude in the range 0/15 (i.e. silence - there is still a zero amplitude signal at the output of the Amplitude Modulator block) to 15/15 (corresponding to 100 %).

== Controlling Both Sustain Time And Envelope Amplitude ==

Note that the four parameters above are not sufficient to fully describe the envelope shape. In particular, the determination of the time the envelope maintains the sustain level is missing, as is the amplitude, i.e. the maximum level of the envelope signal at the point where the attack leading edge breaks and turns into the decay leading edge. These two parameters are in fact set separately.

The maximum envelope signal level is always set to 100%, but with the understanding that the output level from the entire sound generation chain is globally influenced by the four bits of a single control register. The duration of the sustain level is determined by the GATE bit stored in one of the control registers, separately for each audio channel.

The moment this bit is set to a logic one, an attack cycle is triggered (the envelope begins to change according to the rising edge), followed automatically by a release cycle (first falling edge) until the envelope level settles at the sustain value. This value is maintained as long as the GATE bit is a logic one. The moment this bit is cleared programmatically, the release cycle begins, i.e. the envelope level decreases to zero.

Note: for example, the OPL2 and OPL3 chips use a bit called KEY-ON instead of the GATE bit, but with a very similar meaning.