It’s been silent here. Next to tripping to Tokyo to speak at Adobe MAX in Januari and doing some small jobs, I’m doing a very, very cool Flash 10 Project utilizing the upcoming Papervision for Flash 10. For some optimization parts I’ve been looking into using Alchemy as an easy way to write optimized bytecode. As opposed to what some people took from my previous post on Alchemy, I don’t hate Alchemy. My point there was that if Alchemy can perform that well, so should ActionScript be able to, with the standard compiler.
Now, that being said, all work and no play makes jack a dull boy. With no time to spare during the morning, daytime and evening, I took the laptop with me to bed last night, and decided to do something I didn’t do before, port something with Adobe Alchemy. I decided upon a long time thing on my wish list; SID Playback in Flash. What is SID ? Well, SID stands for Sound Interface Device, referring to the MOS6581 and it’s a programmable audiochip as used in the Commodore 64 and Commodore 128. I grew up with the Commodore 64, and the audio it produces is still something I hold dearly. You are quite likely to have heard a SID chip before, if you listen to the radio, as it is quite a possible you’ve heard one of these baby’s scream. Good recent examples are :
Bastian – You’ve got my love. (the beat in this song comes from Jeroen Tel’s Rubicon).
Nelly Furtado – Do It (controversy all around, Timbaland blatantly stole Glenn Rune Gallefoss’s version of Acid Jazzed Evening).
De Jeugd van Tegenwoordig – Hollereer (Produced by Bastian, C64 lover himself).
My interest was more playing back the old C64 tunes from games and demos. Keep in mind, an average SID file is about 2kilobyte to 10kilobyte; a perfect Small Web Format for all your music during preloading needs . Now, this is something I have been working on before in Flash 9, using the FC64 project, the amazing Flash C64 emulation effort by Claus Wahlers and Darron Schall. Last year, I even made a start with porting FC64 to Flash 10, but that needed to be dropped in favor of actual client work. SID Playback is something different from playing back .mod .xm or .mid files, as the SID chip doesn’t do much on it’s own. Essentially, a .SID file is an executable meant to be ran on the 6510, the Commodore 64′s CPU. So to playback the file, you not only need to emulate the SID chip, but also the 6510 and the needed registers / memory.
Software emulation of the SID chip has been around for a while, and all modern platforms have a way of playback SID files. Winamp plugins, command line utilities for conversion, it’s all there. As is there opensource code to do this. There’s libraries for most major languages. So, after a bit of research, I decided upon the Linux version of TinySid. This library is small enough and well optimized. It looked simple to port, so I went at it. All in all, 4 hours later, I had this baby up and running! (And an unhappy girlfriend who isn’t into the nerd thing, nor is she into listening to chiptunes whilst trying to sleep). Considering my very rusty C and a little hack around I had to do for the audio output, Alchemy shows off it’s feathers here. Many kudo’s to the Alchemy and Flash Player team for this effort. Just now I spent half an hour building a tiny interface using Keith Peter’s Minimal Components, and collected some songs; and here it is.
My favorites : Politik and Science (A C64 version of Coldplay’s the Scientist), Morphing and Turbo. Yes, I love Dane’s tunes!
There’s no code yet, as this is still very rough and unfinished work. I’m pretty sure that when I get time again, I’ll have a go at LibSidPlay instead, since the overall emulation in that library is a lot better.