Transforming your Raspberry Pi into a retro C64 juke box using SIDPlay | blogatom.

Hey, if the Raspberry Pi has a fast CPU and an Audio Out port, it should be able to play Commodore 64 tunes, right? I think it’s a fundamental law of computers: every sufficiently advanced device will eventually evolve to emulate really old micro computers from the 80’s ;-) It turns out it’s really easy to turn your Pi into a retro C64 jukebox filled to the brim with brilliant SID tunes. Here’s how to do it.

First, make sur your Pi’s sound works! The latest Raspbian “Wheezy” images include the sounds drivers by default, so you should be all set if your OS is up-to-date. Let’s test it real quick using a good old WAV test sound:

wget http://www.freespecialeffects.co.uk/soundfx/sirens/police_s.wav
aplay police_s.wav

This should work all right, just make sure something is connected to your Pi’s Audio Jack ;-)

Now we should get a SID player, luckily there are quite a few integrated in the Debian/Raspbian distribution!

First make sure your APT package cache is up-to-date:

sudo apt-get update

Then check out all the SID goodness in there:

apt-cache search sidplay

As you can see, you have no less than three different versions of the SIDPlay libraries!

pi@raspberrypi ~ $ apt-cache search sidplay
libresid-builder-dev - SID chip emulation class based on resid
libresid-builder0c2a - SID chip emulation class based on resid
libsidplay1 - SID (MOS 6581) emulation library
libsidplay1-dev - SID (MOS 6581) emulation library (development files)
libsidplay2 - SID (MOS 6581) emulation library
libsidplay2-dev - SID (MOS 6581) emulation library
libsidplayfp - Library to play Commodore 64 music based on libsidplay2
libsidplayfp-dbg - library to play Commodore 64 music based on libsidplay2 (detached symbols)
libsidplayfp-dev - library to play Commodore 64 music based on libsidplay2 (development files)
libsidplayfp-doc - library to play Commodore 64 music based on libsidplay2  (documentation)
libsidutils-dev - utility functions for SID players
libsidutils0 - utility functions for SID players
sidplay - Music player for tunes from C64 and C128 (console)
sidplay-base - Music player for tunes from C64 and C128 (console)
sidplayfp - Fork of sidplay2, a C64 and C128 music player
xmms2-plugin-sid - XMMS2 - libsidplay2 based decoder
xsidplay - Music player for tunes from C64

According to my research, it looks like the “sidplayfp” library may be the newest and most accurate emulation library, unfortunately I haven’t been able to play tunes successfully with it: it looks like the Pi does not have enough CPU power to run that version, even with overclocking set to “Turbo” mode. So I turned to the next best solution: the “sidplay2” library, which is used by numerous SID playing programs on the PC or the Mac. Install it using apt-get:

sudo apt-get install sidplay2

I have tested that library with Overclocking settings set to “None” and it runs perfectly fine, so it won’t burn out your Pi!

Now of course we need a nice SID tune to test the player. Here’s one for you, Dane’s amazing 2008 compo for the Edge of Disgrace demo:

wget http://hvsc.perff.dk/MUSICIANS/M/Mitch_and_Dane/Dane/Edge_of_Disgrace.sid

You should be able to play the tune simply by running the following command:

sidplay2 Edge_of_Disgrace.sid

You will probably get this error, because sidplay2 uses the old OSS /dev/dsp interface:

/dev/dsp: No such file or directory

To fix the problem, load ALSA’s OSS emulation module:

sudo modprobe snd_pcm_oss

And sidplay2 should stop complaining and just play the tune.

In order to fix the problem forever, add the snd_pcm_oss module to the /etc/modules file, and it will be automatically loaded at boot time.

Now in order to stock up on tunes, you will of course need to download that immense compendium of C64 songs, the amazing High Voltage SID Collection, or HVSC! At the time of writing the latest version is #58, and you can download and extract the full version like so:

wget http://www.prg.dtu.dk/HVSC/HVSC_58-all-of-them.zip
unzip HVSC_58-all-of-them.zip
unzip C64Music.zip

This will give you more than 43,000 songs to play. Now hook up your Pi to a good set of speakers, preferably including a subwoofer in order to fully enjoy the SID chip’s amazing bass tones! Here are some of the songs I used to test my setup, but there are so many hundreds of amazing compositions in that archive…

sidplay2 C64Music/MUSICIANS/F/Fanta/Random_2.sid
sidplay2 C64Music/MUSICIANS/F/Fanta/Natural_Wonders.sid
sidplay2 C64Music/MUSICIANS/T/Tel_Jeroen/RoboCop_3.sid
sidplay2 -o3 C64Music/MUSICIANS/T/Tel_Jeroen/Savage.sid
sidplay2 C64Music/MUSICIANS/G/Galway_Martin/Ocean_Loader_1.sid

Enjoy!