Kefrens-Sound Machine format
Created by Razmo / Kefrens (1989)
Analysed by Asle / ReDoX (asle@mygale.org)

Source:
 - 6 KSM files sent by Gryzor ! (thx).

Note: Most probably based on SoundTracker format ... only 15 samples.
     the effect command numbers are 'almost' ptk-like !.


Offset    size (byte)    Comment
------    -----------    -------

  0            2         "M." Id

  2           13         Title
             (0Dh)

 15            1         "a". Always here ... at least in the 6 example
(0Fh)                    files I have.

 16           16         ?!? (16 empty bytes)
(10h)        (10h)

      ***************************************
      * the following is repeated 15 times  *
      * with 32 bytes description for 1 smp *
******************************************************
                                                     *
 32           16         ?!?                         *
(20h)        (10h)                                   *
 48            4         Sample address in the file  *
(30h)                                                *
 52            2         Sample size                 *
(34h)                                                *
 54            1         Volume (0 - 40h)            *
(36h)                                                *
 55            1         ?!?                         *
(37h)                                                *
 56            2         Loop Start                  *
(38h)                                                *
 58            6         ?!?                         *
(38h)                                                *
                                                     *
******************************************************
Note: the 16 first bytes are anything but clear ... . It appears to finish
     more or less in the same way with lots of "(". The last byte is always
     empty.

512          1024        List of the tracks numbers per pattern. there's
(200h)                   256 possible positions !. It ends when $FF is
                         the number of the first voice. Sometime, all the
                         four voices are $FF ... but not always, so better
                         refer to the first voice :).
                         First value is $00 !.

1532           4         $FF-FF-FF-FF. To mark the end of the upward list.
(5FCh)

1536           ?         Track data. Each track is 64 notes which are 3 bytes
(600h)                   long. So each track is 192 bytes long.

Description of one note :


         Sample number (0->Fh)
              /\
             |  |
  0000-0000  0000-0000  0000-0000
  |       |       |  |  |       |
   \     /         \/    \     /
  relative        effect  effect
    note                  value
   number


effect:
D: Volume slide (A under ptk)

C and F are the same as ptk ... I cant says for the others for I still
look for them :).



relative note number (PTK):

C-1 to B-1 : 856,808,762,720,678,640,604,570,538,508,480,453
C-2 to B-2 : 428,404,381,360,339,320,302,285,269,254,240,226
C-3 to B-3 : 214,202,190,180,170,160,151,143,135,127,120,113

becomes (KSM):

C-1 to B-1 : 01,02,03,04,05,06,07,08,09,0a,0b,0c
C-2 to B-2 : 0d,0e,0f,10,11,12,13,14,15,16,17,18
C-3 to B-3 : 19,1a,1b,1c,1d,1e,1f,20,21,22,23,24


 Follows Sample datas stored like ProTracker.
Nothing is packed..