The Protracker file format

Tracker 4.44

## 8.1: The binary Protracker file format

      Offset
      ---------------------------------------
        0        20 bytes        Song Name [1]
       20        22 bytes        Sample name
       42         1 word         sample length [2]
       43         1 byte         finetune [3]
       44         1 byte         volume [4]
       46         1 word         looping start point
       48         1 word         looping length
                ---------
                 30 bytes [5]

      20+30*n     1 byte         length of song [6]
      21+30*n     1 byte         number of patterns to load [7]
      22+30*n   128 bytes        pattern indices [8]

      1080        4 bytes        signature (31 samples modules only)

      150+30*n 1024 bytes        each pattern [9]

      150+30*n                   sample data [10]
      +1024*p

[1] Song names and sample names will be converted to a null-terminated string. Be very careful as to what to allow there...

[2] Sample length, looping start point, looping length are normally stored as a number of words. Occasionally, in very old modules, the looping start point might be stored in bytes (case in point: ``kawai-k1`'). Checking looping start point + looping length against sample length might discover the problem. Sound samples are 8-bit signed

[3] Finetune does only exist for protracker modules: if the signature isn't M.K./M!K!, it should be 0. Normal values are 0-15. Signature M!K! should only occur if the number of patterns is greater than 64.

[4] This is the sample default volume, when no specific values have been given. Normal values are 0-64. Some songs include out of range values. Be sure to normalize to 0-64

[5] There are 15 sample info entries in old soundtracker files, 31 in newer protracker/noisetracker ones. The difference lies in the signature. Valid signatures are M.K. / M!K! (for Mahoney & Kaktus), FLT4/FLT8 for startrekker modules.

[6] Range 1-128

[7] Do not trust this byte ! Very old trackers used it to indicate the number of pattern indices, so it's set to 127 by protracker to enable old trackers to load this module. Noisetracker uses this byte for restart.

[8] This is a sequencing order: like in play pattern #2, then #4, then #2 again, and so on...

[9] We use the highest pattern number in the pattern indices table to determine the number of patterns p to load. Older trackers saved it as `number of patterns to load'.

[10] Sample data is given for each existing sample. Non-existing samples have a length of 0 or 1 (usually 1). Sample values are signed bytes, in 2-complement notation. Each sample length is a multiple of 2 in bytes.