Values are in hexadecimal
(B) indicates byte value
(W) indicates BASIC integer value; 5 bytes,
1st byte is hex 40, 4-byte value follows, lsbyte last.
Start of File
"Maestro" 0D (B) (carriage return)
02 (B) indicates type 2 music file
(type 1 is old type not considered here)
Each section that follows starts with a byte 'label' indicating which section follows. Thus the sections may appear in any order. The labels are given on the left hand side:
01 indicates Music data follows (detailed description below)
(W) number of 'Gates'
for C = 1 to 8
{
(W) length of queue of notes and rests in channel C (in bytes)
(data for each note or rest occupies 2 bytes)
}
for G=1 to Number of Gates (input above)
{
(B) data for gate G
}
for C = 1 to 8
{
for Q = 1 to length of note queue in channel C (read above)
{
(B)(B) data for note or rest in channel C at point Q in queue
(data for each note occupies 2 bytes)
}
}
02 indicates Stave data follows
(B) (0..3) number of music staves
(B) (0..1) number of percussion staves
03 indicates Instrument data follows
(instrument names are not recorded; only channel numbers)
8 times:
{
(B) channel number - 1; 1..8 (redundant, always consecutive 1..8)
(B) voice number; 0 = no voice attached
}
04 indicates Volume data follows
for n= 1 to 8
{
(B) Volume on channel n = 0..7 = ppp..fff
}
05 indicates Stereo position data follows
for n= 1 to 8
{
(B) Stereo position of channel n = 0..7 = Full Left..Full Right
}
06 indicates Tempo data follows
(B) 0..14;
/ Aside
Suggested extensions:
1 Queue of 1- or 2-byte 'Gates'.
A 'Gate' is a point in the music when something is interpreted -
e.g. a note, time-signature, key-signature, bar-line
or clef can each occupy a gate
the gate data is 1 byte for a note or rest; 2 bytes for an attribute
(time-signature, key-signature, bar-line or clef)
{
bit 0 = 1 -> Time signature:
bit 1..4 = Number of beats - 1; 1..16
bit 5..7 = Beat type - 1; 1..8
or
bit 0..1 = 01 (binary) -> Key signature
bit 2 0 = #, 1 = b
bit 3..5 0..7
or
bit 0..2 = 001 (binary) -> Clef
bit 3..4 0 = Treble, 1 = Alto, 2 = Tenor, 3 = Bass
bit 5..6 Stave - 1; 1..4
or
bit 0..3 = 0001 (binary) -> Slur *
bit 4 1 = on; 0 = off
bit 6..7 Stave - 1; 1..4
or
bit 0..4 = 00001 (binary) -> Octave shift *
bit 5 0 = up, 1 = down
bit 6..7 Stave - 1; 1..4
or
bit 0..5 = 000001 (binary) -> Bar
or
bit 0..6 = 0000001 (binary) -> Reserved (for what?)
}
or
byte 0 > 0 -> Gate Mask.
bit n = 1 -> gate 1 note/rest from queue n (n=0..7)
}
8 Queues of Notes and Rests, data for each is 2 bytes: Note (bits 3..7 > 0) or Rest (bits 3..7 = 0)
If a rest coincides with a note, its position is determined by the following note on the same channel.
bit Rest Note
0 0 Stem orientation : 0 = up; 1 = down;
1 0 1 = Join beams (barbs) to next note *
2 0 1 = tie with next note
3..7 0 Stave line position, 1..31; 16=centre line
8..10 0 Accidental 0 = natural, 1 = sharp, 2 = flat,
3 = double-sharp, 4 = double-flat,
5 = natural-sharp, 6 = natural-flat.
11..12 number of dots: 0..3