Each pattern has a header and then its packed cells, with no alignment between them. In version 1.04 the patterns follow the file header and come before the instruments; in 1.02 and 1.03 they come after the instruments. The number of patterns is in the file header. Numbers are little-endian.
Pattern header
| Offset | Size | Type | Name | Description |
|---|---|---|---|---|
| 0 | 4 | u32 | header length | Length of this header: 9 (8 in version 1.02). The packed data starts that many bytes after the header's first byte, so a reader skips by it; a value above 9 leaves extra bytes before the data, a value below 9 is read as 9 by FT2 and the clone. |
| 4 | 1 | u8 | packing type | Always 0. No other type is known. |
| 5 | 2 | u16 | rows | Number of rows, 1 to 256. Version 1.02 stores one byte holding rows − 1 instead (see versions). 0 is read as 64 by OpenMPT and the clone; above 256 is cut to 256. |
| 7 | 2 | u16 | packed size | Size of the packed data after the header. 0 means the pattern is completely empty and no data follows. |
An empty pattern still has a header with its row count. FastTracker 2 and the clone write 64 rows for every empty pattern, and the clone reads any empty pattern as 64 rows whatever the header says. OpenMPT and libxmp keep the header's row count, as the explorer does, so a module from another tracker with an empty pattern of 32 rows plays 32 rows here and 64 rows in the clone.
Packing
An unpacked cell is five bytes: note, instrument, volume column, effect type and effect parameter. The rows are stored one after another, and within a row the cells of channel 1, then 2, and so on to the last channel. The packed form shortens each cell. Its first byte decides:
- If its top bit is clear, the byte is the note, and the other four bytes follow: the cell is five plain bytes, as if it were unpacked.
- If its top bit is set, the byte is a flag byte, and only the fields it names follow, in the order below. Fields that are not named are zero.
| Bit | Value | Meaning when set |
|---|---|---|
| 0 | 01 | A note byte follows. |
| 1 | 02 | An instrument byte follows. |
| 2 | 04 | A volume column byte follows. |
| 3 | 08 | An effect type byte follows. |
| 4 | 10 | An effect parameter byte follows. |
| 5–6 | Unused; readers ignore them. | |
| 7 | 80 | Set: this is a flag byte, not a note. |
An empty cell is the single byte 80. FastTracker 2 writes the cells packed
like this; OpenMPT and other trackers may also write plain five-byte cells, so a reader
must handle both in one pattern. The largest pattern (256 rows of 32 channels) is
40,960 bytes unpacked, which is more than the 16-bit packed size can hold: a full one
cannot be stored without packing.
The cells of a pattern may stop before the packed data does, in which case the extra bytes are not used, or the packed data may stop before the cells do (libxmp's tests list fourteen released modules with such cleanly truncated patterns). The rest of the cells are then empty, as every loader treats them.
Worked example
The start of the first pattern of a real song by FastTracker 2 (four channels, 64 rows, header at offset 336):
00000150 09 00 00 00 00 40 00 60 02 83 3D 01 83 3D 04 83 3D .....@.`..=..=..=
00000160 02 83 38 03 80 80 80 83 3A 03 81 61 87 3D 04 20 ..8.....:..a.=.
00000170 80 83 41 03 80 83 3D 04 83 3D 02 83 38 03 ..A...=..=..8.
| Bytes | Meaning |
|---|---|
09 00 00 00 | header length 9 |
00 | packing type 0 |
40 00 | 64 rows |
60 02 | packed size 0x0260 = 608 bytes |
83 3D 01 | row 0, channel 1: flags 83 (note and instrument), note 0x3D = 61 = C-5, instrument 1 |
83 3D 04, 83 3D 02, 83 38 03 | channels 2 to 4: C-5 with instrument 4, C-5 with instrument 2, G-4 with instrument 3 |
80 80 80 | row 1, channels 1 to 3: empty cells |
83 3A 03 | row 1, channel 4: A-4 with instrument 3 |
81 61 | row 2, channel 1: flags 81 (note only), note 0x61 = 97: key off |
87 3D 04 20 | row 2, channel 2: flags 87 (note, instrument and volume), C-5, instrument 4, volume column 0x20 = volume 16 |
80, 83 41 03 | row 2, channels 3 and 4: empty, then E-5 with instrument 3 |
Fields of a cell
| Field | Values | Notes |
|---|---|---|
| Note | 1 to 96: C-0 to B-7. 97: key off. 0: none. | Above 97 is invalid; the FT2 clone treats it as none. FT2 shows the key-off note as ==. |
| Instrument | 1 to 128; 0 is none. | Above 128 is invalid and read as none by the clone (OpenMPT reads 255 as none). An instrument with no note changes the volume and panning to the instrument's defaults; see playback. |
| Volume column | Below. | |
| Effect type | 0 to 35: effects 0 to 9 and A to Z. | Above 35 is invalid; the clone clears the effect and its parameter. See effects. |
| Effect parameter | 0 to 255. | Meaning depends on the effect. Effect 0 with parameter 0 is no effect; effect 0 with another parameter is arpeggio. |
The format description (xm.txt) is inconsistent here: its pattern section says the note is 0 to 71 with 0 = C-0, and its period section says the pattern note is 0 to 95 with 0 = C-0 and 95 = B-7. Files store 1 to 96, with 0 meaning no note; xm.txt does not mention the key-off note 97 at all (it lists a key-off effect, K). It also says the instrument is 0 to 128 and the effect type is stored as a byte, and that the most significant bit of the note byte, never used by a note, is the packing flag. The packed form and its five flag bits match the table above (xm.txt: “bit 4 set: Guess what!”, the effect parameter).
Note 1 is C-0 and note 96 is B-7. The name of a note is its letter, a sharp or a dash, and the octave, so note 49 is C-4 and plays at 8,363 Hz for a sample with relative note 0 and finetune 0. The note plus the sample's relative note (see sample header) gives the pitch, which can be outside 1 to 96 (from −47 to 167 with the relative note clamped to −48 to 71 as the clone does). A pitch below 0 or above 119 is not played; a pitch of exactly 0 starts the sample without changing the period.
| Note | 1 | 13 | 25 | 37 | 49 | 61 | 73 | 85 | 96 | 97 |
|---|---|---|---|---|---|---|---|---|---|---|
| Name | C-0 | C-1 | C-2 | C-3 | C-4 | C-5 | C-6 | C-7 | B-7 | key off |
Volume column
One byte that sets the volume or runs a small effect. FastTracker 2 reads it before the effect column on every row. The values 10 to 50 set the volume, 0 does nothing, and from 60 up the high nibble is a command and the low nibble its value. Every command is described on the effects page.
| Value | FT2 shows | OpenMPT shows | Meaning |
|---|---|---|---|
00 | Do nothing. | ||
01–0F | Invalid; ignored. | ||
10–50 | 10–50 (hex) | v00–v64 | Set volume: the value minus 10, 0 to 64. |
51–5F | 51–5F | Invalid: FT2 sets volume 64. | |
60–6F | -x | dx | Volume slide down. |
70–7F | +x | cx | Volume slide up. |
80–8F | Dx | bx | Fine volume slide down. |
90–9F | Ux | ax | Fine volume slide up. |
A0–AF | Sx | ux | Set vibrato speed. |
B0–BF | Vx | hx | Vibrato with depth x. |
C0–CF | Px | px | Set panning. |
D0–DF | Lx | lx | Panning slide left. |
E0–EF | Rx | rx | Panning slide right. |
F0–FF | Mx | gx | Tone portamento. |
The vibrato speed and depth share memory with effect 4xy and the tone portamento speed shares memory with 3xx; the volume slides here do not remember their parameter.
Damaged patterns
A pattern header that runs past the end of the file, a packed size larger than what is left, or cells that run past the packed data all occur in real files. The explorer shows the bytes that are there, marks the pattern as cut, and treats the missing cells as empty. A packed size of 0 with data after it is read as an empty pattern, so the data is taken as the next header, as every loader does.