DTV SID experiments

On this page I am collecting some bits of information regarding the DTV's SID implementation. The interest in this subject was sparked by Nojoopa by a post on DTV Hacking forums @ PETSCII. It has been discovered that there are cases where the DTV SID implementation does not produce the expected result.

One thing that was known already from the DTV hardware specs was that the DTV SID does not have any filters. In the original C64 SID the filters were actually analog, and varied greatly between different pieces of hardware. A lot of games did not use filters to much extent, probably because the resulting sound would be too "unpredictable". Still, even with games, programs or demos using the SID filters extensively, an implementation without them will still give some sound, although it might sound slightly different. In my opinion this was an understandable sacrifice in terms of getting the DTV produced, and since it was mainly meant for playing the 30 games shipped with it, the filters were not too important.

But as Nojoopa pointed out, there are other things with the DTV SID implementation, that do not behave as expected. Most notably, combinations of master volume and channel parameters (mainly the envelope settings) result in either no sound, or sound at a level that does not correspond to the selected parameters. For some games, this results in a much different SID experience on the DTV compared to a real C64. Exploring the hardware, and attempting to discover its limitations seems interesting, and since I wanted a fun little project getting me back to DTV hacking, I dug out my oscilloscope and started playing around.

Schematics

Of course the first thing to get straight was the schematics of the DTV audio circuit, and where to connect the probes. I looked at a DTV PCB, measured, and compared with the Original schematics. This is what I came up with (not too different from the original - resistors and capacitors are discrete instead of arrays, and the output inductor is gone).

DTV SID audio schematics
DTV SID audio schematics

Now, with the scope connected to the appropriate channels on the DTV ASIC, and using Nojoopa's SIDTESTM, I started gathering some information.

The volume channel

The volume channel is the most simple one, so let's start with that. For a volume setting of 0 (in SID register $D418), it is constantly low. For other volumes, a 16-bit pattern is produced, switching at 32MHz (i.e. bit duration is 31.25ns). The pattern (being 16 bits) repeats at 2MHz (500ns). The generated pattern has a number of bits set equal to the global volume setting. Bits are evenly spaced:

volpattern
$00000000000000000
$11000000000000000
$21000000010000000
$31000010000100000
$41000100010001000
$51001001001001000
$61010010010100100
$71010100101010010
$81010101010101010
$91010110101011010
$A1011011010110110
$B1101101110110110
$C1110111011101110
$D1111101111011110
$E1111111011111110
$F1111111111111110

Note that the bit patterns repeat, and capturing them on my scope means I cannot really define a start and end, so the values given above are possibly generated in some clever way.

In any case, the result of this is, that after being filtered by R42 and C23, a voltage proportional to the master volume setting appears.

SID channel

The individual SID channels each have corresponding digital output line from the ASIC, wired in exactly the same way as the volume channel. These lines show a pattern depending on both the master volume setting, and on the parameters for the corresponding channel.

It has already been established how the global volume setting produces a fixed pattern on the volume channel. Now, for a very simple case, channel 1 of the SID is configured for to output a square wave, and we look at how the signals on the output result in sound.

Starting with the most simple setting of 1 for the global volume, with attack, decay and release all set to 0, and a sustain-setting of $f, we observe a sound, and we can see the individual channels:

Volume/channel delay
Delay between volume and SID channel outputs

D0 is the volume channel, while D1, D2 and D3 are the digital SID channels, directly from the ASIC. Of course the image shows when the channel is active (remember that we used a square wave), and we can see that the pattern on the volume channel is output on the active channel as well, but delayed one bit (31.25ns). For a sustain-setting of $F, this is the case for all volume settings (with the patterns as described above).

Now, for the volume setting of 1, we look at the waveform for different settings of sustain. It was discovered that even values of sustain does not work correctly when volume=1, so here is what it looks like for the odd sustain values:

Vol=1, Sust=1
Volume=1, Sustain=$1
Vol=1, Sust=3
Volume=1, Sustain=$3
Vol=1, Sust=5
Volume=1, Sustain=$5
Vol=1, Sust=7
Volume=1, Sustain=$7
Vol=1, Sust=9
Volume=1, Sustain=$9
Vol=1, Sust=b
Volume=1, Sustain=$B
Vol=1, Sust=d
Volume=1, Sustain=$D
Vol=1, Sust=f
Volume=1, Sustain=$F

