The sounds come last in the file. After the last pattern, the data of each sample follows in the order of the sample headers, sample 1 first, with nothing between them and no headers or lengths of its own: the lengths are in the sample headers.
Where each sample starts
The data begins where the patterns end:
start of sample data = 1084 + patterns × 1024
patterns = 1 + the highest number in all 128 order entries
sample n starts at = start of sample data + 2 × (length of samples 1 to n − 1)
Sample n is 2 × length bytes long. Samples with a length of 0 take no space. For example, a module whose order table names patterns 0 to 9, and whose first two samples are 7,000 and 3,000 bytes long, has sample 1 at 11,324, sample 2 at 18,324 and sample 3 at 21,324.
Encoding
Each byte is one sample point, a signed 8-bit number from −128 to 127, mono. No sample rate is stored: the rate depends on the note being played, as the period says, so the same data plays faster for a higher note: C-2 plays it at about 8,287 bytes a second and C-3 at about 16,574.
By convention the first two bytes of a sample are 0. ProTracker leaves the Amiga’s voice playing those two bytes after a sample without a loop has finished, so a zero there keeps the voice silent; see How it plays.
+0 00 00 05 12 26 3B 4A 52 51 47 35 1D 02 E8 D0 BD
E8 is −24, BD is −67)One rare variant stores differences instead. In files with the signature
M\0\0\0, from the Inconexia demo, each byte is added to the value before it,
starting from 0 and wrapping at 8 bits, to give the sample points (the delta PCM that
OpenMPT’s loader asks for); the explorer decodes them.
The explorer shows each sample as a waveform, with a Show button in the list of samples and on the sample’s bytes in the structure view, at the rate of note C-2.
ADPCM-packed samples
ModPlug Tracker could save a module with its samples packed, to about half their
size, in a 4-bit ADPCM of its own. OpenMPT reads any 31-sample module this way, of
any signature but Inconexia’s: it looks at the start of each sample’s data for the five
letters ADPCM, and if they are there the sample is packed:
| Offset | Size | Field | Meaning |
|---|---|---|---|
| 0 | 5 | marker | ADPCM |
| 5 | 16 | step table | 16 signed 8-bit steps |
| 21 | (points + 1) ÷ 2, rounded down | codes | two 4-bit codes a byte, the low one first |
The number of points is the sample length from the header, 2 × length. Each code picks
a step from the table, which is added to a running value that starts at 0 and wraps at
8 bits; each new value is one point. The next sample’s data follows straight after the
codes, so a reader that does not know the marker finds every later sample in the wrong
place. The rules are those of OpenMPT’s SampleIO.cpp and
Load_mod.cpp; ModPlug published no other description. The explorer
unpacks such samples, shows the marker, table and codes in the structure, and plays
them.
Short and long files
The file should end with the last byte of the last sample, but not every file does. In the files examined for this site, one ends a few bytes short of its last sample and others carry extra bytes after it, in one case 16 KB. A reader should take what is there rather than turn the file down: the explorer reads a sample cut short as far as the file goes and reports how much is missing.