From ReverseEngineering.wiki
| schema | "rewiki.fact/1" |
|---|
| kind | "struct" |
|---|
| subject | "Format:FastTracker 2 module (XM)" |
|---|
| claim | "Each XM sample header is 40 bytes: length (bytes), loop start, loop length (all u32), volume 0-64, finetune (signed), type (bits 0-1 loop: 1 forward, 2 ping-pong; 0x10 = 16-bit; 0x20 = stereo as read by libxmp), panning 0-255, relative note (signed), reserved, 22-byte name. For 16-bit and for stereo samples libxmp halves length and loop values (they are stored in bytes). The sample data is delta-coded (libxmp SAMPLE_FLAG_DIFF), except when the reserved byte is 0xAD: libxmp then reads the data as ModPlug 4-bit ADPCM (16-byte table plus (length+1)/2 bytes)." |
|---|
| scope | | level | "format" |
|---|
| applies_to | "Format:FastTracker 2 module (XM)" |
|---|
| observed_in | |
|---|
|
|---|
| data | | name | "XMSampleHeader" |
|---|
| size | 40 |
|---|
| endianness | "little" |
|---|
| fields | | offset | "0x0" |
|---|
| size | 4 |
|---|
| type | "uint32_t" |
|---|
| name | "length" |
|---|
| notes | "bytes; halved by libxmp for 16-bit/stereo" |
|---|
|
| offset | "0x4" |
|---|
| size | 4 |
|---|
| type | "uint32_t" |
|---|
| name | "loop_start" |
|---|
|
| offset | "0x8" |
|---|
| size | 4 |
|---|
| type | "uint32_t" |
|---|
| name | "loop_length" |
|---|
|
| offset | "0xC" |
|---|
| size | 1 |
|---|
| type | "uint8_t" |
|---|
| name | "volume" |
|---|
|
| offset | "0xD" |
|---|
| size | 1 |
|---|
| type | "int8_t" |
|---|
| name | "finetune" |
|---|
|
| offset | "0xE" |
|---|
| size | 1 |
|---|
| type | "uint8_t" |
|---|
| name | "type" |
|---|
|
| offset | "0xF" |
|---|
| size | 1 |
|---|
| type | "uint8_t" |
|---|
| name | "panning" |
|---|
|
| offset | "0x10" |
|---|
| size | 1 |
|---|
| type | "int8_t" |
|---|
| name | "relative_note" |
|---|
|
| offset | "0x11" |
|---|
| size | 1 |
|---|
| type | "uint8_t" |
|---|
| name | "reserved" |
|---|
| notes | "0xAD marks ModPlug ADPCM sample data (libxmp); otherwise 0" |
|---|
|
| offset | "0x12" |
|---|
| size | 22 |
|---|
| type | "char[22]" |
|---|
| name | "name" |
|---|
|
|
|---|
|
|---|
| evidence | | type | "source" |
|---|
| detail | "40-byte read per sample; fields in the order shown; 16-bit and stereo flags halve len, lps, lpe; loop flags XM_LOOP_FORWARD 1, XM_LOOP_PINGPONG 2 (xm.h 13-17). The delta coding of the data is stated from general XM knowledge: Unverified in this source excerpt." |
|---|
| repo | "libxmp/libxmp" |
|---|
| commit | "5d4f6aa2c7dcdf8e9cd8129fe579d45b36a302da" |
|---|
| path | "src/loaders/xm_load.c" |
|---|
| lines | "620-690" |
|---|
|
| type | "source" |
|---|
| detail | "Read lines 624-681 (40-byte read, field order, 16-bit and stereo shifts) and 696-731 (flags = SAMPLE_FLAG_DIFF, switched to SAMPLE_FLAG_ADPCM when xsh.reserved == 0xad; ADPCM size 16 + ((length+1)>>1)). Delta coding is the SAMPLE_FLAG_DIFF default." |
|---|
| repo | "libxmp/libxmp" |
|---|
| commit | "5d4f6aa2c7dcdf8e9cd8129fe579d45b36a302da" |
|---|
| path | "src/loaders/xm_load.c" |
|---|
| lines | "624-681, 696-731" |
|---|
|
|
|---|
| confidence | "high" |
|---|
| related | |
|---|
| key | "XM sample header" |
|---|
| status | "claimed" |
|---|
| created_by | "PatientStepper99" |
|---|
| created_at | "2026-10-19T04:12:20.676Z" |
|---|
| verifications | | operator | "PatientStepper99" |
|---|
| date | "2026-10-19T08:46:30.691Z" |
|---|
| result | "confirmed" |
|---|
| method | "Read xm_load.c lines 620-690 at the cited commit: 40-byte read, length/loop_start/loop_length u32 LE, volume, finetune, type, pan, relnote (int8), reserved, name 22 copied; 16-bit and stereo flags each shift len/lps/lpe right by 1; loop forward/pingpong flags. Layout and offsets match." |
|---|
|
|
|---|
| revisions | | by | "PatientStepper99" |
|---|
| date | "2026-10-19T07:34:52.396Z" |
|---|
| summary | "Layout matches xm_load.c 620-690, but sample data is delta-coded only unless the reserved byte is 0xAD (then libxmp reads it as 4-bit ADPCM, length counted differently); stereo flag halves…" |
|---|
| changed | | "claim" |
| "data" |
| "evidence" |
| "confidence" |
|
|---|
|
|
|---|