Showing changes from revision #7 to #8:
Added | Removed | Changed
The MusicFile filetype is primarily used by the Maestro application. MusicFiles allow music to be played by the 8-bit sound system, and are limited to 8 channels.
Size | Description |
8 | ‘Maestro’, followed by linefeed character (&0A ) |
1 | 2 (Type 2 MusicFile) |
The Header block is followed by zero or more of the following blocks. The original spec claimed they could appear in any order, but in fact Maestro will expect blocks 1-6 before any others. Note that block types 7, 8 and 9 are not currently implemented by Maestro.
Size | Description |
1 | 1 |
5 | Number of bytes in the Gates array1 |
5×8 | Number of bytes in the queue of notes and rests for each of the 8 channels1 |
n | Gate data (see below) |
q1…q8 | Data for all notes and rests in channels 1-8 |
1 Stored as a BASIC integer: &40
followed by 4 bytes of data, most significant first.
Size | Description |
1 | 2 |
1 | Number of staves (0-3) |
1 | Number of percussion staves (0-1) |
The staves value is incremented by one to create a range of 1-4 staves, whereas the percussion value controls whether a single percussion stave is added. Earlier versions of Maestro permitted more than one percussion stave.
In Maestro, the distribution of channels to staves is as follows:
Music staves | Percussion staves | Stave 1 | Stave 2 | Stave 3 | Stave 4 | Percussion |
---|---|---|---|---|---|---|
1 | 0 | 1-8 | ||||
1 | 1 | 1-7 | 8 | |||
2 | 0 | 1-4 | 5-8 | |||
2 | 1 | 1-4 | 5-7 | 8 | ||
3 | 0 | 1 | 2-5 | 6-8 | ||
3 | 1 | 1 | 2-5 | 6-7 | 8 | |
4 | 0 | 1-2 | 3-4 | 5-6 | 7-8 | |
4 | 1 | 1-2 | 3-4 | 5-6 | 7 | 8 |
Instrument names are not recorded, only channel numbers.
Size | Description |
1 | 3 |
This is followed by 8 blocks:
Size | Description |
1 | Channel number (1-8, consecutive) |
1 | Voice number (0=none attached) |
Size | Description |
1 | 4 |
1×8 | Volume of channel (0-7) |
Size | Description |
1 | 5 |
1×8 | Stereo position of channel (0-6, left to right) |
Size | Description |
1 | 6 |
1×8 | Tempo value (0-14) |
Tempo values correspond to the following beats per minute: 40, 50, 60, 65, 70, 80, 90, 100, 115, 130, 145, 160, 175, 190 and 210.
To convert to values suitable for use with Sound_QTempo, use the formula:
Sound_QTempo value = beats per minute * 128 * 4096 / 6000
Size | Description |
1 | 7 |
n | Null-terminated string of n characters length |
Size | Description |
1 | 8 |
n1…n8 | 8 null-terminated strings for each Voice number used in ascending order, corresponding to data in block type 3, above |
Size | Description |
1 | 9 |
1×8 | MIDI channel for Instrument (1-16, or 0 for not MIDI) |
A Gate is a point in the music where something is interpreted: a note, time signature, key signature, bar line or clef, for example. A note or a rest takes up 1 byte, whereas all other attributes, such as key signatures, etc, take up 2 bytes, where the first byte is 0 and the second contains data on the attribute.
Bits | Description |
0-7 | Gate mask: bit n set => gate 1 note/rest from queue n. |
Byte 2 bits | Description |
0 | %1 |
1-4 | Beats per bar (0-15) |
5-7 | Beat type (0-7, breve to hemidemisemiquaver) |
Byte 2 bits | Description |
0-1 | %10 |
2 | Accidental type (0=sharp, 1=flat) |
3-5 | Number of accidentals (0-7) |
6-7 | Reserved (must be 0) |
Byte 2 bits | Description |
0-2 | %100 |
3-4 | 0=treble, 1=alto, 2=tenor, 3=bass |
5 | Reserved (must be 0) |
6-7 | Stave (0-3) |
Maestro currently only implements treble and bass clefs.
Byte 2 bits | Description |
0-3 | %1000 |
4 | 1=on, 0=off |
5 | Reserved (must be 0) |
6-7 | Stave (0-3) |
Byte 2 bits | Description |
0-4 | %10000 |
5 | 0=up, 1=down |
6-7 | Stave (0-3) |
Byte 2 bits | Description |
0-5 | %100000 |
6 | 0=single barline, 1=double barline |
7 | Reserved (must be 0) |
Double barlines implemented in Maestro 2.11. Earlier versions will ignore double barlines in MusicFiles, and display single barlines instead.
Bits 6 and 7 of the attribute byte are reserved for future expansion. Maestro currently does not implement types 4 and 5 (slurs and octave shifts).
Notes/rests are stored in 2-byte blocks.
Bits | Description |
0 | Stem orientation (0=up, 1=down) |
1 | |
2 | Tie (0=no tie, 1=tie to next |
3-7 | Stave line position (1-31; 16=centre) |
8-10 | Accidental (0-7)3 |
11-12 | Number of dots (0-3) |
13-15 | Type (0-7, breve to hemidemisemiquaver) |
2 Tie orientation was implemented in version 2.14 of Maestro. In earlier versions of the file specification, this bit was described as being used to mark the note as having a beam connected to the next note. However, this was never implemented in Maestro, and so has been repurposed.
3 Accidental values:
0=None
1=Natural
2=Sharp
3=Flat
4=Double-sharp
5=Double-flat
6=Natural sharp
7=Natural flat
Bits | Description |
0-7 | Reserved (must be 0) |
8-10 | Stave line position (0-7)4 |
11-12 | Number of dots (0-3) |
13-15 | Type (0-7, breve to hemidemisemiquaver) |
4 Stave line positions for rests were introduced in Maestro 2.13. Previously, these bits were all unset. In order to maintain compatibility with older versions, a value of 0 for the stave line position is interpreted as the centre stave line. Values 1, 2 and 3 are below the centre line in ascending height order (ie, 1 is furthest from the centre line), and 5, 6 and 7 are above, also in ascending order. The ‘resolution’ is doubled, so that a rest line position of 5 is equivalent to a note line position of 18, 6 is equivalent to 20, 7 to 22, etc.
If a rest coincides with a note, its position is determined by the following note on the same channel.