21

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?

24

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

  • 3
    Actually, 4 bits. The volume register is 4 bit wide, and it happened that any change to the volume register produced a "clic" sound with the new volume (hence a 16 level volume). Changing the volume register value very quickly allowed the "clic" sound to follow the instant values of a 4 bit digital signal. – mcleod_ideafix Apr 27 '16 at 22:56
  • Would be good if the answer would be edited to correct the bit-depth, in line with the document it cites. – underscore_d May 25 '16 at 22:56
  • 1
    This does not really answer the question. Changing the volume on my PC does not make it possible to play samples. You need to incorporate the comment by @mcleod_ideafix for it to make sense. – pipe May 30 '16 at 19:50
  • It was the same technique used on all machines with a AY-3-8910 sound chip (Atari ST, MSX, Amstrad CPC, etc); On the ST it was typical to use the Timer B to generate a scanline interrupt to change the volume at that time, at around 15khz, allowing sounds of up to 7.5khz, the lack of filter made the result quite harsh. The three channels were playing a carrier signal like what Stavr00 described below. – Thomas Dec 9 '16 at 20:10
  • The same can be done with a disk drive! YouTube – Jammin4CO Aug 8 '17 at 16:40
7

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.

Pulse width modulation to sound wave example

Source: https://en.wikipedia.org/wiki/Pulse-width_modulation

https://www.c64-wiki.com/index.php/SID

  • Pulse-width modulation needs a carrier greater than 4KHz to get good results; even with a perfect reconstruction filter, an A440 (not a particularly high note) would need to have all harmonics beyond the fourth filtered out; an A880 would only get to have the fundamental and octave harmonic. Most sounds need at least the fifth harmonic before they even start to get "interesting", so a 4KHz PWM rate isn't going to cut it except when trying to produce very low notes. – supercat Dec 9 '16 at 19:48
  • I re-read the digi article in the original answer, and it explains a different way of doing PWM. Will rewrite. – Stavr00 Dec 9 '16 at 20:06
4

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.)

  • 2
    You need to actually write how that works, in this answer, otherwise it's just a comment. – pipe May 30 '16 at 19:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.