This is an old revision of the document!
Table of Contents
MUS File Format
License
The bulk of information for this article comes from public domain sources, in particular The MUS File Format by Vladimir Arnost. The rest was filled in through various sources and contributions. As such, even though most articles on this site are licensed under the Creative Commons Attribution license, this article is here by released into the public domain.
File Structure
The MUS file format is similar to the Midi file format. It consists of a header, a variable length list of instruments used followed by music events. Unlike the Midi file, the MUS file has only a single track.
Header
The header always starts with a magic value 'MUS' 0x1A. Following the magic value is a 2 byte length and 2 byte offset value. The offset specifies the offset from the beginning of the file where the actual midi commands begin. The length specifies the length of the score from the offset to the end of the file. Because the length is a 2 byte value the score is limited to 64KB.
The channels field specifies the number of channels that are used in the score not including channel 15. The sec_channels field specifies the number of secondary channels used. num_instruments indicates the number of instruments contained in the variable length instruments list.
4D 55 53 1A ll ll oo oo cc cc ss ss nn nn dd dd
struct mus_header { unsigned int id; // identifier "MUS" 0x1A unsigned short length; // the length of the score unsigned short offset; // score offset from beginning of file unsigned short channels; // count of primary channels unsigned short sec_channels; // count of secondary channels unsigned short num_instruments; // number of instruments in variable length section unsigned short dummy; unsigned short instruments[]; // variable-length list of instruments };