home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaMiscModsCD3.iso / _PROGRAMME / TRACKER / pro2.lha / fileformat_V2 < prev    next >
Encoding:
Text File  |  1996-05-20  |  5.9 KB  |  171 lines

  1.                       Soundtracker pro II file format
  2.                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3.  
  4. I haven't planned to write a converter from pro2-mods to protracker-
  5. or MED-mods any time soon, so I decided to document and release
  6. the pro2-fileformat, hoping that someone will do it for me. ;)
  7. If you do, I would't mind if send me a copy.
  8.  
  9. Soundtracker pro II files exist in three versions, 0, 1 and 2.
  10. Since the first official release (2.0) of pro2, only the version 2
  11. fileformat has been used for saving.
  12. You might encounter a version 0 or 1 song written by one of the
  13. betatesters. The fileformats are very much the same, it is not
  14. hard to make a loader for all of them.
  15.  
  16. In a mixture of pseudo-C/assembler/pro2-script, the file formats are as
  17. follows:
  18.  
  19. dc.l    'STP3'          ; an identifier not easily impersonated
  20. dc.w    version         ; only versions 0, 1 and 2 supported
  21. dc.b    songlength      ; number of valid entries in pattern sequence
  22. dc.b    patternlength   ; default length of patterns in lines. In version 0 this
  23.                         ; is also the actual patternlengt for all pattern.
  24. ds.b    128             ; 128 bytes pattern sequence, only <songlength> are valid
  25. dc.w    delay           ; delay
  26. dc.w    delayfraction   ; delay fraction. 0,1,2,3 for 0, .25, .5 and .75
  27. dc.w    count           ; cia count
  28. dc.w    songflags       ; see below
  29. ds.l    1               ; reserved, should be zero
  30. dc.w    midi            ; number of MIDI bytes to follow (50)
  31. ds.b    midi            ; the MIDI settings
  32.  
  33. dc.w    x               ; number of samples to follow
  34. dc.w    y               ; length of each sample structure, must be even
  35.             ; for version 0 and 1 this structure is 82 bytes in size
  36.             ; version 2 has this word set to 4
  37. repeat x
  38.   if(version <= 1)
  39.   {
  40.     dc.w  samplenumber
  41.     ds.b  y               ; standard sample structure, see below
  42.   }
  43.   else
  44.   {
  45.     dc.w samplenumber
  46.     dc.l structsize
  47.     ds.b structsize-2
  48.   }
  49.   if (version>=1)
  50.   {
  51.     dc.w  numloops      ; number of loops in the sequence, use 0 for non-seqs
  52.     ds.l  2*numloops    ; loops: repstart,replen
  53.   }
  54. endrep
  55.  
  56. if(version==0)
  57. {
  58.   dc.w  x               ; number of patterns
  59.   repeat x
  60.     ds.b  patternlength*16
  61.   endrep
  62. }
  63. else
  64. {
  65.  { /* continue until patternnumber = -1 */
  66.    dc.w  patternnumber
  67.    dc.w  patternlength  ; in lines
  68.    dc.w  patternwidth   ; in tracks
  69.    ds.l  patternlength*patternwidth
  70.  }
  71.  { /* loop until scriptnumber = -1*/
  72.    dc.w  scriptnumber
  73.    dc.w  status          ; compiled/uncompiled = compiled/text
  74.    dc.l  length
  75.    ds.b  length
  76.  }
  77.  
  78.   ds.b  17              ; drumpad sample numbers
  79.   ds.b  17              ; drumpad note numbers
  80. }
  81.  
  82. if (!EOF)
  83. {
  84.    ds.b   total sample length  ; sampledata
  85. }
  86.  
  87. NOTE: - the absence of scripts or the absence of patterns is signalled by
  88.         giving -1 as the first script- or patternnumber (version 1 and up)
  89.       - Currently the patternwidth must be 4.
  90.  
  91. *---------------------------------------------------------------------
  92.  
  93. sample structure version 0 and 1:
  94.         ds.b    30        pathname, 30 chars max
  95.         dc.b    0        zero termination, in case all 30 chars were used
  96.         dc.b    sampleflags    flags, see below
  97.         ds.b    30        filename
  98.         dc.l    samplelength    in bytes
  99.         dc.b    volume        0-$40
  100.         ds.b    1        reserved, set to zero
  101.         dc.l    repeat offset    in bytes
  102.         dc.l    repeat length    in bytes, 0 for no repeat
  103.         dc.w    default command
  104.         ds.b    4        4 reserved bytes, set to 0
  105.  
  106. sample structure version 2:
  107.         ds.b    N        pathname, zero terminated, 256 chars max
  108.         dc.b    sampleflags    flags, see below
  109.         ds.b    M        filename, zero terminated, 30 chars max
  110.         even            pad to even boundary
  111.         dc.l    samplelength    in bytes
  112.         dc.b    volume        0-$40
  113.         ds.b    1        reserved, set to 0
  114.         dc.l    repeat offset    in bytes
  115.         dc.l    repeat length    in bytes, use 0 for no repeat (PT uses 2)
  116.         dc.w    default command
  117.         dc.w    default period
  118.         dc.b    finetune    -16 to +15
  119.         ds.b    1        reserved, set to 0
  120.     
  121.  
  122. A sample must not have a nonzero repeatstart and zero repeatlength, unless
  123. it contains a sequence!!!!!!!!
  124.  
  125. *---------------------------------------------------------------------
  126.  
  127. patterns contain notes, one longword per note, like this:
  128. track0note0  track1note0  track2note0  track3note0
  129. track0note1  track1note1  track2note1  track3note1
  130. track0note2  track1note2  track2note2  track3note2
  131. etc...
  132.  
  133. The longwords are as follows:
  134.  
  135.         'note'-word                     'info'-word
  136.         0000 0000  0000 0000            0000 0000  0000 0000
  137.         \       /  \       /
  138.          \     /    \     /             high byte:
  139.           \   /      \   /              command #
  140.            \ /        \ /                          low byte:
  141.           sample #    key # (MIDI)                 command parameter
  142.                                       (some commands use the low 3 nibbles
  143.                                        as command parameter)
  144.  
  145. MIDI keynumbers start at 24 decimal for note C-1 and are incremented by one
  146. for each higher note.
  147.  
  148. *---------------------------------------------------------------------
  149.  
  150. songflags: (filter+clockmode indicator)
  151.  
  152.        bits:      ......ed a.b...c.
  153.                      a: 1=par in slow
  154.                      b: 1=use cnt clock,0=use 02 clock
  155.                      c: 1= filter on
  156.                      d: 1=par out
  157.                      e: 1=par out slow
  158. All other bits are reserved and should be set to zero
  159.  
  160. sampleflags:
  161.        bits:    c... .ur.
  162.                   c: 1= chipram preferred for this sample
  163.                   u: 1=upsample for notes A#3, B-3, A#4 and B-4
  164.           r: 1=load right channel of stereo sample
  165.                      0=load left channel of stereo sample
  166.                      (only for songs, since mods have the
  167.                       correct sample embedded)
  168. All other bits are reserved and should be set to zero
  169.  
  170. *---------------------------------------------------------------------
  171.