Sound chips in 8-bits - continuation

== Sample Playback ==

When the SID chip is used to play back sampled sounds, the value of each sample can be converted to a four-bit number that affects the sustain level. The envelope itself is changed so that the attack, decay, and release values are set to zero (this corresponds to the sharpest edges), the GATE bit value remains set to a logic one, and only the sustain level is changed programmatically.

== GATE Bit at the Moment of ATTACK And RELEASE Phases ==

SID also allows the GATE bit value to be changed at any time. For example, if this bit is cleared while the attack cycle is still in progress, the release cycle will start immediately, i.e. the middle part of the envelope will disappear.

It is also possible to set the GATE bit back to logic one before the release cycle has finished, which immediately starts the next attack cycle (some music synthesizers that also use the ADSR envelope do not allow this "accelerated" transition between attack and release cycles).

== Other Parts of the Sound Processing Chain ==

Signal generators and envelope shapers (i.e. ADSRs) are the basic blocks that can be used to generate sounds that mimic various musical instruments. However, this is far from all that SID can do. First of all, it is possible to influence the output of one signal generator by the output of another using so-called ring modulation (the name of this modulation is derived from the way semiconductor diodes are connected in an analog circuit, which performed this modulation, for example, in superheterodynes - FM receivers), synchronise individual signal generators, use analogue output filters such as low-pass, high-pass and band-pass, add an external audio signal, combine signals generated in signal generators, etc.

These techniques, which, among other things, have contributed greatly to the popularity of SID, will be discussed in more detail in the following chapters.

== Ring Modulation ==

Two selected audio signals can be subjected to ring modulation before the signal generated in the signal generator is input to the amplitude modulator, which results in the synthesis of unique and SID-specific sounds. In fact, SID is one of the few sound chips to use ring modulation; for example, it is very difficult to emulate on OPL-2 or OPL-3 chips.

Ring modulation can always be enabled for a pair of selected audio channels: channel 1 can be modulated by the output of the oscillator of channel 3, channel 2 can be modulated by the output of the oscillator of channel 1, and finally channel 3 can be modulated by the output of the oscillator of audio channel 2 (see the fourth figure with the blue arrows indicating which signal is modulated by which).

For the effect of ring modulation to be audible, an oscillator producing a triangular signal (its rising and falling edges have the same slope) must be enabled on the modulated audio channel. A rectangular signal of a specified frequency is always used from the modulation channel to "sample" (multiply) the triangular signal on the modulated audio channel, which is usually of a somewhat lower frequency than the rectangular signal.

The frequencies of the two channels whose signals enter the ring modulator can be coherent or incoherent - each time synthesizing a tone with a different timbre (for example, a 3:2 or 5:4 frequency ratio sounds interesting). Multiplication in the time domain leads to a whole wide range of inharmonic frequencies in the frequency domain which can be used to create the coloured tones typical of SID music.

The timbre obtained using ring modulation is quite different from that obtained using frequency modulation (FM) or phase modulation (PM), although these modulations also produce additional higher and lower frequencies in the resulting sound.

== Output Filters ==

The SID is a hybrid chip containing both digital circuits (such as the signal generators described earlier or the part that provides the chip's connection to the address and data bus as well as the logic for selecting control and status registers) and purely analog circuits. Based on analog circuits, output filters are also created, to which it is possible to selectively feed both the outputs from individual audio channels (after applying ring modulation and amplitude modulation using the ADSR envelope) and external audio signal.

Output filters are of three types - low pass (LP), high pass (HP) and band pass (BP). Filters are essentially a separate part of the audio synthesis, which is not additive (no other components are added to the signal), but rather subtractive (selected frequencies are removed or reduced).

The individual filters can be combined with each other to create, for example, a band stop using a low pass and high pass, or low pass with a different characteristic using a low pass and band pass. Two 8-bit control registers are used to set the cutoff frequency of all filters (this is the only frequency valid for all three filter types, but its meaning is different for each filter).

If two capacitors with a capacitance of 6.8 microfarads are connected between the pins named CAP1A and CAP1B and CAP2A and CAP2B, the cutoff frequency of the filters can be changed in the range of approximately 30 Hz to 12 kHz (Commodore C64 computers contained capacitors of this capacitance, but SID can be used in other systems as well, where the capacitances may be different depending on the intended use of the chip).

The frequency itself is represented as an 11-bit dimensionless number, the actual frequency is linearly dependent on this value.

The attenuation of the audio signal passing through the low and high pass is approximately 12 decibels per octave after the cutoff frequency is exceeded. In the case of a band-pass, the attenuation (in both directions from the cut-off frequency) is equal to six decibels per octave. Remember that a one-octave increase in pitch doubles its frequency and a one-octave decrease halves its frequency.

The attenuation is given in decibels, i.e. the logarithmic ratio between the measured (calculated) amplitude and the maximum amplitude (the result is also multiplied by ten or twenty depending on whether it is voltage or power attenuation or amplification).

== External Signal Input And Volume Control of Output ==

In the block diagram of the SID sound chip we can see the input of an external signal along with the possible way this signal can be processed - either the external signal is directly mixed with the outputs of the audio channels or it is fed to the input of the filters described in the previous chapter. Virtually any sound chip can be connected to this analogue input with an input impedance of approximately 100 kiloohms, for example another SID or even an AY-8910 or POKEY :-), or the analogue output from a sound synthesizer (electronic organ).

