The XM File Format

Original Documentation

The .XM files (Extended Module) are multichannel MOD files created by Triton's
FastTracker ][. They feature up to 32 channels and different effects. FT 2 is
a shareware program. After the initial .XM header follows the pattern data,
after the patterns follow the instruments.

OFFSET              Count TYPE   Description
0000h                  17 char   ID="Extended module: "
0011h                  20 char   Module name, padded with zeroes
0025h                   1 char   ID=01Ah
0026h                  20 char   Tracker name
003Ah                   1 word   Tracker revision number, hi-byte is major version
003Ch                   1 dword  Header size
0040h                   1 word   Song length in patterns
0042h                   1 word   Restart position
0044h                   1 word   Number of channels
0046h                   1 word   Number of patterns (< 256)
0048h                   1 word   Number of instruments (<128)
004Ah                   1 word   Flags :
								 0 - Linear frequency table / Amiga freq. table
004Ch                   1 word   Default tempo
004Eh                   1 word   Default BPM
0050h                 256 byte   Pattern order table

--- Pattern header
The patterns are stored as ordinary MOD patterns, except that each note is
stored as 5 bytes:

	  ?      1   (byte) Note (0-71, 0 = C-0)
	 +1      1   (byte) Instrument (0-128)
	 +2      1   (byte) Volume column byte (see below)
	 +3      1   (byte) Effect type
	 +4      1   (byte) Effect parameter

A simle packing scheme is also adopted, so that the patterns do not become TOO
large: Since the MSB in the note value is never used, it is used for the
compression.If the bit is set, then the other bits are interpreted as follows:

	  bit 0 set: Note byte ollows
		  1 set: Instrument byte follows
		  2 set: Volume column byte follows
		  3 set: Effect byte follows
		  4 set: Effect data byte follows

OFFSET              Count TYPE   Description
0000h                   1 dword  Length of pattern block/header ??
0004h                   1 byte   Pattern pack type
0005h                   1 word   Number of rows in pattern (1..256)
0007h                   1 word   Size of pattern data
					"PSZ" byte   Pattern data

--- Instrument header
Each instrument has one or more sample headers following it.
OFFSET              Count TYPE   Description
0000h                   1 dword  Instrument block/header size
0004h                  22 char   ASCII Instrument name, 0 padded ?
001Ah                   1 byte   Instrument type (always 0)
001Bh                   1 word   Number of samples in instrument
001Dh                   1 dword  Sample header size
0021h                  96 byte   Sample numbers for all notes
0081h                  48 byte   Points of volume envelope
00C1h                  48 byte   Points of panning envelope
0101h                   1 byte   Number of volume points
0102h                   1 byte   Number of panning points
0103h                   1 byte   Volume sustain point
0104h                   1 byte   Volume loop start point
0105h                   1 byte   Volume loop end point
0106h                   1 byte   Panning sustain point
0107h                   1 byte   Panning loop start point
0108h                   1 byte   Panning loop end point
0109h                   1 byte   Volume type, bitmapped
								 0 - Volume on
								 1 - Sustain on
								 2 - Loop on
010Ah                   1 byte   Panning type, bitmapped
								 0 - Panning on
								 1 - Sustain on
								 2 - Loop on
010Bh                   1 byte   Vibrato type
010Ch                   1 byte   Vibrato sweep
010Dh                   1 byte   Vibrato depth
010Eh                   1 byte   Vibrato rate
010Fh                   1 word   Volume fadeout
0111h                   1 word   Reserved

--- Sample headers
OFFSET              Count TYPE   Description
0000h                   1 dword  Sample length
0004h                   1 dword  Sample loop start
0008h                   1 dword  Sample loop length
000Ch                   1 byte   Volume
000Dh                   1 byte   Finetune for sample (-128..+127)
								 +-127 is one half tone
000Eh                   1 byte   Sample type, bitmapped
								 0,1 : Loop type :
										0 - no loop
										1 - forward loop
										2 - ping-pong loop
										3 - reserved
								   4?: sample is 16-bit
000Fh                   1 byte   Sample pan
0010h                   1 byte   Relative note number (signed byte)
								 (-96..+95), 0 -> C-4 sounds as C-4
0011h                   1 byte   Reserved
0012h                  22 char   ASCII name of sample, 0 padded
0013h               "LEN" byte   Sample data. The sample data is stored
								 as delta compressed data like the ProTracker.


This information is from and is used with permission.

More Resources