Scream Tracker 2 Module

From MultimediaWiki
Jump to navigation Jump to search
  • Extension: stm

A 4-channel module format somewhat similar to Protracker/Amiga for MS-DOS on the PC.

File Format

The format is little-endian (least significant byte first). A "byte" is 8 bits, a "word" is 16 bits, and a "dword" (double word) is 32 bits. Hex values will be denoted with "0x". A parapointer is 16 bits wide, and points to pp*16 in the file due to the DOS nature of the format.

  • 20 bytes: Module name, NUL-padded.
  • 8 bytes: Magic string. It's best to just check if the entire string is printable ASCII.
    • !Scream! - The most common tag that's checked for
    • BMOD2STM - A MOD to STM conversion utility
    • WUZAMOD! - Currently unknown, any searches for references just yields other players supporting the string...
    • SWavePro - SoundWave Pro
    • !Scrvrt! - RepellantMold's S3M to STM converter.
  • Byte: Usually 0x1A, though 2 files were spotted to have 0x02 instead. ST3 checks the field while ST2 doesn't.
  • Byte: File type, 1 is song (no samples) and 2 is module (has samples)
  • Byte: Major file version (x), usually 2
  • Byte: Minor file version (yy), usually 21

I'll be referring to file version as x.yy from here on out, also note that the file version does not mean tracker version!

  • Byte: Initial tempo
  • Byte: Pattern count (range 1 <= x <= 63)
  • Byte: Global volume (range 0 <= x <= 64)
  • 13 bytes: Reserved
  • 31 instruments:
    • 12 bytes: DOS File name, NUL-terminated
    • Byte: Reserved (always 0)
    • Byte: Instrument disk (range 0 <= x <= 99)
    • Word: Parapointer to sample data (annoyingly, ST2's TECH.DOC marked this as reserved which no doubt caused a lot of confusion!)
    • Word: Length in bytes
    • Word: Loop start in bytes
    • Word: Loop end in bytes (0xFFFF means to never loop, ST2 also does not sanitize the loop end field so it can go beyond length!)
    • Byte: Default volume (range 0 <= x <= 64 - 0 is undefined behavior in ST2 and will make the parapointer point in a random spot if the length is not blank, which no doubt made tools struggle if they had relied on guessing based on the "guess" method for grabbing samples)
    • Byte: Reserved
    • Word: C speed
    • 6 bytes: Reserved
  • 128 bytes or 64 bytes if the file version is 2.00: Order list - 99 means no pattern, though a single 255 can also be seen. Any orders that are above the pattern count should be treated as blank patterns, and patterns above 63 are undefined behavior.
  • Pattern data:
    • You read one byte
      • if the byte is 0xFB, 0xFC, or 0xFD then define instrument, volume, effect to be blank values or 0 in the case of 0xFB and skip. If it's any other value then read the next 3 bytes.
    • A regular pattern cell has the format of 4 bytes, represented in bits as oooonnnn iiiiivvv VVVVeeee xxxxyyyy
      • oooo is the notes octave, (0 - 4, all other values play nothing), nnnn is the notes pitch (0 - 11, all other values display as garbage and play nothing).
      • iiiii is instrument, 0 - 31, 0 is a blank cell.
      • VVVVvvv is the volume (0 - 127, 65 means empty, other values overflow ST2's volume table and display as "??")
      • eeeexxxxyyyy is the effect, eeee is the effect type while xxxx and yyyy is the effect parameter.
    • Rinse and repeat for 4 channels and 64 rows!
  • Signed 8-bit mono sample data, padded to the nearest 16 bytes

Playback notes

Tempo is rather bizarre in Scream Tracker 2, as it has speed (ticks per row in other trackers) in the high nibble then then a scaling factor in the low nibble. If the minor file version is <= 20, then this is in decimal, as in the "speed" will be in the tens digit with scale being in the ones digit with a range of 0 to 9. Speed gets clamped to 1 if it has a value of 0. The actual tempo is also dependent on the mixing rate (which in ST2 will either be 5000, 6500, 8000, 9943, 11932, 13000, 15909, 17045, 19886, or 23863 Hz).

TODO: Either get a table of all possible speeds, or show the formula

Effects

All effects are treated as no-op if the parameter is 0x00.

Effects are displayed as letters (A, B, C, ...) rather than numbers (1, 2, 3, ...). The entire range is from A to O but only A and J have any kind of functionality, other values may bug out tools or even Scream Tracker 3!

Axy

Set tempo to x per row with a scale of y. If the file version has a minor version less than 21, e.g. 2.20, then it's in decimal (like 60 rather than 0x60).

Bxx

Set next order, this effect does not break the pattern immediately.

Cxx

Break to the next pattern, parameter is ignored.

Dxy

Volume slide. Identical to Scream Tracker 3, however fine slides do not exist.

Exx

Slide down. Identical to Scream Tracker 3, however fine slides do not exist. It also has the odd quirk of having the ability to underflow to a really high note if

Fxx

Slide up.

Gxx

Slide to note. If a sample is specified without volume, the volume does not get reset to its default setting.

Hxy

Vibrato. Depth is doubled when compared to other trackers!

Ixy

Tremor. Identical to Scream Tracker 3, sans effect memory resulting in 0 being very fast.

Jxy

Arpeggio. This effect was implemented rather late, being implemented starting ST2.24. This effect is rather bugged as it skips to y halfway through a row if x is 0.