The Commodore 64 did not have any hardware dedicated to digital audio playback, so how were some games and songs able to achieve this on an unmodified and unextended Commodore 64? Did these techniques require specific hardware revisions?
No hardware revisions are necessary. The digitization playback is achieved by bit-banging the volume register of the SID chip to simulate a digital playback device. Essentially, the SID can be used as a 4-bit digital playback device. What's amazing is that the thing sounds as good as it does playing back digital data.
A great article about digis on the C64 can be found here: http://sid.kubarth.com/articles/the_c64_digi.txt
The best audio quality was obtained with
pulse width modulation using the square wave voice. The oscillator was set to 0 and the pulse width was set by flipping the pulse width from 0 to maximum.
With the CPU speed at 1mHz the fastest pulse switch rate achievable is around 15kHz, producing a sound wave of 7.5 kHz or less. Setting the low pass filter help smooth the sound.
There were also some more recent creative alternatives taking advantage of filters and undocumented test bits as well. Check out the Cubase64 demo by Mahoney: http://www.livet.se/mahoney/cubase64 You can also find versions of it playing on the real thing on YouTube, naturally. (spoiler alert: your face will melt -- it's that awesome.)
It seems that all the earlier posts only give partial answers to the question. The below extract of the relevant parts of my doc https://bitbucket.org/wothke/websid/src/master/docs/digi-samples.txt should remedy that situation and give a more comprehensive overview of all the respective techniques:
There are basically 4 general approaches [that are used to play digi samples on the C64]:
- $d418 "volume register" based
This is probably the oldest technique: The SID's audio output is directly modulated by changing the master volume. The result of this approach primarily depends on the original output available for modulation, i.e. ideally the original output would need to be at a constant maximum which would then allow the technique to modulate it to "anything" between 0 and that maximum. A flaw in the old 6581 SIDs made them particularly suceptible to this exploit: respective chips always produce a relatively large DC voltage offset on the master volume D/A which means that there is always "some" kind of original signal that can be modulated via the master volume - even when there is no regular voice output.
However this technique usually works poorly on the newer 8580 SID chips, since those no longer produce the flawed DC voltage offset, meaning that there may be very little original signal avilable for modulation (depending on what other regular output the SID's voices are producing).
[The technique can still work on the 8580, provided that there is suitable output from the SID's regular voices that can be modulated.] [..]
Mahoney's "8-bit samples"
There is a more recent "turbo charged" variant of the $d418 approach [..] Here the trick is to carefully setup the regular voice output such that not only the volume but also different filter activation will influence the modulated result. [..]
Due to the fact that the "carrier signal" has been specifically set up, the approach runs fine also on newer 8580 models. [i.e it runs on all SID models but a specific implementation is always optimized for a particular SID model's filter and D/A converter characteristics and will not yield optimum results when used on other models] [..]
- frequency modulation based
This technique probably produces the highest-quality sample playback, allowing for actual 8-bit samples. [Respective players typically only use the high-byte of the frequency register to control the "step width" - see below.]
The underlying principle is to use one of the waveforms that linearly transition from 0x0 to 0xfff (i.e sawtooth or triangle), to start it at 0 and then let it go up for a fixed number of clock cycles until it has reached the desired output level and then output that level for the duration of a sample.
The sample playback rate of this type of player is fixed, e.g. the player might play a new sample every 129 cycles. This means the SID will always "step up" the waveform output for exactly 129 cycles and it is then just a matter of finding suitable frequency settings [i.e. the size of each step] that will result in the desired output levels after 129 clock cycles [aka steps].
[This technique works on all SID models.] [..]
- pulse waveform based
An early/primitive form of pulse-waveform based sample output can be found in Slapshot_1987.sid. Here a 7kHz 1-bit signal is generated by manually turning the test-bit on/off and thereby toggling betweeen the 0x0 and 0xfff output level. [This works on all SID models but the audio quality is generally abysmal.]
More sophisticated later players use what might be be called a "pulse width modulation" approach. [..]
Their principle is to use a high frequency pulse-waveform and then manipulate the "average" output signal by shifting the pulse-width one way or another to get any average level between 0x0 and 0xfff.
[This approach works on all SID models eventhough the audio quality oftentimes suffers due to the used carrier signal.] [..]
- waveform toggling based
Finally there is an approach that tries to let one voice create different output levels by toggling between different waveforms. The respective frequency and pulse-width settings of that voice are previously configured in such a way that the respective waveforms result in the desired output levels.
[This works on all SID models but the resolution available for each audio sample is usually small.. due to the limited amount of different waveforms available.] [..]
PS: for some hands on experience you might use my below playlist to try out respective digi-songs online and see what technique these are actually using: https://deepsid.chordian.net/?file=/$TinyRSid%27s%20Digi%20Favourites/