Digital Sound & Music: Concepts, Applications, & Science, Chapter 6, last updated 6/25/2013
tracks, Format1 files are for multiple tracks, and Format 2 files are for multiple tracks where a
separate song performance can be represented. (Format 2 is not widely used.) SMF files are
platform-independent, interpretable on PCs, MAC, and Linux machines.
Blocks of information in SMF files are called chunks. The first chunk is the header
chunk, followed by one or more data chunks. The header and data chunks begin with four
bytes (a four-character string) identifying the type of chunk they are. The header chunk then has
four bytes giving the length of the remaining fields of the chunk (which is always 6 for the
header), two bytes telling the format (MIDI 0, 1, or 2), two bytes telling the number of tracks,
and two bytes with information about how timing is handled.
Data are stored in track chunks. A track chunk also begins with four bytes telling the
type of chunk followed by four bytes telling how much data is in the chunk. The data then
follow. The bytes which constitute the data are track events: either regular MIDI events like
Note On; meta-events like changes of tempo, key, or time signature; or sys-ex events. The
events begin with a timestamp telling when they are to happen. Then the rest of the data are
MIDI events with the format described in Section 1. The structure of an SMF file is illustrated in
Figure 6.47.
Figure 6.47 SMF file structure
MIDI event timestamps tell the change in time between the previous event and the current
one, using the tick-per-beat, frame rate in frames/s, and tick/frame defined in the header. The
timestamp itself is given in a variable-length field. To accomplish this, the first bit of each byte
in the timestamp indicates how many bytes are to follow in the timestamp. If the bit is a 0, then
Previous Page Next Page