The number of chips connected in "series" is practically limited only by the increasing noise level. This input has also been used by many users in the SID 8580 series to feed a DC component into the VOLUME block, thus enabling the playback of sampled sounds, as this last series of SID chip was modified to produce a less noisy output, but this resulted in the absence of the DC component that is used in sample playback (see next section). The last block on the SID is a block called VOLUME, which changes the volume of the resulting sound globally. Four bits in one of the control registers are reserved for determining the volume, which actually determines the typical sample format when playing digitized sounds.

== Playing Back Digitized (Sampled) Sound ==

It is also possible to play back digitized (sampled) sound on the SID sound chip quite easily. There are several possible ways to play back sampled audio; typically either direct control of the output level in the VOLUME block is used, with a DC component fed to the input (this makes it easy to work with four-bit samples), or PWM - pulse width modulation - is used, i.e. a program change in the rectangular signal's alternation.

In this case, it is not possible to use the SID's capabilities directly for alternation, because its sound generators do not have such a high frequency (for PWM, a time step corresponding to the sampled frequency multiplied by the dynamic range of the sample, i.e. for example 2^8, must be used).

Using PWM, even on an ordinary Commodore C64 computer, digitized audio sampled at about 16 kHz with samples stored at six bits can be played back without further hardware modifications, corresponding to a dynamic range of about 36 dB (with SuperCPU, sample rates up to 19 kHz with fully 8-bit samples can be achieved).

A detailed description of the various ways of playing digitized sounds (including practical examples of playback routines) is given in the article The C64 Digi, by Robin Harbron, Levente Harsfalvi and Stephen Judd. The simplest playback routine, which directly modifies the output volume depending on the highest four bits of an eight-bit sample, looks like this:

       ldy #0      ; The lower 8 bits
                   ; of a pointer to
                   ; the sample being
                   ; played
:loop  lda ($fd),y ; At $fd and $fe
                   ; (in zero page),
                   ; the beginning of
                   ; the sample is
                   ; stored
       sta $d418   ; Address of the
                   ; VOLUME control
                   ; register - play
                   ; sample
       ldx #5      ; Set according
                   ; to sample rate
:delay dex
       bne :delay  ; Delay loop
       iny         ; transition to
                   ; next sample
       bne :loop
       inc $fe     ; We count even with
                   ; the transition
       jmp :loop   ; through a memory
                   ; page of 6502
                   ; (page = 256 bytes)

== SID: Past And Present ==

SID was initially designed primarily for use in Commodore's eight-bit home computers (CBM).

In this respect, it was indeed a great success, as the Commodore C64 in particular was one of the most successful eight-bit computers (in terms of sales numbers), surpassing both the eight-bit Apple II (this computer was especially popular in companies and schools, thanks in part to Wozniak's ingeniously designed floppy disk drive and VisiCalc spreadsheet) and probably the European ZX Spectrum (specific numbers vary quite a bit; while the numbers of C64s sold are fairly accurate, the situation is somewhat more complex for ZX Spectrum computers, as there are many more or less compatible clones, many of which are widespread).

However, thanks to the specific sound that SID can generate, this sound chip later came to be used in other devices, especially in specialized synthesizers.

Since the original SID is no longer manufactured and its imitations have a different sound, these synthesizers use older chips obtained, for example, from defunct Commodore computers or from leftover stock released on the market (this situation speaks to the unique position of the SID - there is perhaps no other integrated circuit that, after more than 20 years, would be "mined" from old eight-bit computers and incorporated into modern systems).

== Samples of Music for SID ==

Similarly to the Atari 8-bit home computers and the ASMA music archive, the SID has an archive of music created using this chip. This archive is named HSVC, or High Voltage SID Collection, and is available at http://www.hvsc.c64.org/ (in fact, the creators of ASMA were inspired by HSVC and its success).

The music in HSVC is stored (again, similar to the POKEY chip) in the form of a MOS 6502 microprocessor machine program that changes the values of the chip's SID control registers at specific intervals.

The stored music files are very short for this reason, often only a few kilobytes long (sometimes only hundreds of bytes). Only when sampled sounds are used, the file size is larger, but usually does not exceed about 30 kilobytes (this is also due to the limitations imposed by the original 8-bit computers).