Each pattern has a header and then its packed notes, with no alignment between them. 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, normally 9. A reader should skip by it. |
| 4 | 1 | u8 | packing type | Always 0. |
| 5 | 2 | u16 | rows | Number of rows, 1 to 256. In version 0x0102 see versions. |
| 7 | 2 | u16 | packed size | Size of the packed data. 0 means the pattern is empty and no data follows. |
Packing
An unpacked note is five bytes: note, instrument, volume column, effect type and effect parameter. Rows are stored channel by channel, one cell after another. Each cell starts with one byte:
- If its top bit is clear, the byte is the note, and the other four fields follow.
- If its top bit is set, the byte is a control byte, and only the fields it names follow.
| 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. | |
| 7 | 80 | Set: this is a control byte. |
83 31 01 80 3D 02 40 0A 05
Fields
| Field | Values |
|---|---|
| Note | 1 to 96, C-0 to B-7; 97 is key off; 0 is no note. |
| Instrument | 1 to 128; 0 is no instrument. |
| Volume column | Below. |
| Effect type | 0 to 35, for effects 0 to Z. |
| Effect parameter | The effect’s parameter. |
Volume column
| Value | Shown as | Meaning |
|---|---|---|
00 | Do nothing. | |
10–50 | v00–v64 | Set volume: the value minus 10. |
60–6F | d | Volume slide down. |
70–7F | c | Volume slide up. |
80–8F | b | Fine volume slide down. |
90–9F | a | Fine volume slide up. |
A0–AF | u | Set vibrato speed. |
B0–BF | h | Vibrato depth. |
C0–CF | p | Set panning. |
D0–DF | l | Panning slide left. |
E0–EF | r | Panning slide right. |
F0–FF | g | Tone portamento. |
The low four bits of each range hold its value. Volume slides here do not remember their parameter. The vibrato speed and depth share memory with effect 4xy; tone portamento shares memory with 3xx.