An instrument is an 80-byte header found through the instrument parapointers. Its first byte is the type, and the fields that follow depend on it. Offsets are hexadecimal. Numbers are little-endian.
Instrument types
| Type | Meaning | Signature |
|---|---|---|
| 0 | Empty: a message only, with no sample data | – |
| 1 | Sample | SCRS |
| 2 | AdLib melody | SCRI |
| 3 | AdLib bass drum | SCRI |
| 4 | AdLib snare | SCRI |
| 5 | AdLib tom | SCRI |
| 6 | AdLib cymbal | SCRI |
| 7 | AdLib hi-hat | SCRI |
Scream Tracker reportedly loads files that lack the signature, so a reader should not insist on it.
Sample instrument
| Offset | Size | Type | Name | Description |
|---|---|---|---|---|
| 00 | 1 | u8 | type | 1. |
| 01 | 12 | text | filename | DOS 8.3 file name. |
| 0D | 3 | u24 | MemSeg | Parapointer to the sample data, in a mixed byte order (see below). |
| 10 | 4 | u32 | Length | In bytes. Scream Tracker uses only the low 16 bits and clips files above 64,000 bytes. |
| 14 | 4 | u32 | LoopBegin | Low 16 bits used. |
| 18 | 4 | u32 | LoopEnd | One past the last byte played in the loop. Low 16 bits used. |
| 1C | 1 | u8 | Vol | Default volume, 0 to 64. |
| 1D | 1 | u8 | reserved (TECH.DOC: Dsk) | 0 in Scream Tracker files. Advanced DigiPlayer 3.0 writes 2 here when it saves the sample packed (DP30ADPCM, below). |
| 1E | 1 | u8 | Pack | 0 unpacked, 1 DP30ADPCM, 4 ModPlug Tracker’s ADPCM. Scream Tracker 3.01 does not use packing, Scream Tracker 3.21 does not look at this byte. DP30ADPCM is what TECH.DOC calls value 1, but Advanced DigiPlayer 3.0 leaves this byte 0 in the files it saves and marks packed data at byte 1D instead. |
| 1F | 1 | u8 | Flags | |
| 20 | 4 | u32 | C2Spd | Frequency for middle C. Low 16 bits used. |
| 24 | 12 | – | internal | Scream Tracker uses these bytes only in memory, for the Gravis address, Sound Blaster loop flags and last-used position. The Gravis address is saved as it was: with the Sound Blaster driver loaded it is 1 for every used sample (a zero becomes 1, St3.exe 0x2bc9e to 0x2bcdc), with the Gravis driver it is the sample’s card memory address divided by 32 (0x307dc), so each sample has its own. If the addresses of a file made by Scream Tracker 3 combine (OR) to more than 1, it was last saved with the Gravis driver. |
| 30 | 28 | text | sample name | Includes the terminating zero byte. |
| 4C | 4 | ASCII | signature | SCRS. |
MemSeg
Sample data is found with a 24-bit parapointer split across the 3 bytes at
0D: the first is the top byte, and the next two are the middle and low
bytes, little-endian. In other words, the file offset is
((byte 0 × 65536) + (byte 1) + (byte 2 × 256)) × 16.
Sample flags
| Bit | Value | Meaning when set |
|---|---|---|
| 0 | 1 | Loop on. |
| 1 | 2 | Stereo: left data, then right data, each Length bytes. Not supported by Scream Tracker 3.01. |
| 2 | 4 | 16-bit little-endian samples. Not supported by Scream Tracker 3.01. |
The header’s Ffi field says whether samples are signed (1, very old) or unsigned (2).
AdLib instrument
| Offset | Size | Type | Name | Description |
|---|---|---|---|---|
| 00 | 1 | u8 | type | 2 for melody, 3 to 7 for percussion. |
| 01 | 12 | text | filename | DOS 8.3 file name. |
| 0D | 3 | – | reserved | Zero. |
| 10 | 12 | bytes | D00–D0B | The OPL operator parameters. |
| 1C | 1 | u8 | Vol | Default volume. |
| 1D | 3 | – | reserved | TECH.DOC calls byte 1D “Dsk” without describing it. |
| 20 | 4 | u32 | C2Spd | Scales the note frequency sent to the AdLib. Low 16 bits used. |
| 24 | 12 | – | reserved | |
| 30 | 28 | text | sample name | Includes the terminating zero byte. |
| 4C | 4 | ASCII | signature | SCRI. |
OPL parameters (D00 to D0B)
The modulator uses D00, D02, D04, D06 and D08; the carrier D01, D03, D05, D07 and
D09; D0A belongs to both. The bytes are the contents of the registers of the OPL2 chip (YM3812) of an AdLib card:
libopenmpt’s OPL.cpp writes D00 and D01 to registers 20 + the operator’s offset, D02 and D03 to 40, D04 and
D05 to 60, D06 and D07 to 80, D08 and D09 to E0, and D0A to C0 + the channel, and the AdLib driver of
St3.exe (0x2dc9b to 0x2dfd2) uses D02, D03 and bit 0 of D0A in the volume registers the same way. Where
TECH.DOC marks a bit with a question mark, the register layout of the chip gives its meaning: the explorer’s replay of
these instruments through a port of the Opal chip emulator matches libopenmpt’s output to the last bit
(NOP.s3m of its test suite).
| Byte | Meaning |
|---|---|
| D00, D01 | Bits 0 to 3: frequency multiplier. Bit 4: envelope scaling (key scale rate). Bit 5: sustained sound (the note holds at its sustain level until key off). Bit 6: pitch vibrato. Bit 7: volume vibrato (tremolo). |
| D02, D03 | Bits 0 to 5: the operator’s attenuation, 63 minus the volume. Bits 6 and 7: key scale level, how much the operator’s level drops towards the high notes (0 none, 1 1.5 dB an octave, 2 3 dB, 3 6 dB). |
| D04, D05 | Bits 4 to 7: attack rate. Bits 0 to 3: decay rate. |
| D06, D07 | Bits 4 to 7: sustain level, stored as 15 minus the level. Bits 0 to 3: release rate. |
| D08, D09 | Waveform select, 0 to 7 (the OPL2 has the first four). |
| D0A | Bits 1 to 3: feedback of the modulator. Bit 0: connection, 0 for FM (the modulator drives the carrier), 1 for additive (the two are added). Bits 4 and 5 are set by the program when it plays the instrument (left and right outputs). |
Sample data
Sample data is Length bytes at the MemSeg parapointer for 8-bit mono, the only form Scream Tracker itself plays. It is signed or unsigned according to the header’s Ffi field. With the 16-bit flag Length counts samples and each takes two bytes (little-endian, signed or unsigned in the same way); with the stereo flag the left channel’s data comes first and the right channel’s data after it, Length samples each (libopenmpt and libxmp read them so; TECH.DOC says “bytes” and shows the flags as not supported by Scream Tracker 3.01).
Scream Tracker 3.21’s loader (the routine at file offset 0x191AE of St3.exe, the loop at 0x196E8) reads
an instrument of type 1 whose MemSeg is not 0 by seeking to the position the MemSeg gives and reading Length bytes
(the length as a 32-bit number), and for a file with Ffi 1 calls a routine that converts the data (read at file offset 0x1F339: it adds 0x80 to each of the first Length bytes, the low 16 bits of the length, which turns a signed byte into an unsigned one; a sample with no data pointer is left alone). It never looks at
the Pack byte or the stereo and 16-bit flags, so the program has no code that unpacks DP30ADPCM data; the program’s
saver stores Pack as it found it. An instrument of a type above 1 gets no sample data. When the program saves, it
changes a volume above 64 to 64, a length above 64,000 to 64,000 and puts loop points back in range (0x1e285).
DP30ADPCM is what Advanced DigiPlayer 3.0 saves only when a switch with no button on the main screen is set (the eleventh byte of its settings file DIGIPLAY.SET,
0 as shipped; the save routine writes 2 at header byte 1D and leaves Pack at 0 when it is 1, and the loader tests byte 1D
for 2 and never looks at Pack). TECH.DOC’s
Pack value 1 names the same packing, so the explorer reads either mark. A sample file saved by DigiPlay 3.0 itself,
run in an emulator, has 2 at 1D, Pack 0, the length in frames and floor(frames / 2) data bytes (for an odd length the last
code is not stored), and decodes to within three of the original sample. The sample is half a byte a frame, low nibble first. Each
nibble indexes the table 0, 1, 2, 4, 8, 14, 24, 45, 0, -1, -2, -4, -8, -14, -24, -45 and adds it to a running value that
starts at 128 and stays within 0 to 255; the value less 128 is the signed 8-bit sample. Length in the header counts frames,
not bytes.
The Pack byte value 4 is not Scream Tracker’s: ModPlug Tracker writes it for a sample packed with its own ADPCM (a 16-entry table of deltas followed by 4-bit values), which libopenmpt and libxmp read and the explorer decodes with the same method as for its XM files.