home *** CD-ROM | disk | FTP | other *** search
/ Archive Magazine 1996 / ARCHIVE_96.iso / discs / mag_discs / volume_8 / issue_06 / risc_os / MusicFiles < prev    next >
Text File  |  1989-01-04  |  5KB  |  176 lines

  1. Maestro Music File format
  2. -------------------------
  3.  
  4. Values are in hexadecimal
  5. (B) indicates byte value
  6. (W) indicates BASIC integer value; 5 bytes,
  7.     1st byte is hex 40, 4-byte value follows, lsbyte last.
  8.  
  9. Start of File
  10.  
  11. "Maestro" 0D (B) (carriage return)
  12.  
  13. 02 (B)  indicates type 2 music file
  14.         (type 1 is old type not considered here)
  15.  
  16. Each section that follows starts with a byte 'label' indicating
  17. which section follows. Thus the sections may appear in any order.
  18. The labels are given on the left hand side:
  19.  
  20. 01 indicates Music data follows (detailed description below)
  21.    (W) number of 'Gates'
  22.    for C = 1 to 8
  23.      {
  24.      (W) length of queue of notes and rests in channel C (in bytes)
  25.          (data for each note or rest occupies 2 bytes)
  26.      }
  27.    for G=1 to Number of Gates (input above)
  28.      {
  29.      (B) data for gate G
  30.      }
  31.    for C = 1 to 8
  32.      {
  33.      for Q = 1 to length of note queue in channel C (read above)
  34.        {
  35.        (B)(B) data for note or rest in channel C at point Q in queue
  36.           (data for each note occupies 2 bytes)
  37.        }
  38.      }
  39.  
  40. 02 indicates Stave data follows
  41.    (B) (0..3) number of music staves
  42.    (B) (0..1) number of percussion staves
  43.  
  44. 03 indicates Instrument data follows
  45.    (instrument names are not recorded; only channel numbers)
  46.    8 times:
  47.      {
  48.      (B) channel number - 1;  1..8   (redundant, always consecutive 1..8)
  49.      (B) voice number; 0 = no voice attached
  50.      }
  51.  
  52. 04 indicates Volume data follows
  53.    for n= 1 to 8
  54.      {
  55.      (B) Volume on channel n = 0..7 = ppp..fff
  56.      }
  57.  
  58. 05 indicates Stereo position data follows
  59.    for n= 1 to 8
  60.      {
  61.      (B) Stereo position of channel n = 0..7 = Full Left..Full Right
  62.      }
  63.  
  64. 06 indicates Tempo data follows
  65.    (B)  0..14;
  66.     = 40,50,60,65,70,80,90,100,115,130,145,160,175,190,210 beats per minute
  67.      ( convert to values to program into SWI Sound_Tempo by
  68.        Sound_Tempo value = Beats per minute * 128 * 4096 DIV 6000 )
  69.  
  70. End Of File
  71.  
  72.  / Aside
  73.  
  74.  Suggested extensions:
  75.  
  76.  1. Permit any number of repetitions of the above data within one file
  77.  to allow for changes in any parameters, such as tempo or volume, in
  78.  the middle of a piece of music.
  79.  Parts of the piece could be edited as separate files in Maestro,
  80.  and then concatenated to make an entire piece (retaining the separate
  81.  files for continued editability.
  82.  Only if complete compatibility is required, would it be necessary to
  83.  modify Maestro,
  84.  2. Add extra section (labelled 7) for title string of piece of music
  85.     as zero-byte-terminated string.
  86.  
  87.  3. Add extra section (labelled 8) for text string names of instruments
  88.      Each name should be zero-byte-terminated, and should define the
  89.      names of each voice number used in ascending order in section 3.
  90.      This section should be terminated by an extra zero byte
  91.      (2 consecutive) to ensure it is simple to scan through. It is,
  92.      however not obvious what should be done if the instrument isn't
  93.      installed. Perhaps give a warning on starting to play.
  94.     
  95.  4. Add extra section (labelled 9) for MIDI channels setup information
  96.      for C = 1 to 8
  97.        {
  98.        (B) MIDI channel number on this stave channel C.
  99.            1..16; 0 = not transmitted over MIDI
  100.        }
  101.      
  102.  / End Aside
  103.  
  104.  
  105. Detailed description of Music Data
  106. ----------------------------------
  107. There are 9 queues:
  108.  
  109. 1 Queue of 1- or 2-byte 'Gates'.
  110.    A 'Gate' is a point in the music when something is interpreted -
  111.    e.g. a note, time-signature, key-signature, bar-line
  112.         or clef can each occupy a gate
  113.    the gate data is 1 byte for a note or rest; 2 bytes for an attribute 
  114.    (time-signature, key-signature, bar-line or clef)
  115.   {
  116.   byte 0 = 0  -> Music Attribute follows:
  117.     {
  118.     byte 1 is prefix-encoded data for time-signature, key-signature,
  119.     clef, slur, octave or bar:
  120.  
  121.       bit 0     = 1   -> Time signature:
  122.         bit 1..4  = Number of beats - 1;  1..16
  123.         bit 5..7 = Beat type - 1;         1..8 
  124.  
  125.      or
  126.       bit 0..1  = 01 (binary)  -> Key signature
  127.         bit 2      0 = #, 1 = b
  128.         bit 3..5   0..7
  129.  
  130.      or
  131.       bit 0..2  = 001 (binary) -> Clef
  132.         bit 3..4  0 = Treble, 1 = Alto, 2 = Tenor, 3 = Bass
  133.         bit 5..6  Stave - 1;  1..4
  134.  
  135.      or
  136.       bit 0..3  = 0001 (binary) -> Slur  *
  137.         bit 4     1 = on; 0 = off
  138.         bit 6..7  Stave - 1;  1..4
  139.  
  140.       or
  141.       bit 0..4  = 00001 (binary) -> Octave shift  *
  142.         bit 5     0 = up, 1 = down
  143.         bit 6..7  Stave - 1;  1..4
  144.  
  145.       or
  146.       bit 0..5  = 000001 (binary) -> Bar
  147.  
  148.       or
  149.       bit 0..6  = 0000001 (binary) -> Reserved   (for what?)
  150.     }
  151.  
  152.   or
  153.   byte 0 > 0  -> Gate Mask.
  154.     bit n = 1 -> gate 1 note/rest from queue n (n=0..7)
  155.   }
  156.  
  157. 8 Queues of Notes and Rests, data for each is 2 bytes:
  158.   Note (bits 3..7 > 0) or Rest (bits 3..7 = 0)
  159.  
  160.   If a rest coincides with a note, its position is
  161.   determined by the following note on the same channel.
  162.  
  163.   bit       Rest     Note
  164.   0          0     Stem orientation : 0 = up; 1 = down;
  165.   1          0     1 = Join beams (barbs) to next note *
  166.   2          0     1 = tie with next note
  167.   3..7       0     Stave line position, 1..31; 16=centre line
  168.   8..10      0     Accidental 0 = natural, 1 = sharp, 2 = flat,
  169.                               3 = double-sharp, 4 = double-flat,
  170.                               5 = natural-sharp, 6 = natural-flat.
  171.   11..12  number of dots:  0..3
  172.   13..15  type: breve = 0 to hemidemisemiquaver = 7
  173.  
  174.  
  175. * = not implemented in Maestro
  176.