Welcome!

NAVIGATION:
Home
Projects

About


 Raspberry Pi 
SID Player


sidPic01


Project overview:

   
The Raspberry Pi SID player is a device which allows you to play music from the Commodore 64 computer using original audio hardware (the "SID" chip) through the Raspberry Pi. In addition to supporting the vast library of classic game music from the Commodore 64, this player also supports the playback of homebrew Commodore 64 music.

Video Demonstration:




Block diagram & Hardware configuration:


blockus

    The GPIO pins on the Raspberry Pi are used to address the SID chip and feed data to it. In order to reduce the number of GPIO pins used (which makes this compatible with earlier Raspberry Pi models), I leverage shift registers to interface between both the address and data busses of the SID chip and the Raspberry Pi.

    The output stage of the SID chip is coupled with a 1k resistor and 4.7uF capacitor as described in the SID chips datasheet. The audio is then fed into a very simple LM386 amplifier circuit, tuned for a gain of about 20x, which is sufficient to drive a headphone jack. The circuit for the amplifier comes straight from the LM386 datasheet, and it works fine for me. Powering the SID can be a challenge, as the chip requires both +5V and +12V supplies. I found that using an 8xAA battery pack full of Enloop rechargeable batteries produced 5.2V and 10.5V, depending on whether I tap half of all of the batteries. The SID 12V supply line worked fine for me at 10.5V. In addition to powering the SID, I use the 5V line to power the Raspberry Pi. This allows for a more compact, and portable build.

    Finally, to make the device useful as a standalone music player, I added an LCD to the device, which lets you see information about the currently playing song. I used a Sainsmart 20x4 LCD because it was inexpensive, and it is very easy to interface (I2C). Initial reports suggested that the 3.3v logic of the GPIO wouldn't be high enough to drive the LCD, but I did not have a problem doing so via i2c. 

Software configuration:

    
The Raspberry Pi is configured to run the Raspbian Linux distribution. I've coded a python script to control playback. The basic operation of my python script follows the flowchart below:

flowchart

    On the Pi, I use six GPIO pins to drive the shift registers. (Latch, Data, and Clock for each shift register). We also need a GPIO for the R/W pin and /CE pin, but they can be tied together and accessed through one GPIO pin, bringing the total to 7. Finally, two I2C pins are required for the LCD, using up 9 of the accessible pins. I opted against using a full header as it would block the unused GPIO.

    The raw SID files need to be converted to dumps before being played back. Parallax forum member Ahle2 has created a SID converter for his SID emulator for the Parallax Propeller, which is another really neat project. Basically what it does is reads the addresses of the SID every frame, and dumps the data to a file. In order to play it back then, all we need to do is increment through each address every frame writing each sequential byte from file to the SID, and the tune will play. You can check out his work and the dumper here: http://forums.parallax.com/showthread.php/118285-SIDcog-The-sound-of-the-Commodore-64-!-%28Now-in-the-OBEX%29

    I have attached schematics below of my build, as well as my sample Python script that plays music. The schematic is provided as a high resolution screenshot as well as a raw EAGLE schematic. You can provide a song title as a command argument to the program, and if not, it will default to the "Last Ninja 2" central park theme, which sounds particularly good. For my playback purposes, I SSH into the Pi and trigger the script from the command line. It would be very easy, however, to hook up a "Left/Right" button to change tracks if you wanted to use this project in a standalone casing.

Enjoy!

(Click to enlarge schematic)
superHiRez

Eagle Schematic

Python Code

Feel free to email any questions, comments or the like to my email bertszy{AT}gmail.com