Programmers - Mod Format files. Describe the format of the standard MOD file used in the General Sound.

ZX Format #07
 Mod-File Format

music by MIDISOFT
(C) Stinger '& TP 1997
_


  1. Nazvanie_kompozitsii

  2. Zagolovki_instrumentov

  3. Таблица_позиций_и_информация_о_мо
   muzzle

  4. Patterns

  5. Samples


   1. Song Name

 Offset Length


   +0 20
 Track title, the maximum length
20 characters. If the name is less
than 20 characters, then the remaining part
this field will be filled with binary
zeros. The offset is relative to the beginning of the file.


   2. Headers Tool

 Here are the 1931 series title, the length of each header 30 
(# 1E) bytes, ie with respect to the file header will be offset


   the following:

   Title 1 - offset 20 (# 14)

   Title 2 - offset 50 (# 32)

   .

   Title 31 - offset 920 (# 398)

 The following are the bias offset of the header

 Offset Length


   +0 22
 Name of the instrument, the maximum length
22 characters. If the name is less
than 22 characters, then the remaining part
this field will be filled with binary
zeros.

  +22 2
 Sample length-length sample (*). Value
this field is 0 or 1 indicates a blank
sample (ie, if the sample length in bytes
less than or equal to 2, then the sample blank).
Higher value means the actual, physical sample.

  +24 1
 The lower 4 bits represent the value of setting tone 
(Finetune) for the sample. Znachenie ranges from -8 to +7.

Senior 4 bits should be ignored when reading and recording set 
in zero.

 Bytes: The values ​​set tone:


   x0 = 0

   x1 +1

   x2 +2

   x3 +3

   x4 +4

   x5 +5

   x6 +6

   x7 +7

   x8 -8

   x9 -7

   xA -6

   xB -5

   xC -4

   xD -3

   xE -2

   xF -1

 One unit of setting tone is equal to 1 / 8
semitones, ie with this option
You can omit the frequency of sound samples per
semitone or down to 7 / 8 semitones up.

  +25 1
 Volume tool by default. Value ranges from 0 to 64
(# 00 .. # 40), where 64 top volume, and 0 - minimum.

  +26 2
 Repeat offset - the beginning point of the repeat in
tool (*). This offset of the sample. This value is
meaning if the length of the repeating part
(Displacements 28) is greater than zero.

  +28 2
 Repeat length - the length of the repeating part (*). Sample 
is looped in the fact and only if considered

value greater than zero. (*) These values
measured in words and stored in a standard Amiga High-Endian 
format, therefore, for adequate interpretation of these 
quantities requires the following steps: 

 a) rearrange the older and younger halves of the word;

   b) multiply the word for two


   LD HL, (32768 20 +22); length of the first sample in the 
Amiga words 

   LD A, H; (if the module is loaded at 32,768)

   LD H, L

   LD L, A

   ADD HL, HL; now got the sample length in bytes

Sample is played as follows:
 1) If the length of the sample is less than two, then nothing 
is played;  2) further analyzed the length of the repeating 
part: if it is greater than zero, then sample is looped, and if 
equal zero, then nezatsiklennym.

 3) nezatsiklenny sample is played
simply from beginning to end, ie from Sample_start_adress to 
Sample_start_adress + Sample_Length (Sample_start_adressadres 
sample start).  4) obsessed same sample played

more difficult:
at the beginning is played by Sample_start_adress
to Sample_start_adress + Repeat_offset + Repeat_Length, and 
then to infinity by Sample_start_adress + Repeat_offset to 
Sample_start_adress + Repeat_offset + Repeat_Length. 


  3. Table of positions and information mation about the module

 Offset Length

 +950 (# 3B6) 1
 The length of the track positions (Song Positions) value 
ranges from 1 to 128

 +951 (# 3B7) 1
 The position at which the player must move at the end of 
playback module. C Using this you can loop a module. If this 
value is greater than the number of positions, the player must 
stay on After proigryvaniya module. If the module is hung up is 
not required, it is recommended to record in this field to 127. 
 +952 (# 3B8) 128  Table positions. Length of the table from 1 
to 128 (determined by the value at offset

950) Item number yavlyatsya index in
table, and value in the table on this
index is the number pattern. With
this table we can determine the number of patterns in the 
module. This requires a maximum value in the table and add to 
it one - it will be a number of patterns. 

Example:

  (950) = 6 length tracks - 6 positions.

  (+952) = 2,2,1,0,3,2,6,7

   Position 1 - Pattern 3

   Position 2 - Pattern 3

   Position 3 - Pattern 2

   Position 4 - Pattern 1

   Position 5 - pattern 4