.. _fm: SID 2 (SID-compatible FM-Synthesizer) ===================================== The SID 2 is a sound generator that is backwards-compatible with the famous Commodore SID, but extends it by powerful FM Synthesis features. Each of the three voices in the SID 2 consists of two operators, with each operator functioning identially to one SID voice with the addition of a sine-wave output option. In the default, additive synthesis mode, the two operators function independently, with both of their outputs audible, yielding up to 6 total voices nearly analogous to a dual-SID setup. If frequency-modulated synthesis mode is selected for a voice, its two operators are merged, with the output of one (the modulator) shifting the frequency of the other (the modulated). Only the output of the modulated operator becomes audible in this case. The famous SID filters are also still present in this design, allowing further flexibility in sound generation. Each of the three voices can be independently selected to be passed through this filter. In additive synthesis mode, both operators’ outputs of a selected voice are passed through the filter. All additional functionality is hidden in new registers mapped to addresses unused in the original SID, which all reset to inactive states, providing backwards-compatibility. Tunes composed for the original SID will also play back correctly on the SID 2. --------------- Pad Assignments --------------- .. list-table:: Pad description :name: sid-2-pad-description :header-rows: 1 * - Pad - Name - Type - Summary * - ``bidir[5]`` - ``R/Wn`` - I - Active low write-enable * - ``bidir[10]`` - ``CEn`` - I - Active low chip-enable * - ``bidir[15:11]`` - ``A[4:0]`` - I - Register address inputs * - ``bidir[21:16]`` - ``D[5:0]`` - IO - Bi-directional databus * - ``bidir[23]`` - ``D[6]`` - IO - Bi-directional databus * - ``bidir[32]`` - ``D[7]`` - IO - Bi-directional databus * - ``bidir[33]`` - ``POTY`` - IO - Potentiometer analog input Y * - ``bidir[34]`` - ``POTX`` - IO - Potentiometer analog input X * - ``bidir[39]`` - ``A[5]`` - I (PD) - Register address input * - ``bidir[41]`` - ``RSTn`` - I - Active-low design reset --------- Registers --------- To allow for twice as many operators to be present on the SID 2 as on the SID, the amount of registers has been doubled through the use of an additional address input to differentiate between the two banks of SID registers. This behaves similarly to a dual-SID setup. The following registers are implemented, with register bits unique to the SID 2 highlighted in green. Bank 0 ------ .. raw:: html
Addr 2⁷ 2⁰
Voice 1, Modulating Operator
'h00freq[7:0]
'h01freq[15:8]
'h02pw[7:0]
'h03pw[11:8]
'h04NoisePulseSawTriangleTestRingSyncGate
'h05attackdecay
'h06sustainrelease
Voice 2, Modulating Operator
'h07freq[7:0]
'h08freq[15:8]
'h09pw[7:0]
'h0Apw[11:8]
'h0BNoisePulseSawTriangleTestRingSyncGate
'h0Cattackdecay
'h0Dsustainrelease
Voice 3, Modulating Operator
'h0Efreq[7:0]
'h0Ffreq[15:8]
'h10pw[7:0]
'h11pw[11:8]
'h12NoisePulseSawTriangleTestRingSyncGate
'h13attackdecay
'h14sustainrelease
Filter Configuration
'h15fc[2:0]
'h16fc[10:3]
'h17resV3V2V1
'h183 OFFHPBPLPvol
Misc.
'h19potx
'h1Apoty
'h1Bosc3¹
'h1Cenv3¹
Voice 1, Modulating Operator, Sine Configuration
'h1DSNoiseSPulseSSawSTriangleSine
Voice 2, Modulating Operator, Sine Configuration
'h1ESNoiseSPulseSSawSTriangleSine
Voice 3, Modulating Operator, Sine Configuration
'h1FSNoiseSPulseSSawSTriangleSine
Bank 1 ------ .. raw:: html
Addr 2⁷ 2⁰
Voice 1, Modulated Operator
'h20freq[7:0]
'h21freq[15:8]
'h22pw[7:0]
'h23pw[11:8]
'h24NoisePulseSawTriangleTestRingSyncGate
'h25attackdecay
'h26sustainrelease
Voice 2, Modulated Operator
'h27freq[7:0]
'h28freq[15:8]
'h29pw[7:0]
'h2Apw[11:8]
'h2BNoisePulseSawTriangleTestRingSyncGate
'h2Cattackdecay
'h2Dsustainrelease
Voice 3, Modulated Operator
'h2Efreq[7:0]
'h2Ffreq[15:8]
'h30pw[7:0]
'h31pw[11:8]
'h32NoisePulseSawTriangleTestRingSyncGate
'h33attackdecay
'h34sustainrelease
Modulation Volume Adjust
'h35modvol1
'h36modvol2
'h37modvol3
FM Configuration
'h38CDinvfm_en
Misc.
'h39potx
'h3Apoty
'h3Bosc3¹
'h3Cenv3¹
Voice 1, Modulated Operator, Sine Configuration
'h3DSNoiseSPulseSSawSTriangleSine
Voice 2, Modulated Operator, Sine Configuration
'h3ESNoiseSPulseSSawSTriangleSine
Voice 3, Modulated Operator, Sine Configuration
'h3FSNoiseSPulseSSawSTriangleSine
¹In bank 0, these registers sample from the modulating operator of Voice 3, but in bank 1, they sample from the modulated operator of Voice 3. ---------------------- Functional Description ---------------------- Description of original SID function is not covered in this documentation, please refer to `original documentation `__ for information on SID functionality. Compatibility Mode ------------------ After reset, the SID 2 behaves like a single SID. FM is disabled for all voices, putting them in additive mode. However, the ``CD`` (short for Compatibility Disable) bit of register ``'h38`` gates additive synthesis mode. If this bit is cleared, as is the default, only the three operators of bank 0 (the modulating operators) are audible, with the additional operators of bank 1 being disabled. Additive Synthesis ------------------ Once ``CD`` is set, additive mode is enabled for all voices that do not have FM enabled. In additive mode, the modulating and modulated operator outputs in the affected voice are added together. To prevent clipping, the volume of each operator is halved before this addition, meaning the final voice output is ``v = op1 * 0.5 + op2 * 0.5``. This incompatibility necessitates the existance of the ``CD`` bit, as the halving does not take place when it is clear. FM can be enabled for individual voices even while ``CD`` is clear. Frequency Modulation Synthesis ------------------------------ Frequency Modulation Synthesis can be enabled for individual voices by setting the corresponding bit in ``fm_en``. In this mode, the output of the modulating operator of the affected voice becomes inaudible and is instead used to modulate the frequency of the modulated operator. The frequency of the modulated operator is continuously multiplied by one plus the amplitude of the modulating operator output multiplied by three: ``f_mod = freq * (1 + amplitude * 3)``. To control this effect more precisely, the ``modvol1`` through ``modvol3`` registers scale the output of the corresponding voice’s modulating operator. A value of zero is off, while a value of ``'hFF`` is full volume. In FM Mode, this allows the maximum frequency shift to be tuned. In additive mode, these register simply scale the audible volume of these operators, even if ``CD`` is clear. To maintain backwards-compatibility, all three ``modvol`` registers read ``'hFF`` after reset. Sine Wave Generation -------------------- To allow for more interesting and dynamic sound types to be generated, all 6 operators on the SID 2 have been extended by one additional waveform type: sine wave. This can be selected by setting the "Sine" bit in the corresponding "Sine Configuration" register, along with at least one of "SNoise", "SPulse", "SSaw" or "STriangle". Selecting multiple waveform types causes the output of the operator to become the bitwise-logic-AND of all selected waveforms, just as on the SID, which now includes the sine wave. The sine wave is generated by indexing a quarter-sine Look-Up-Table and translating its output depending on which quadrant of the wave the index falls in. How this index is generated depends on the remaining bits in the Sine Configuration register. A normal sine wave can be achieved by setting just the "SSaw" bit. This selects the value of the sawtooth waveform to be used as the LUT index. As this waveform’s binary amplitude simply counts up until overflowing to zero, this results in a linear cycling through the LUT indices and thus a normal sine wave. However, other waveforms, and their bitwise-logic-AND combinations, may be used as the LUT index, creating other waveforms. For instance, selecting just "STriangle" as the LUT index generates a "mirrored" looking wave. .. image:: _static/waveform1.png Relationship between LUT index and sine output. This is also the final output when using sawtooth as the LUT index. .. image:: _static/waveform2.png Alternative waveform achievable by using triangle as the LUT index. .. image:: _static/image.png Frequency modulation example where the modulating operator is playing a square wave and the modulated operator is playing a sine wave.