Notice that the last image shows the case we used originally, with sustain=$F, which results in the pattern output on the volume channel being duplicated on the voice channel, except delayed by one bit. For the other settings, it appears that the pattern on the volume channel repeats 16 times, and a number of these (depending on the sustain setting) also have the voice channel enabled. However, this seems to be the case for a volume setting of 1, and for odd sustain-values. When we try other combinations, results differ.

For instance, let's see what happens when we lock the sustain at 1 and look at different volume settings:

Vol=1, Sust=1
Volume=$1, Sustain=$1
Vol=2, Sust=1
Volume=$2, Sustain=$1

As previously described, increasing the volume setting leads to more bits being set in the volume pattern, and for volume settings of 8 or less, it also increases the number of pulses generated on the volume channel. But when looking at volume=2, sustain=1, we see that the voice channel has 3 pulses, instead of 4, as we might have expected based on previous results.

Vol=3, Sust=1
Volume=$3, Sustain=$1

And for a volume setting of 3, we observe that the theory of the sustain setting only affecting how many times each 16-bit pattern is repeated, does not hold. (Beware of the time base change when comparing to the previous images).

For higher volume settings, we can clearly see that the volume patterns that repeat based on the sustain setting clearly do not do so after 16 patterns (8us), but at a much slower rate, and following a more complicated pattern.

Vol=4, Sust=1
Volume=$4, Sustain=$1
Vol=5, Sust=1
Volume=$5, Sustain=$1
Vol=8, Sust=1
Volume=$8, Sustain=$1

Let's try to take a closer look at the last image. Zooming in on the three pulses, to show their relation with the signal on the volume channel.

Vol=8, Sust=1
Volume=$8, Sustain=$1, Zoomed

The volume channel is now toggling at the fastest speed, but only every 4th pulse on the volume channel yield a corresponding pulse on the voice channel. Somehow, it appears there are things about the DTV SID implementation that I have a hard time getting a grasp on. I suppose with enough measurements it will be possible to build a better theory and understanding of the DTV SID. So far, I can't seem to get the picture, though.

I also took a different approach and tried to map the combinations of volume- and sustain-settings that yield sound. As already described, all the odd sustain-settings work for all volume levels. For the even sustain-settings, there are a number of volume settings that produce no sound. In these cases, the output channel (voice) is constantly low. I mapped the combinations in this matrix, with - indicating no sound, and S indicating some sound. But even for the combinations that yield sound, the correspondance between the parameters and the percieved volume level is not really obvious. A higher volume setting sometimes result in a lower percieved sound level.

volume 0 1 2 3 4 5 6 7 8 9 A B C D E F
sust 2 - - - - - S - S - S S S S S S S
sust 4 - - - S - S S S - S S S S S S S
sust 6 - - - - - S - S S S S S S S S S
sust 8 - - - S - S S S - S S S S S S S
sust A - - - S S S S S S S S S S S S S
sust C - - - S - S S S S S S S S S S S
sust E - - - S S S S S S S S S S S S S

As Nojoopa suggested, there might be some relation with the envelope value (which is based on the sustain settings in these experiments). It certainly does not look like the sustain setting is what directly leads to the missing sounds, but with envelope settings being derived from the sustain-setting, there is a chance of finding something more useful if mapping the envelope values to some of the other observations. For instance, a matrix like the above, but with the envelope values instead of the sustain settings might be useful. At any rate, I think I will need to do some more studying of the SID and especially to get a better understanding of the envelope generator, before I can be of any help in this respect.

I do, however, have a few more images that can possibly help identify how the patterns are generated, and in particular why sustain=4 and volume=4 yields no sound.

Vol=3, Sust=3
Volume=$3, Sustain=$3
Vol=4, Sust=3
Volume=$4, Sustain=$3
Vol=3, Sust=4
Volume=$3, Sustain=$4
Vol=7, Sust=4
Volume=$7, Sustain=$4
Vol=B, Sust=4
Volume=$B, Sustain=$4
Vol=F, Sust=4
Volume=$F, Sustain=$4

Still a lot of things I do not understand, but now I have provided the documentation that I have been gathering, and hopefully someone else will be able to spot something interesting, or at least come up with some good theory, and experiments to verify it.

Last updated: 2011.11.16