![]() |
![]() |
Compressed Midi File Format
The compressed midi file format is composed of a header and up to sixteen individual tracks. Each midi channel will have its own track. If there are no midi events for a particular channel, the track will not be created, and the offset to that track will be set to zero.
The compressed midi file header is a collection of 16 offsets and a division value.
typedef struct {
u32 trackOffset[16];
u32 division;
} ALCMidiHdr;
The offset is specified in bytes from the begining of the file to the begining of the track. The division value is taken from the input midi file.
The format for the individual tracks is similar to the format used in a standard midi file. Each track consists of a series of events, seperated by delta times in ticks. Ticks are specified using variable length numbers, and ever event must have a delta value, even if that value is zero. Midi events are of the same format as that used in the standard midi file except as specified below.
The compressed midi file format uses a system of matching patterns in the data, and replacing them with markers, instead of repeating the data. When constructing tracks, any pattern of data may be replaced by any previous track data with a marker. A pattern marker consists of four bytes. The first byte is 0xFE. The second two bytes are an unsigned 16 bit value that specifies the difference, in bytes, between the begining of the marker, and the begining of the pattern. The last byte is the length of the pattern. In order to distinguish between a data byte of 0xFE and a pattern marker’s first byte, any data byte of 0xFE will be followed by another byte of 0xFE.
Note: The maximum pattern length is 0xFF and the maximum distance between the marker and the pattern is 0xFDFF.
Nesting of patterns is not supported. If a marker is encountered within a repeated pattern, the marker data will be returned to the sequence player, as actual midi data.
Note: Patterns replaced with markers may not contain bytes of value 0xFF or the current loop count byte of a loop end event.
Copyright © 1999 Nintendo of America Inc. All Rights Reserved Nintendo and N64 are registered trademarks of Nintendo Last Updated January, 1999 |