Tag Archives: libgme

Retro tunes with Phonon

So, in The Beginning, when I was just a young padawan on the Internet, I had been let into a glorious secret: Emulation (not of IBM System/360 machines, but of more important things like the Super NES). Some branching from there led me to zophar.net, a popular emulation site, and their message boards, and also left me with a fascination with emulation.

The attributes of some of the older systems like the NES and Super NES made it fairly easy to capture their music-producing software, since those systems used separate co-processors to handle music effects. NES music would be stored in the NSF format, and SNES music was handled with the SPC format (named after the audio chip used, the Sony SPC700). There were (and still are) specialized plugins on many systems to play these formats (they emulated only the music chip, not the rest of the system).

I’ve been involved on the periphery of some of these things for the past couple of years. (For instance I had written a KFileMetaInfo plugin for KDE 3, and had helped Chris Lee with adding playback support to GStreamer.

One problem with the previous GStreamer solution (which I’ll call gst-spc) is that the underlying playback library, libopenspc, is written in x86 assembly, and has some crash bugs associated with it as well. As well the code has long been orphaned. I’m not really any good at writing emulation code and although I could learn, it would take far too much time for me to do anything useful.

Luckily for me the state of the art has advanced and last year I was pointed to a library called game-music-emu. This library included a very good SPC emulator written in C++, which had been merged into some popular SNES emulators already. Unfortunately it didn’t really have a great build system (using it involved simply copying it into your existing program) so my initial proposal to port GStreamer to use game-music-emu by simply including the source files with GStreamer was rejected. The GStreamer devs preferred to have an external library which could be used (or not) and I couldn’t blame them since in general good OSS projects avoid copying or forking external code.

So I contacted the game-music-emu author (Blargg) asking about the possibility of adding support for building a library, and ended up with commit access and an invitation to do it myself. Hmm.

So I did, and awhile ago I had made a release of “libgme” 0.5.5, working with Blargg has he got free time. My subsequent patch to GStreamer was accepted and since gst-plugins-bad-0.10.14 it has been possible to use libgme to playback many emulated music file types (not just SNES, but others as well).

With that solved I left the issue, but I recently came back to it since I figured out that even after upgrading to gst-plugins-bad-0.10.17 the other day, that gstreamer playback was not using libgme, but the older libopenspc.

At first I thought it was simply my fault, as I’d still had gst-spc installed from years and years ago. Removing gst-spc and libopenspc (just to be double-sure) left me with no SPC playback features. Running gst-inspect confirmed I did not have any gme decoder. WTF.

I then again thought it was my fault because I had installed libgme to /usr/local instead of /usr. So I dutifully wrapped up libgme in an ebuild and installed it. And still nothing. WTF.

I dug into the Gentoo ebuild for gst-plugins-bad and it seems that for whatever reason not all possible plugins are installed. It seems the new installation method is supposed to be that each individual plugin is supposed to have its own ebuild (i.e. gst-plugins-gme), like how Gentoo has split out other packages like KDE into individual ebuilds. Fair enough.

I write another ebuild, and finally hit paydirt:

Screenshot of music player playing SPC files
The Qt example music player playing SPC files

Obviously this does require that you are using the GStreamer backend for Phonon to have this work, otherwise you can just try it in some other GStreamer-using application. (I’d show it in JuK but I’d have to add SPC support to Taglib first)

If you’re interested in the ebuilds I used you can use this Portage overlay, (SHA-512 sum c0ff9aa5413b0c0b14f7c52d5b3ee887edc4e7bf47182e58c21e9c340d8ff7e9). The overlay may or may not work for you, and I don’t even know if overlays are still the “hip” way to do things in Gentoo, but It Works For Me. ;)

Status update

Since I haven’t blogged in awhile I thought I’d give an update as to what I’ve been doing in the past month or so:

  • This is only tangentially related to KDE at best but I’ve been pushing to get an improved video game music emulation library supported by GStreamer. The library in question is simply called Game Music Emu (or libgme depending on where you’re looking ;). It is an all-in-one emulation framework allowing for decoding and playback of Super NES, NES, Sega MegaDrive/Genesis formats and more. This has ended up with me having commit access to libgme and fostering a mini-revival by the library author to turn it into a proper library. Based on this work, the GStreamer devs have applied my patch to use libgme and then improved my patch several times from there. The next releases of gst-plugins-bad (for SNES SPC, etc. playback) and gst-plugins-base (for the typeinfo fixes) will be able to make use of these changes. JuK requires TagLib support to add files to a collection so even if you use phonon-gst you’ll still need to use a separate player to test it out though (Qt’s example musicplayer is perfectly sufficient though).
  • I haven’t forgotten about kdesvn-build’s git support (it’s actually there, but not plugged into anything other than qt-copy). My major hiccup has been handling the case where the user changes the “repository” option on me (especially with regards to qt-copy). I may just punt and make the user manually do it since I’m not sure what the best way is to switch over the remote tracking options in git (i.e. make git pull work from the new repository from now on)
  • I’m trying to get started in a Master’s degree program for a M.S. in Computer Science. I’ve taken the required entrance exam (the GRE) and although I’ll not post the exact scores I will say I did well (and without studying to boot. I tried to study but couldn’t get the “PowerPrep” software to work in Wine). It’s been a bit of a special case for me as I was a couple of weeks past the deadline due to the timing of showing up at my present command, but I think everything will work out to start ASAP.
  • If you’re just getting started with KDE 4.3 and you start seeing dialogs warning about being about to start executing a file, that’s by design. I’ve heard of a bug where dragging a working desktop link will make an “unsafe” desktop link since the destination doesn’t fall under the same exemptions as the old location which I may try to look into. Just remember that this is for your own good, and is a one-time only dialog per file! If you are writing your own .desktop links which you want to launch applications, just make sure to set it as executable.
  • Finally I’m going to be putting an old unused computer of mine to good use and setting it up for my 2.5 year old son. He enjoys computers too much, now it’s time for him to click on his instead of mine and my wife’s! ;) So I’d prefer it to have a guest account arrangement on super-lockdown (no Web, edu games, paint applets, etc. available, locked or healing desktop, that kind of thing). Any suggestions for KDE-friendly distributions for this kind of thing? I’m trying to keep download size for the install media under 1 GB.