home *** CD-ROM | disk | FTP | other *** search
/ Large Pack of OldSkool DOS MOD Trackers / digitr31.zip / FORMAT.TXT < prev    next >
Text File  |  1996-03-28  |  22KB  |  487 lines

  1.                                                       ┌─-─--·· · · ··--─-─┐
  2. ╒═════════════════════════════════════════════════════│    █▐  n-Factor's │══╕
  3. ├─────────────────────────────────────────────────────│    █▐             │──┤
  4. │                                                     │ ▐███▐  ▀ ▐███▌  ▀ │  │
  5. │   ≡≡≡ DIGITRAKKER ≡≡≡ FILE-FORMAT DESCRIPTION ≡≡≡   │ █  █▐ █▐ █  █▐ █▐ │  │
  6. │                                                     │ ▐███▐ █▐ ▐███▐ █▐ │  │
  7. ├─────────────────────────────────────────────────────│             █▐    │──┤
  8. ╘═════════════════════════════════════════════════════│  t r a k k▐██▌e r │══╛
  9.                                                       └─-─--·· · · ··--─-─┘
  10.  
  11. --------------------------- by prodatron/n-Factor ----------------------------
  12. revision 3.1
  13.  
  14.  
  15. This file contains information about the songmodule-format "MDL", the
  16. instrument-format "IST" and the old sample-format "SPL".
  17. If you have some problems or if you have questions about these formats, which
  18. are not answered in here, just contact me (eMail: pdt@uni-duisburg.de).
  19.  
  20.  
  21.  
  22.  
  23. ╔════════════════════════════════════════════════════════════════════════════╗
  24. ║                        THE SONGMODULE-FORMAT  (MDL)                   V1.1 ║
  25. ╚════════════════════════════════════════════════════════════════════════════╝
  26.  
  27. Offset Lenght Description
  28.  
  29.  000    004     "DMDL"; the four letters mark the mdl-format
  30.  004    001     version; the current version is 11h (=1.1)
  31.  005    ???     the different data-blocks are stored at this position
  32.  
  33. Some words to the format version-number:
  34. - if the low-nibble increases, there are extensions in the format, but old
  35.   loaders should be able to load the new modules (or most of them...)
  36. - if the high-nibble increases, there are changes in the format which make old
  37.   loaders unable to read the new songfiles
  38.  
  39. The MDL-songmodule-format is subdivided into the following blocks:
  40.  
  41. "IN"    infoblock; contains most songparameters, like speed, length etc.
  42. "ME"    songmessage; contains the songinformation from the composer
  43. "PA" c  pattern; contains the length, names and tracklists for every pattern
  44. "TR"    tracks; contains all the tracks for the pattern
  45. "II" n  instruments; contains all information for the used instruments
  46. "VE" n  volume-envelopes; contains the construction of all used vol-envelopes
  47. "PE" n  panning-envelopes; the same for the used pan-envelopes
  48. "FE" n1 frequency-envelopes; ...used frq-envelopes (LFO)
  49. "IS" c  sampleinfos; contains information for every used sample
  50. "SA"    samples; contains the sample-datas
  51.  
  52. [[ c  = blockstructure changes from v0.0 to v1.0 ]]
  53. [[ n  = new in version 1.0                       ]]
  54. [[ n1 = new in version 1.1                       ]]
  55.  
  56. The sequence of the blocks in a file is not fixed so they can be stored in any
  57. way. Digitrakker uses the descripted sequence.
  58.  
  59. The structure for every block is the same:
  60.  
  61. Offset Lenght Description
  62.  
  63.  000    002     "xx"; block-ID (example: "IN" for infoblock)
  64.  002    004     blocklength; this dword contains the length of the FOLLOWING
  65.         datas.
  66.  006 <blocklen> datas for this block...
  67.  
  68. The next block will be at offset (006 + <blocklength>).
  69.  
  70. ┌────────────────────────────────────────────────────────────────────────────┐
  71. │                          The Song-Infoblock  (IN)                          │
  72. └────────────────────────────────────────────────────────────────────────────┘
  73.  
  74. Offset Lenght Description
  75.  
  76.  000    002     "IN"; infoblock-ID
  77.  002    004     blocklenght
  78.  006    032     songname; name of the songmodule (filled with spaces [32])
  79.  038    020     composername; name of the song-composer
  80.  058    002     songlength; Digitrakker supports up to 255 songpositions
  81.  060    002     songrepeat
  82.  062    001     mainvolume (001-255)
  83.  063    001     song-speed (001-255)
  84.  064    001     beats per minute (004-255)
  85.  065    032     channel-information: bit 0-6 - panposition (0=left,127=right)
  86.                      bit 7   - 0=channel on, 1=channel off
  87.                 [number of channels = last active channel]
  88.  097  <snglen>  sequencer; contains the number of the pattern for every
  89.         songposition
  90.  ???  <chnnam>  the names for every channel (8 chars for one name).
  91.         <chnnam> = 8 * <number of channels>
  92.  
  93. ┌────────────────────────────────────────────────────────────────────────────┐
  94. │                            The Songmessage (ME)                            │
  95. └────────────────────────────────────────────────────────────────────────────┘
  96.  
  97. Offset Lenght Description
  98.  
  99.  000    002     "ME"; songmessage-ID
  100.  002    004     blocklenght
  101.  006    ???     songmessage; every line is closed with the CR-char (13). A
  102.         0-byte stands at the end of the whole text.
  103.  
  104. ┌────────────────────────────────────────────────────────────────────────────┐
  105. │                           The Patterndatas  (PA)                           │
  106. └────────────────────────────────────────────────────────────────────────────┘
  107.  
  108. Offset Lenght Description
  109.  
  110.  000    002     "PA"; patterndata-ID
  111.  002    004     blocklenght
  112.  006    001     number of pattern; values from 1 to 255 are possible
  113.  007  <patlar>  the datablocks for all saved pattern
  114.  
  115. The structure of one pattern-datablock:
  116.  
  117.  000    001    number of used channels (0-32)
  118.  001    001     patternlength-1 (0-255 for 1-256 lines)
  119.  002    016    pattern-name (filled with [32])
  120.  018  <trklar>  tracksequencing-list
  121.         <trklar> = 2 * number of channels in this pattern
  122.  
  123. The tracksequencing-lists descripe which track is used as which voice in the
  124. pattern. The first word in this list is the number of the track at voice 0.
  125. The second is track for voice 1 and so on...
  126. As every track is saved independend, it is possible to save some discspace by
  127. this methode: If the song contains equal tracks at several positions in
  128. the patterns, these double tracks will only saved one time.
  129. Track 0 is not saved and represents an empty track.
  130.  
  131. ┌────────────────────────────────────────────────────────────────────────────┐
  132. │                            The Trackdatas  (TR)                            │
  133. └────────────────────────────────────────────────────────────────────────────┘
  134.  
  135. Offset Lenght Description
  136.  
  137.  000    002     "TR"; trackdata-ID
  138.  002    004     blocklenght
  139.  006    002     number of tracks
  140.  008    ???     track-datablocks; every trackdatablock is stored in this way:
  141.         Ofs.000 Len.002         length of the trackdatas
  142.             002 <trackdatalen>  datas for this track
  143.  
  144. Every track consists of 1-256 notepositions and every notposition contains
  145. 6 bytes:
  146.  
  147. byte 0              - note-value; 1 = C-0, 2 = C#0,..., 120 = B-9,
  148.               0 = nothing (---), 255 = key off (^^^)
  149. byte 1              - instrument-number; 1-255; 0 = nothing
  150. byte 2              - volume; 1-255; 0 = no volume change
  151. byte 3, low nibble  - number of the first effect-command
  152. byte 3, high nibble - number of the second effect-command (commands "g"-"l"
  153.               get the numbers 1-6)
  154. byte 4              - databyte for the first effect-command
  155. byte 5              - databyte for the second effect-command
  156.  
  157. Digitrakker stores the tracks in a packed way. The structure of this VERY
  158. effective (!!!) packformat is the following:
  159.  
  160.      bit 76543210
  161. byte 0 - xxxxxxyy
  162.  
  163. if yy = 00 -> <xxxxxx>+1 is the number of the empty notepositions which are
  164.           following.
  165. if yy = 01 -> the last noteposition will be repeated <xxxxxx>+1 times.
  166. if yy = 10 -> the noteslot from position <xxxxxx> is copied to the actual
  167.           position.
  168. if yy = 11 -> the following datas will be put in the actual noteslot:
  169.         bit 2 = 1 -> note
  170.         bit 3 = 1 -> sample
  171.         bit 4 = 1 -> volume
  172.         bit 5 = 1 -> effectcommand numbers
  173.         bit 6 = 1 -> databyte for effect 1
  174.         bit 7 = 1 -> databyte for effect 2
  175.               If the bit is not setted, the byte isn't stored and you have to
  176.               take 0 instead.
  177.  
  178. To find out the number of notepositions in a track you should decrease a
  179. counter (startvalue: length of the packed trackdatas) while depacking.
  180. Every depacked track has to be filled out with 0-values up to position 256.
  181. When you copy the track into a pattern just take the number of positions you
  182. need for the pattern (if the pattern has a length of 64 positions only take
  183. the first 64 positions from the track).
  184.  
  185. ┌────────────────────────────────────────────────────────────────────────────┐
  186. │                           The Instruments (II)                             │
  187. └────────────────────────────────────────────────────────────────────────────┘
  188.  
  189. Offset Lenght Description
  190.  
  191.  000    002     "II"; intrument-ID
  192.  002    004     blocklenght
  193.  006    001     number of saved instruments; values from 0 to 255 are possible
  194.  007  <inslar>  the datablocks for all used instruments
  195.  
  196. The structure of one instrument-datablock:
  197.  
  198.  000    001     instrument-number; (1-255)
  199.  001    001    number of samples in instrument; (1-16)
  200.  001    032     instrument-name; the name of the instrument (filled with [32])
  201.  033  <is-len>  this block contains the infos for all defined samples in the
  202.         instrument; every info consist of 14 bytes, so
  203.         <is-len> = 14 * number of defined samples
  204.  
  205. The structure of one instrument-sample datablock:
  206.  
  207.  000    001     sample-number; (1-255)
  208.  001    001     playrange-end (0-119,0='c-0'); the last note for this sample;
  209.         a higher note uses one of the next samples
  210.  002    001     volume (1-255)
  211.  003    001     bit 0-5 -> volumeenvelope-number (0-63)
  212.         bit 6   -> flag, if volume is used
  213.         bit 7   -> flag, if volumeenvelope is used
  214.  004    001     panning (0-127)
  215.  005    001     bit 0-5 -> panningenvelope-number (0-63)
  216.         bit 6   -> flag, if panning is used
  217.         bit 7   -> flag, if panningenvelope is used
  218.  006    002     fadeout-speed (0-65535)
  219.  008    001     vibrato-speed (0-255)
  220.  009    001     vibrato-depth (0-255)
  221.  010    001     vibrato-sweep (0-255)
  222.  011    001     vibrato-form (0-2)
  223.  012    001     ** reserved ** (should be set to <0>)
  224.  013    001     bit 0-5 -> frequencyenvelope-number (0-63)
  225.                 bit 6   -> ** reserved ** (should be set to <0>)
  226.                 bit 7   -> flag, if frequencyenvelope is used
  227.  
  228. ┌────────────────────────────────────────────────────────────────────────────┐
  229. │                         The Volume-Envelopes  (VE)                         │
  230. └────────────────────────────────────────────────────────────────────────────┘
  231.  
  232. Offset Lenght Description
  233.  
  234.  000    002     "VE"; volume-envelope-ID
  235.  002    004     blocklenght
  236.  006    001     number of saved vol-envelopes (0-64)
  237.  007  <ve-lar>  volume-envelope datas; a datablock contains 33 bytes, so
  238.         <ve-lar> = 33 * number of saved vol-envelopes;
  239.  
  240. The structure of one envelope-datablock:
  241.  
  242.  000    001     envelope-number; (0-63)
  243.  001    030     the positions of the 15 points are stored here; the first
  244.         byte is the x-distance from the last point (1-255; 0 means,
  245.         that no more points are defined; take 1 for the first point),
  246.                 the second byte is the y-position (0-63)
  247.  031    001     bit 0-3 -> sustain-point (0-14)
  248.         bit 4   -> flag, if sustain is on
  249.         bit 5   -> flag, if loop is on
  250.                 bit 6-7 -> ** reserved ** (should be set to <0>)
  251.  032    001     bit 0-3 -> loop-start (0-14)
  252.         bit 4-7 -> loop-end (0-14)
  253.  
  254. ┌────────────────────────────────────────────────────────────────────────────┐
  255. │                         The Panning-Envelopes (PE)                         │
  256. └────────────────────────────────────────────────────────────────────────────┘
  257.  
  258. Offset Lenght Description
  259.  
  260.  000    002     "PE"; panning-envelope-ID
  261.  002    004     blocklenght
  262.  006    001     number of saved pan-envelopes (0-64)
  263.  007  <pe-lar>  panning-envelope datas; a datablock contains 33 bytes, so
  264.         <pe-lar> = 33 * number of saved pan-envelopes
  265.         see at "VE" for the description of an envelope-datablock
  266.  
  267. ┌────────────────────────────────────────────────────────────────────────────┐
  268. │                        The Frequency-Envelopes (FE)                        │
  269. └────────────────────────────────────────────────────────────────────────────┘
  270.  
  271. Offset Lenght Description
  272.  
  273.  000    002     "FE"; frequency-envelope-ID
  274.  002    004     blocklenght
  275.  006    001     number of saved frq-envelopes (0-64)
  276.  007  <fe-lar>  frequency-envelope datas; a datablock contains 33 bytes, so
  277.                 <fe-lar> = 33 * number of saved frq-envelopes
  278.         see at "VE" for the description of an envelope-datablock
  279.  
  280. ┌────────────────────────────────────────────────────────────────────────────┐
  281. │                         The Sample-Infoblocks (IS)                         │
  282. └────────────────────────────────────────────────────────────────────────────┘
  283.  
  284. Offset Lenght Description
  285.  
  286.  000    002     "IS"; sampleinfo-ID
  287.  002    004     blocklenght
  288.  006    001     number of saved samples; values from 0 to 255 are possible
  289.  007  <samlar>  sample-infoblocks; an infoblock for one sample contains 59
  290.                 bytes, so <samlar> = 59 * number of saved samples
  291.  
  292. The structure of one sample-infoblock:
  293.  
  294.  000    001     sample-number; (1-255)
  295.  001    032     sample-name; the name of the sample (filled with [32])
  296.  033    008     filename of the sample
  297.  041    004     C-4 sample-frequency in hz
  298.  045    004     sample-length
  299.  049    004     sample-repeatstart
  300.  053    004     sample-repeatlength; if this value is set to 0, the sample
  301.         will not loop
  302.  057    001     ** not used ** (this was the volume in old v0.0-modules)
  303.  058    001     infobyte:
  304.         bit 0   -> 0=8 bit sample, 1=16 bit sample
  305.         bit 1   -> 0=forward looping, 1=bidirectional looping
  306.                 bit 2,3 -> packmethode (0=not packed, 1=8bit packing,
  307.                            2=16bit packing, 3=not defined)
  308.                 bit 4-7 -> ** reserved ** (should be set to <0>)
  309.  
  310. ┌────────────────────────────────────────────────────────────────────────────┐
  311. │                            The Sampledatas (SA)                            │
  312. └────────────────────────────────────────────────────────────────────────────┘
  313.  
  314. Offset Lenght Description
  315.  
  316.  000    002     "SA"; sampledata-ID
  317.  002    004     blocklenght
  318.  006    ???     sampledatas; samples are stored in numeric sequence
  319.  
  320. Unpacked samples are stored in signed form. Packmethode (1) is designed for
  321. 8 bit samples, Packmethode (2) for 16 bit samples. Methode (3) isn't defined
  322. in this version.
  323. A packed sample begins with a dword which contains the length of the
  324. following datastream.
  325.  
  326.  
  327. The description of the sample-packmethode (1) [8bit packing]:...
  328. ────────────────────────────────────────────────────────────────
  329.  
  330. This methode is based on the huffman-algorithm. It's an easy form, but very
  331. fast and effective on samples. The packed sample is a bit-datastream:
  332.  
  333.     Byte 0    Byte 1    Byte 2    Byte 3
  334. Bit 76543210  fedcba98  nmlkjihg  ....rqpo
  335.  
  336. A packed byte is stored in the following form:
  337.  
  338. xxxx10..0s => byte = <xxxx> + (number of <0>-bits between s and 1) * 16 - 8 ;
  339.           if s=1 then byte = byte xor 255
  340.  
  341. If there are no <0>-bits between the first bit (sign) and the <1>-bit, you
  342. have the following form:
  343.  
  344. xxx1s      => byte = <xxx> ; if s=1 then byte = byte xor 255
  345.  
  346. To depack one byte, you have to use the following algorithm:
  347. ┌────────────────────────────────────────────────────────────────────────────┐
  348. │       read bit                                                             │
  349. │       sign = bit                                                           │
  350. │       read bit                                                             │
  351. │       if bit = 1                                                           │
  352. │               then  read [3bits]                                           │
  353. │                     byte = [3bits]                                         │
  354. │                     goto next                                              │
  355. │               else  byte = 8                                               │
  356. │loop:  read bit                                                             │
  357. │       if bit = 0                                                           │
  358. │               then  byte = byte + 16                                       │
  359. │                     goto loop                                              │
  360. │               else  read [4bits]                                           │
  361. │                     byte = byte + [4bits]                                  │
  362. │next:  if sign = 1                                                          │
  363. │               then byte = byte xor 255                                     │
  364. └────────────────────────────────────────────────────────────────────────────┘
  365.  
  366. Two examples:
  367.  
  368. xxxx  s
  369. 1001101 = ( 9 + 1 * 16 - 8 ) xor 255 = 238
  370.  
  371. xxx s
  372. 01010 = 2
  373.  
  374. Note that the depacked bytes are delta values. To convert them to real data
  375. use this algorithm:
  376.  
  377. oldbyte = 0
  378. for sampleposition = 1 to samplelength
  379.     newbyte = byte [sampleposition] + oldbyte
  380.     byte [sampleposition] = newbyte
  381.     oldbyte = newbyte
  382. next sampleposition
  383.  
  384.  
  385. The description of the sample-packmethode (2) [16bit packing]:...
  386. ────────────────────────────────────────────────────────────────
  387.  
  388. It works as methode (1) but it only crunches every 2nd byte (the high-
  389. bytes of 16 bit samples). So when you depack 16 bit samples, you have to
  390. read 8 bits from the data-stream first. They present the lowbyte of the
  391. sample-word. Then depack the highbyte in the descripted way (methode [1]).
  392. Only the highbytes are delta-values. So take the lowbytes as they are.
  393. Go on this way for the whole sample!
  394.  
  395.  
  396. ┌────────────────────────────────────────────────────────────────────────────┐
  397. │                    ** Differences to older formats **                      │
  398. └────────────────────────────────────────────────────────────────────────────┘
  399.  
  400. Changes from v0.0 to v1.0:
  401. - block "PN" (patternnames) doesn't exist in v1.0-modules (patternnames now
  402.   stored in block "PA")
  403.   the old v0.0 structure of the "PN"-block:
  404.     000    002     "PN"; patternnames-ID
  405.     002    004     blocklenght
  406.     006  <patnam>  the names for every pattern (16 chars for one name).
  407.            <patnam> = 16 * <number of patterns>
  408. - structure of block "PA" changes completely
  409.   the old v0.0 structure of the "PA"-block:
  410.     000    002     "PA"; patterndata-ID
  411.     002    004     blocklenght
  412.     006    001     number of pattern; values from 1 to 255 are possible
  413.     007  <patlar>  tracksequencing-list for the used patterns;
  414.            <patlar> = 64 * number of patterns (32 words with the
  415.            tracknumbers for every pattern)
  416. - new blocks in v1.0-modules: "II" (instruments), "VE" (volume-envelopes) and
  417.   "PE" (panning-envelopes)
  418. - volumebyte (byte 57) in the sample-datablocks (block "IS") isn't used;
  419.   the C-4 sample-frequency increases from a word (2 bytes) to a dword (4
  420.   bytes), so one whole sample-infoblock now has a length of 59 bytes
  421.  
  422. Extension from v1.0 to v1.1:
  423. - new block: "FE" (frequency-envelopes)
  424.  
  425.  
  426.  
  427.  
  428. ╔════════════════════════════════════════════════════════════════════════════╗
  429. ║                        THE INSTRUMENT-FORMAT  (IST)                   V0.1 ║
  430. ╚════════════════════════════════════════════════════════════════════════════╝
  431.  
  432. The IST-format has the same structure like parts the MDL-format:
  433.  
  434. Offset Lenght Description
  435.  
  436.  000    004     "DIST"; the four letters mark the ist-format
  437.  004    001     version; the current version is 01h (=0.1)
  438.  005    ???     the different data-blocks are stored at this position
  439.  
  440. The IST-instrument-format is subdivided into the following blocks:
  441.  
  442. "II"    instruments; contains all information for the saved instrument
  443. "VE"    volume-envelopes; contains the construction of all vol-envelopes for
  444.         this instrument
  445. "PE"    panning-envelopes; the same for the pan-envelopes
  446. "FE"    frequency-envelopes (new in v0.1); the same for the frq-envelopes
  447. "IS"    sampleinfos; contains information for every used sample
  448. "SA"    samples; contains the sample-datas
  449.  
  450. The structures for the several blocks are the same as in the mdl-format.
  451. The instrument-infoblock ("II") contains one instrument only.
  452.  
  453.  
  454.  
  455.  
  456. ╔════════════════════════════════════════════════════════════════════════════╗
  457. ║                          THE SAMPLE-FORMAT  (SPL)                     V0.0 ║
  458. ╚════════════════════════════════════════════════════════════════════════════╝
  459.  
  460. Here comes the description for the old sample-format "SPL", which was used in
  461. older tracker-versions (V2.0-V2.2). This format isn't supported any longer in
  462. Digitrakker, that means you can read it, but you can't save samples in this
  463. form.
  464. The reason for this step was the fact, that there are too many sample-formats
  465. and it makes no sense to introduce a new one, because the existing IFF-format
  466. nearly contains all infos you need for a Digitrakker-sample.
  467.  
  468. Offset Lenght Description
  469.  
  470.  000    004     "DSPL"; the four letters mark the spl-format
  471.  004    001     version; the current version is 0
  472.  005    032     sample-name; the name of the sample (filled with [32])
  473.  037    008     filename of the sample
  474.  045    002     C-4 sample-frequency in hz (00000-65535)
  475.  047    004     sample-length
  476.  051    004     sample-repeatstart
  477.  055    004     sample-repeatlength; if this value is set to 0, the sample
  478.         will not loop
  479.  059    001     sample-volume (1-255)
  480.  060    001     infobyte:
  481.         bit 0   -> 0=8 bit sample, 1=16 bit sample
  482.         bit 1   -> 0=forward looping, 1=bidirectional looping
  483.         bit 2,3 -> packmethode (0=not packed, methodes 2 and 3 doesn't
  484.                exist in this version)
  485.         bit 4-7 -> not used (should be set to 0)
  486.  061    ???     sampledatas... (see above)
  487.