Playing music

The year is 2005, a game called Guitar Hero comes out and makes 2006 the year when music games become mainstream worldwide. Surfing on the wave then came Rock Band in 2007 and you could play more than just the guitar, but also have other instruments including a drum kit!

Rewind to 1997, Konami started releasing series of musical games of various kinds under the Bemani umbrella. Those were a huge hit in Japan and in 1999 came the first releases of the GuitarFreaks and DrumMania games that could be played together and became mainstream in Japan many years before the rest of the world would enjoy music video games.

I remember back when Guitar Hero came out, some people would smugly remark how pointless those games were and how you’d be better off learning the real instruments in the first place. Living in France, I could always reply that they should stop playing football (soccer) on their home console and just play on the field. That would usually make my point, but I digress.

Thanks to a friend I discovered the Bemani games but unfortunately it was quite expensive to import any of it so the best I could afford was one game, one guitar controller and one drum kit controller. I couldn’t afford a Japanese PlayStation so instead I modded the one I already had and all was fine.

Playing actual music

Soon after that same friend enrolled me in an actual band and I learned the hard way the difference between arcade and simulation. It turns out playing drums involves more than hitting the right drum or cymbal at the right time. But that’s why those games are successful. You don’t need to learn an actual instrument to play or cover songs, you’re supposed to have fun!

So I kept having fun with a GuitarFreaks and DrumMania clone available for Windows. The final piece of hardware I needed was a PS1 to USB adapter and suddenly I had access to more songs than just the ones present on the one game I purchased.

I eventually moved to a place where there was not enough space to keep the game controllers or an electronic drum kit around and moreover ditched Windows in favor of Fedora, because free software. So all I was left with was an actual band enabling me to compose and play actual drum scores, poor me.

Enter xadec.dll

Years have passed and soon I should have enough space to take my electronic drum kit out of its box every now and then and the very thought made me research this topic lost in time.

It turns out the game I was playing at the time is open source! I wouldn’t have guessed that I could actually get the source code for DTXMania but yes, it is available. But no luck, it builds only for Windows and doesn’t run in Wine.

After a quick search, I came across DigiBand, another GuitarFreaks and DrumMania clone that can even play DTXMania songs. Sadly the project looks dead and I haven’t tried to build it yet because at first glance it looked like a painful process (at least on Fedora).

Then my butterfly senses triggered when I read a disturbing note in the cook book for Windows:

To play alot of the already existing songs for DigiBand, you will need XA decode. XA decode is a decoder written by a Japanese programmer for an application called bandjam. It has long gone extinct, however DTXMania, Session stream, and DigiBand all require the use of XA Decode so the developer released the XA decoder as a binary only library. This is why XA will not work for DigiBand under linux. We are however, moving to deprecate this library with the use of OpenAL. The XA format was originally used because MP3 and wav had inconsistant overhead and latency when playing back on demand.

I checked in the DTXMania code repository and there is indeed a xadec.dll library bundled with the rest of the code. So apparently a 32bit DLL became crucial but its source code was lost because bandjam (another GuitarFreaks and DrumMania clone) was not open source when it disappeared.

So that’s how I decided to take a stab at it. I would try to undo a wrong and at least give the opportunity to DTXMania to ditch xadec.dll and enter the 64bit world. Who knows, maybe then I will be able to run it in Wine?

This is a good example of why free software and open standards matter. By reverse engineering xadec.dll I was able to confirm its focus on latency, but I think another goal was compression and because the PlayStation already had its own XA format I’m guessing that having a different audio codec may have been a requirement to prevent piracy (with the usual effectiveness) because of licenses involved in a music game with lots of titles. Considering the hardware capabilities of the first PlayStation I wouldn’t be surprised if this was actually the format found in the games rather than a thing the bandjam developer came up with.

In the next posts of this series on xadec.dll I will share the results of my very first reverse engineering journey.