-
Notifications
You must be signed in to change notification settings - Fork 59
XMF File Format
The original game uses a custom tracker file format (a file containing audio samples and instructions on when and how modulated to play them).
| Offset | Description |
|---|---|
| 0x000000 | Version number |
| 0x000001 .. 0x001000 | 256 x 16 bytes of audio sample registry. See Sample registry. |
| 0x001001 .. 0x001100 | 256 tracker section ids, an FF indicates end of sections and where to loop back |
| 0x001101 |
sample_count - 1 |
| 0x001102 |
tracker_section_count - 1 |
0x001103 .. + sample_count
|
Sample default balance. Left (0 .. 7 .. 15) Right. |
0x001103 + sample_count .. + sample_count * tracker_section_count * 0x180 |
The tracker instruction bytes. See Tracker Instructions |
0x001103 + sample_count + sample_count * tracker_section_count * 0x180 .. EOF |
The audio sample bytes. Sample registry to calculate boundaries. |
Our files have version 0x03 but the decoder has special path for setting the frequency for version 0x02.
For version 0x02
Frequency = Sample_Frequency / 64 + Some_Sample_Property_1 / 64
For version 0x03
Frequency = Sample_Frequency * Some_Sample_Property_1 / 8363 / 64
(where 8363 is a typical Amiga frequency number.)
| Offset | Description |
|---|---|
| 0x00 .. 0x02 | Sample playback shift relative to the start offset (24 bit little endian) |
| 0x03 .. 0x05 | Sample start relative shift (24 bit little endian) |
| 0x06 .. 0x08 | Sample start offset in memory (24 bit little endian) |
| 0x09 .. 0x0B | Sample end offset + 1 in memory (24 bit little endian) |
| 0x0C | Some flag |
| 0x0D | Control Flags |
| 0x0E .. 0x0F | Sample frequency in Hz |
A sample_size is offset 4 - offset 3.
The first sample starts at file offset 0x1103 + sample_count + sample_count * tracker_section_count * 0x180.
The next samle starts after the first sample's sample_size bytes.
The flags are directly sent to the Gravis Ultrasound Voice Control register
| Bit | Description |
|---|---|
| 0 | Voice Stopped (probably unused) |
| 1 | Force stop voice (probably unused) |
| 2 | Voice data type: 0 = 8 bit, 1 = 16 bit |
| 3 | Loop Voice |
| 4 | Bi-directional playback |
| 5 | Wave IRQ (probably unused) |
| 6 | Direction indicator: 0 = forward, 1 = backward |
| 7 | Pending IRQ (probably unused) |
A tracker is built up from sections. One section is sample_count * 6 * 0x180 bytes long. So one section holds 0x180 rows of instructions. Each row has 6 parameters for each sample_count samples.
| Offset | Description |
|---|---|
| 00 | Frequency shift indicator (i.e., note?) |
| 01 | Sample number (1-based) |
| 02 | Function 1 |
| 03 | Function 2 |
| 04 | Function 2 Subfunction |
| 05 | Function 1 Subfunction |