Amiga Protracker mod loader

I've been interested lately in writing some software to support mod music development. To put it briefly, mod music and the demoscene were a huge part of my adolescence from 19996-1999. While it has mostly faded from its glory days, I'd like to be able to do my part to keep it alive.

I've started by writing a mod file loader in Kotlin. I was originally planning on doing it for the Scream Tracker 3 format, but I decided it would be better to do it in a simpler format, and the obvious best choice for this is the Amiga Protracker format. This format uses the .mod file extension.

Now, there's a few things to know about these formats: first, they were not created by professionals. The demoscene was almost entirely driven by amateurs and enthusiasts, many of whom were teenagers at the time. As such, the formats don't have very well-structured standards, definitions, or documentation.

Secondly,  some of the formats are overloaded, particularly .mod - there were several tracker applications that could create mods and they all differed from each other slightly. So, some mods would play differently in some trackers compared to others.

Thirdly, the formats were generally optimized for space efficiency. The nature of demoscene was to squeeze as much performance as possible out of limited resources. This means they wouldn't use a 32-bit integer to store all the song metadata: so far, I have seen some data being stored all the way down to a 4-bit nibble. In the Amiga Protracker format, 32 bits can contain a reference to a note, a sample, and an effect command with two parameters. And they're not all stored consecutively, either: the sample, for example, is stored in the first four bits of the first byte and the third byte. You need to stitch them together. The second half of the first byte and all eight bits of the second byte contain the note to be played, and the second half of the third byte and all eight bits of the fourth byte contain the effect data (and there are some 35 different unique effects in this format, some of which use a single parameter, some of which use two parameters).

So far, I have successfully written software to load an Amiga Protracker mod and store it in an object, in Kotlin running on the JVM. The next challenge is getting it to actually play. I've never done audio programming before so I have a few things to learn here. I may take a look at existing libraries, such as micromod, to see what they offer.

I'm not sure what my eventual goal is here, but I have visions of creating a more modern library to support mod music playback. If I ever get into UI development, maybe I could create a player, or even a tracker with a more modern interface than OpenMPT. Maybe even a new mod format (I have visions of a format where the tracks are associated with the instrument and have built-in effect DSPs). But that's probably years in the future.

For now, I'm content to just work on developing software to support the existing formats and see if I can figure out how to get them to play.

Comments