Development: Formats/S3M

From OpenMPT Wiki
Jump to navigation Jump to search

General information concerning the S3M file format. Variable names and hexadecimal numbers (in little-endian formats) are indicated by a monospace font.

Tracker IDs[edit]

The S3M header contains a field, Cwt/v, which is used to identify the application that was used to create the file. The following custom tracker IDs (read as little-endian hexadecimal numbers) are known to be found in the Cwt/v field:

  • 0208 - Found in some tracks by Yerzmyey, appears to be from a tracker called Akord (Polish localized version of a tracker called Squeak Tracker)
  • 1xyy - Scream Tracker x.yy - Many other trackers, like ModPlug Tracker, disguise as Scream Tracker 3.20, so this is not a reliable way to tell if a file was really made with Scream Tracker, see below.
  • 2xyy - Imago Orpheus x.yy
  • 3xyy - Impulse Tracker x.yy
  • 4xyy - Schism Tracker x.yy up to Schism Tracker v0.50, later versions encode a timestamp in the version number - see Schism Tracker’s version.c or OpenMPT’s Load_it.cpp for a version not relying on the C runtime library (since localtime is not guaranteed to be thread-safe).
  • 5xyy - OpenMPT x.yy - lower two bytes of version number are stored in the two reserved bytes at offset 54 starting from OpenMPT
  • 5447 - Graoumf Tracker (appears as "GT" magic bytes on disk)
  • 6xyy - BeRoTracker x.yy
  • 7xyy - CreamTracker x.yy
  • CA00 - Camoto / libgamemusic
  • 2013 - PlayerPRO on little-endian platforms

Note: BeRoTracker used the ID 4100 since 2004, but has switched to using the 6xyy scheme in 2012. Luckily, this version is not used by Schism Tracker, so it is still possible to tell the two trackers apart.

Are you a tracker developer and you tracker can save S3M files? Please add your Tracker ID to this list!

Detecting trackers disguising as Scream Tracker[edit]

Some trackers disguise as Scream Tracker 3, but there are ways to uncover this diguise:

ModPlug Tracker[edit]

ModPlug Tracker and OpenMPT up to version identifies as Scream Tracker 3.20 in the Cwt/v field, but it puts zeroes for the special field, only ever sets flags 10 (Amiga Limits) and 40 (Fast Volume Slides), writes multiples of 16 orders, always saves channel pannings, and writes zero into the ultraclick removal field (Scream Tracker 3 always puts either 16, 24, or 32 there).

ModPlug Tracker versions up to 1.0 alpha 5 can be identified by not setting the stereo bit on the master volume. Versions 1.0 alpha 6 up to 1.16.203 can be told apart from later versions if less than 32 channels are used: In the extended panning table, all channels have bit 5 (use panning) set, even those past the last used channel. Later versions write 08 (center panning, do not use) for such channels instead.

Velvet Studio / PlayePRO[edit]

Velvet Studio and PlayerPRO also pretend to be Scream Tracker 3.20, but write zeroes for special, ultraclick, and flags, and do not save channel pannings. Velvet Studio also writes a fairly recognizable LRRL pattern for the channels.

To tell the two trackers apart, PlayerPRO always writes a global volume of 64 and a mix volume of 48 (mono). On the other hand, Velvet Studio always writes the stereo flag.

PlayerPRO also writes an extra 16 bytes of padding between sample headers.

Detecting other trackers[edit]

Scream Tracker 3.10 / 3.20 / 3.21 normally only writes 16, 24 or 32 in the ultraclick removal field (earlier versions write 0 there), so this could be a way to check if a file was not saved with Scream Tracker 3. However, Scream Tracker does not sanitize this field when re-saving a file made with another tracker, so even if the file was saved with Scream Tracker, a different value might still be carried over from another tracker. See the following section for more reliable fingerprinting.

Output driver detection[edit]

Scream Tracker’s Gravis Ultrasound and Sound Blaster drivers differ in their interpretation of various pattern effects, which affects playback of some modules noticeably. Luckily, there is a way to tell which driver was loaded when the S3M file was last saved in Scream Tracker, which can serve as a detection heuristic: If the file was saved with the Gravis Ultrasound driver loaded, every non-empty sample header will have a unique Int:Gp value. If the file was saved with the Sound Blaster driver loaded, every non-empty sample header will have 1 in this field. Note that the first GUS sample also uses address 1, so if there is only one non-empty sample slot, GUS and SB cannot be told apart.

Note that some S3Ms saved with Scream Tracker 3.00 (cwtv = 1300) have a Int:Gp value of 0 for all samples. There is probably a very early version of Scream Tracker 3.00 (probably from 1992) which does not support the Gravis Ultrasound. For higher cwtv values, the fact that all Int:Gp values are 0 can be used for detecting other trackers or tools disguising as Scream Tracker (e.g. automatic PSM to S3M conversions).

Impulse Tracker Edit Timer[edit]

Impulse Tracker hides its edit timer in the file header; there is a section of 8 reserved bytes, of which the first and last two are zero, and the four bytes in the middle contain the edit timer in the same format as in the IT format.