FMK-tech file v1.02
Updated 5th January 1999

This file gives you all information needed to make your own .FMK-player!


This is the OLD FMK file format for file type 1 (FMK version 1.00-1.03)

  dec  0   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15
     Ŀ
   0 'F''M''K''!' Song name (28 characters)
     Ĵ
  16                                                                 
     Ĵ
  32  Composer name (28 characters)
     Ĵ
  48                                                 F4hTypGlbBas
     Ĵ
  64 Spd Reserved                          #sg#in#paTrack stereo
     Ĵ
  80 pans     Track initial settings (20 bytes)                     
     Ĵ
  96                        Orders, amount #sg bytes, only if #sg > 0
     Ĵ
  xx 2 bytes, word-filepos to the song message (0 = none)
  xx (2 bytes * #is), word-filepos to the instruments (only if #is > 0)
                      
  xx (4 bytes * #pa), long integer-filepos to the packed patterns
                       (only if #pa > 0).

0  -3  FMK!
4  -31 Song name (28)
32 -59 Composer name (28)
60     Value 244 (f4h), just for check.
61     File type {1=evolution 1}
62     Global variables, bits : 0 = stereo, 1 = opl3, 2 = rhythm
       3 = 4.8 db tremolo  4 = 14 cent vibrato.
63     Song basespeed, ticks / second. this version : fixed 50.
64     Song initial speed.
65-73  Reserved
74     Length of song (order).
75     Number of instruments.
76     Number of patterns.
77 -81 Track stereo pan positions, bits 0-1, 2-3, 4-5, 6-7.
       value 0 = left 1 = both 2 = right, from track 1 to 20.
82 -101Track initial settings, 255=unused, bits :
       0-2, type value: 0 = normal 1=hihat 2=cymbal 3=tom tom 4=snare 5=bass
                        6 = 4op    7=unused
       3-7, OPL-channel number (1-18), 21 = none.
102-xx Orders, maximum of 255 (only if length of song > 0)
xx -   (word) Pointer to the song message, if 0, no song message.
xx -   If amount of instruments > 0, Pointers to the instruments, a word for
       one instrument, amount of instruments.
xx -   If amount of patterns > 0, Pointers to the packed patterns,
       value 0 means '---', end of song in order list.

----------------------------------------------------------------

This is the NEW FMK file format for file type 2 (version 1.06 >)

  dec  0   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15
     Ŀ
   0 'F''M''K''!' Song name (28 characters)
     Ĵ
  16                                                                 
     Ĵ
  32  Composer name (28 characters)
     Ĵ
  48                                                 F4hTypGlbBas
     Ĵ
  64 Spd Reserved                          #sg#in#paTrack stereo
     Ĵ
  80  pans    Track initial settings (18 bytes)                     
     Ĵ
  96                Orders, amount #sg bytes, only if #sg > 0
     Ĵ
  xx 2 bytes, word-filepos to the song message (0 = none)
  xx (2 bytes * #is), word-filepos to the instruments (only if #is > 0)
                      
  xx (4 bytes * #pa), long integer-filepos to the packed patterns
                       (only if #pa > 0).

0  -3  FMK!
4  -31 Song name (28)
32 -59 Composer name (28)
60     Value 244 (f4h), just for check.
61     File type {2=evolution 2}
62     Global variables, bits : 0 = stereo, 1 = opl3, 2 = rhythm
       3 = 4.8 db tremolo  4 = 14 cent vibrato.
63     Song basespeed, ticks / second. this version : fixed 50.
64     Song initial speed.
65-73  Reserved
74     Length of song (order).
75     Number of instruments.
76     Number of patterns.
77 -81 Track stereo pan positions, bits 0-1, 2-3, 4-5, 6-7.
       value 0 = left 1 = both 2 = right, from track 1 to 18.
82 -99 Track initial settings, 255=unused, bits :
       0-2, type value: 0 = normal  6 = 4op  7=unused
       3-7, OPL-channel number (1-18), 21 = none.
100-xx Orders, maximum of 255 (only if length of song > 0)
xx -   (word) Pointer to the song message, if 0, no song message.
xx -   If amount of instruments > 0, Pointers to the instruments, a word for
       one instrument, amount of instruments.
xx -   If amount of patterns > 0, Pointers to the packed patterns,
       value 0 means '---', end of song in order list.






Format of packed pattern

0-1    2 bytes, a word, length of packed pattern.
2-length : packed data


packed data : First byte of item, bits:
 0-4 Track define 1-20.
 5 - Note (byte) and instrument (byte) follows.
 6 - volume follows.
 7 - command (byte) and infobyte (byte) follows.
 If value 0, row done.

 Note byte 254 is cut sound note.

 So, if you get 232, read five following bytes and do them to the channel 8.
 (note : this is exactly the same format what ST3 uses)

----------------------------------------------------------------
Format of song message :
0           Amount of rows in message 24 being maximum.
1-(20*rows) Song message, 20 character / row

----------------------------------------------------------------

The instrument file format (used in .FMK .FIN and .FIB) :

  dec  0   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15
     Ŀ                            
   0  Dos name (12 characters)                       Instrument name
     Ĵ
  16  (27 characters)
     Ĵ
  32                             MamCamMleCleMatCatMsuCsuMwa
     
  48 CwaFee
     

0     Dosname is always 12 character long.

12    Instrument name is 27 characters.

39,40 Mam and Cam are "20h+" and "23h+" registers.
         7       6       5       4       3       2       1       0
     Ŀ
     TremoloVibratoSustainKey-    Frequency multiplier          
                          scaling                               
     

41,42 Mle and Cle are "40h+" and "43h+" registers, note that the volume 63
      is really attenuation 0.
         7       6       5       4       3       2       1       0
     Ŀ
     Scaling level   Logarithmic attenuation                       
                                                                   
     


43,44 Mat and Cat are "60h+" and "63h+" registers.
         7       6       5       4       3       2       1       0
     Ŀ
             Attack Rate                    Decay Rate             
                                                                   
     

45,46 Msu and Csu are "80h+" and "83h+" registers, note that the sustain
      level 15 is really 0.
         7       6       5       4       3       2       1       0
     Ŀ
             Sustain level                  Release Rate           
             (inverted)                                            
     

47,48 Mwa and Cwa are "e0h+" and "e3h+" registers.
         7       6       5       4       3       2       1       0
     Ŀ
             Unused                          Waveform select       
                                                                   
     

49    Fee is "C0h+" register
         7       6       5       4       3       2       1       0
     Ŀ
             Unused                   Feedback strength    Connect
                                                                  
     

----------------------------------------------------------------

The Instrument bank file format (FIB) :

0-3 : 'FIB'+f4h
4-5 : Amount of instruments in file, a word.
6-50*#ins : Instruments in .FIN-format.
and the file ends :
Last 4 bytes : 'FIB'+f4h

--------------------------------------------------------------------------

Tables uses shortint types : -127 to +127

Speed table for vibrato and tremolo (with table length of 256 bytes)
 0, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29


Remember, normal volumeslides changes the volume only in every fifth tick.


Commands :
  1  - Speed change    (Axx)
  2  - Break pattern   (Bxx)
  3  - Carrier param   (Cxx)
  4  - Volume slides   (Dxx) (DFx) (DxF)
  5  - Note slide down (Exx) (EFX) (ExF)
  6  - Note slide up   (Fxx) (FFX) (FxF)
  7  - Tone portamento (Gxx)
  8  - Vibrato         (Hxx)
  9  - Retrig          (Ixx)
  10 - Arpeggio        (Jxx)
  13 - Modulator param (Mxx)
  14 - Set waveform    (N0x)
  16 - Break to row    (Pxx)
  18 - Tremolo         (Rxx)
  19 - Stereo control  (S0x)
  20 - Modulator volume(Txx)
  21 - Carrier volume  (Uxx)


Looking for OPL2 / OPL3 programming info ?
Find following files from the Internet :

The Ad Lib Music Synthesizer Card   Programming Guide
             by Tero Ttt
   also .BNK file structure and note frequencies.

Programmer's Guide to Yamaha YMF 262/OPL3 FM Music Synthesizer v1.00
             by Vladimir Arnost
   Good 4-operator diagrams.
   Includes programming examples and OPL2 / OPL3-detection.

Programming the AdLib/Sound Blaster FM Music Chips
             by Jeffrey S. Lee
   Only document of these which have the key scaling level info right.
   This file is part of PC Games Programmers Encyclopedia.


They all have useful information, use them all to get all the facts right.


