Development: Formats/XM

From OpenMPT Wiki
Jump to navigation Jump to search

General information concerning the XM file format.

Tracker IDs[edit]

Tracker should indicate their name in the XM header at offset 38.

Detecting other trackers[edit]

Some trackers disguise as FastTracker 2, but there are ways to uncover this diguise.

ModPlug Tracker (general)[edit]

ModPlug Tracker uses zero-padded strings rather than space-padded strings for sample, instrument and song names. Note that FT2 does not sanitize some fields, so it is possible that a file made with e.g. ModPlug Tracker and then re-saved in FT2 will still be detected as file made with MPT, as e.g. the song name will remain zero-padded.

ModPlug Tracker 1.0[edit]

Tracker ID is "FastTracker v 2.00" (mind the extra space). Instrument header size is either 245 (MPT 1.0 alpha) or 263 (MPT 1.0 beta).

ModPlug Tracker 1.x[edit]

ModPlug Tracker 1.09 (and maybe some older / newer version) sets both the "normal loop" and "ping-pong loop" flag for ping-pong-looped samples, while only the latter flag should be set.

DigiTrakker[edit]

Tracker ID starts with "*Converted ", instrument header size is 29.

Header size fields[edit]

The main header size is variable and can be shortened to not store the entire order list (256 bytes), but some less compatible players (e.g. WinAmp 5.666 and older) will choke on this. Thus, the most compatible way is to always write the entire order list.

The instrument header size (first field of the instrument header) must be respected, otherwise some files will not load correctly. If the size in the file is smaller than the actual header size, pad it with zeros. However, the sample header size is completely ignored by FastTracker 2. Early versions of Sk@leTracker wrote 0 in this field, and there are files in the wild with other, completely arbitrary values (e.g. cybernostra weekend.xm). Hence, ignore this value completely.

The mysterious "reserved" byte[edit]

In each sample header, there is a "reserved" byte right before the sample name. In fact, FT2 stores the sample name as a Pascal string, so the byte before the name tells the length of the string. FT2 always writes space-padded strings, but if the user manually adds space characters at the end of the sample name, they will count towards the string length, so it's not possible to simply compare the length byte against the string length after trimming space characters. Instead, we can probably be sure that a file was not made with FT2 if the actual string length is longer than the length indicated by the reserved byte, or if the reserved value is larger than 22.

ADPCM samples[edit]

The aforementioned reserved byte doubles as an indication for ModPlug 4-bit ADPCM samples: If its value is 0xAD and neither the 16-bit nor stereo flags are set, the sample uses ADPCM compression.

Stereo samples[edit]

ModPlug Tracker added support for stereo samples to the XM format, which is not part of the original format specifications. The sample data is stored like in most other module formats with stereo sample support: First the complete left channel, followed by the complete right channel. As with 16-bit samples, the length, loop start and loop length fields are doubled. Bit 5 of the sample flags (0x20) indicates the fact that it is a stereo sample.

OpenMPT Hacks[edit]

For a list of all the file format hacks that ModPlug Tracker / OpenMPT added to the XM format over the years, see the OpenMPT Format Extensions article.