Recent rediscovery of xmp and the amount of improvements on the player since then is proof that modplaying is still one of my obsessions favorite idle-time activities. Like coding, or reverse engineering file formats. Put them together, and what you get is a modplayer with support to strange file formats you possibly never heard of, such as STMIK (a precursor of Future Crew’s famous S3M format), MASI (used in some old DOS games such as Epic Pinball and Jazz Jackrabbit), DIGI Booster (Amiga), TCB Tracker (Atari) and so on. This time we had a different and intriguing challenge: a simple module format with a rather strange sound sample encoding. If you’re interested in retrocomputing, reverse engineering, investigative stories, or Python, read on.

It all started when looking for obscure trackers and this time Google sent me to the Arcade BBS tracker music archive. In my quest to find previously unknown tracker module formats I picked a few files at random and snooped inside them with bvi (a really great binary file viewer/editor). The one that drew my attention the most read:


00000000 4D 55 53 58 B4 FD 01 00 54 49 4E 46 04 00 00 00 MUSX....TINF....
00000010 90 19 11 19 4D 56 4F 58 04 00 00 00 04 00 00 00 ....MVOX........
00000020 53 54 45 52 08 00 00 00 05 03 03 05 05 03 03 05 STER............
00000030 4D 4E 41 4D 20 00 00 00 73 6F 75 76 65 6E 69 72 MNAM ...souvenir
00000040 20 6F 66 20 63 68 69 6E 61 00 00 00 00 00 00 00 of china.......
00000050 00 00 00 00 00 00 00 00 41 4E 41 4D 20 00 00 00 ........ANAM ...
00000060 43 6F 6E 76 65 72 74 65 64 20 66 72 6F 6D 20 41 Converted from A
00000070 6D 69 67 61 00 00 00 00 00 00 00 00 00 00 00 00 miga............
00000080 4D 4C 45 4E 04 00 00 00 1C 00 00 00 50 4E 55 4D MLEN........PNUM

It was immediately identifiable as a typical module in little-endian IFF format, with visible header, patterns and samples inside the file. A quick search for some of the chunk IDs revealed that it was an Archimedes Tracker file — yes, from the late 1980s Acorn Archimedes ARM3-based computer. It gave me even a format description, too easy. The format looked as simple as TCB tracker, whose loader was implemented in a couple of hours without any documentation. My test module also was a rendition of a well-known tune (Jean-Michel Jarre’s Souvenir of China) and, better yet, converted from a Protracker module I luckily had in my hands already. I coded the loader, it sounded like crap.

I quickly checked the usual suspects: sample size error, signed versus unsigned and reverse endianness. Also not RLE-encoded samples, since the size closely matched the Amiga version of the same file. The spec mentions logarithmic PCM samples, but it didn’t sound like µ-law played as linear PCM — it was more like ADPCM played as linear PCM, with some recognizable sounds amidst lots of noise. Inspecting the initial bytes from a sample you have:


Protracker: 2E E0 01 F0 F8 00 FD FE
Archimedes: D0 C3 30 A3 83 00 59 49

It didn’t look a linear relationship, or differential sampling. No obvious proportions or bit operations, and the 00 becoming 00 was very suspicious. Nibble inversion was a possibility since we had FD FE mapping to 59 49. Boto plotted a correlation graph between the value sets:

Amiga/Archimedes sample data correlation

The graph clearly showed us that we had a logarithmic relationship between the sets, but with something very strange happening with the sample signal. As is, the conversion wasn’t inversible at all. Experience shows us, however, that strange file formats usually are constrained by strange hardware architectures, especially in old machines where you didn’t want to waste CPU cycles converting data at each load. So, how did sound in the Acorn Archimedes work again? In the Audio File Formats file, version 2.5 dated 27-Aug-1992, Guido van Rossum tells us that

The Acorn Archimedes uses a variation on U-LAW with the bit order reversed and the sign bit in bit 0. Being a ‘minority’ architecture, Arc owners are quite adept at converting sound/image formats from other machines, and it is unlikely that you’ll ever encounter sound in one of the Arc’s own formats (there are several).

So let’s emphasize it: sign bit in bit 0. That’s a quite unusual way to encode PCM samples, whoever designed the Archimedes must have had a good reason to do that. Replotting the correlation between Amiga linear PCM as signed 8-bit samples and the Archimedes signal-adjusted samples, we get, as Guido predicted (except for the “bit order reversed” part), a very reasonable logarithmic 8-bit sample encoding that can be easily converted back to linear PCM.

Amiga/Archimedes signal-ajusted correlation

Adjusting the signal, converting the Archimedes logarithmic sample back to linear and plotting the converted values along the original Amiga signed linear PCM samples in time domain, we have an almost perfect match:

Original and converted samples

Which finally allows us to correcly play the samples from Archimedes Tracker modules with xmp. Acorn has some other formats I’d like to investigate further, such as Symphony, DTT and Coconizer. To be able to play most Acorn modules around it would be nice to have a built-in Spark decompressor as well. Need suport for a specific tracker music format you’d like to play? Contact me, implementing it could be fun.

5 Responses to “Archimedes and the bit 0”

  1. Fzero says:

    Você é meu ídalo. :-) Excelente leitura sobre criptoformatologia. Sim, eu inventei a palavra agora.

  2. Alan Robertson says:

    Hi there
    I am still an Acorn user who is into the tracker music scene, and have been for many years.

    The most sophisticated tracker player we had was !Digital Smphony which had its own native file format. It would be great to see it being supported on the pc.

    I am sure there is some documentation on the web around the !Digital Sympony format should you be interested.

    Nice work, and good to see people are interested in olf acorn technology!

    Alan

  3. claudio says:

    Hi Alan,

    Shortly after the !Tracker post I added support for Digital Symphony based on the version 0 format description by Bernard Jungen and Gil Damoiseaux, including LZW-compressed patterns and samples (using the LZW algorithms from Arc and ArcFS). Some of the multi-effects are not implemented and others (such as unset sample loop) are not supported by the player framework, but it can play most modules I found around reasonably well. Unfortunately I don’t have any insight on how to decode version 1 packed samples yet — I tried to match some popular algorithms with no luck. DTT is partially implemented, and I’m waiting for some Coconizer modules to code the loader as well.

  4. Denis says:

    I had an acorn/archimedes computer when I was young, and used to listen to the music from various games on it. One such game was Oddball, which had fantastic music.

    Unfortunately nothing seems to play the music of Oddball. After examining the contents of the MUSIC file from oddball, I worked out that it’s a archimedes tracker file. The problem is, it doesn’t seem to play in the most recent version of XMP.

    I’d appreciate it if you could examine the Oddball music file for me, since I’d really love to hear that music again.

    Email me and I’ll send you the file. I would post it here, but of course there’s no file upload mechanism and I don’t have any reliable webhosting.
    Or, you could go to google and search for “acorn oddball” and a zipped version of the game’s files would show up quickly.

    Either way, let me know if you have a look at it. Thanks.

  5. claudio says:

    Thanks for the comment. I’ll have a look and report back if I find something. The Archimedes Tracker support in xmp was built entirely on reverse engineering, so perhaps it has some detail I overlooked.

Leave a Reply