polarbreeze wrote:Doug Kerr wrote:What seems to have happened here is this...
Hey, nice work, Doug. Fast too! I have to take some time to digest all that. Meanwhile I'm missing a piece of knowledge about MIDI files. I'm not familiar with the concept of "track" in a MIDI file. All my MIDI education has been in the context of a real-time MIDI data stream and (as far as I know anyhow), there is no concept of "track" there - it has meaning only in the file
Quite so.
Can you point me to a reference where I could acquaint myself with that?
I'll do it right here.
Tracks in MIDI filesIn a MIDI file, the various events can be placed in separate "compartments" called "tracks". This has no direct relationship to a MIDI message stream. For example, there is no indication in a MIDI message as to the "track" in which the source event was held in source file. Tracks are creatures of MIDI files only, not of MIDI streams.
Tracks exist primarily for "administrative" convenience in the manipulation of the data. For example, the sequencist may want to use a separate track for each "instrument" in a composition. This allows the note events for that instrument to be isolated for display or attention. They can easily be shown on separate staves in a notation view in the editor.
There is not necessarily any relationship between the channels for events and the tracks in which they are held. Nevertheless, the sequencist may declare a default channel for each track. Then, as notes are added in that track, they will initially be tagged for that channel. But in the typical MIDI editor-sequencer, one can reset the channel for any individual event (usually in an "event list" view).
When the file is sequenced, the messages are sent out in the time sequence of the events, with the events in all tracks being considered a common source pool for that at sequencing time. Each message will carry the channel stored for it in its event in the file (which it may have gotten in several ways).
MIDI meta-eventsIn a typical MIDI file, the first track in fact contains no actual "events" (that is, no Note ON or of Note OFF events, no Volume events, and so forth. It contains only the
meta-events in the file.
Meta-events do not correspond to (or spawn the emission of) MIDI messages. They instead give instructions to the sequencer or other recipient of the MIDI file. They indicate such things as:
• The initial tempo at which the file should be sequenced.
• The time signature that should be used in displaying the note events in the editor (especially in a "notation" view, but also in a piano roll view). (Note that the time tags for the individual events are not themselves based on measures.)
• The declaring the definition of a
tick for the file (what fraction of a "quarter note" is it). Common values are 120, 240 (used in Encore in exported MIDI files), and 480. Encore will properly interpret incoming MIDI files with other tick factors. The actual factor is formally called "parts per quarter note" (PPQN).
There is no conceptual need for these meta-events to be sequestered in their own track, but it can prevent clutter in dealing with the data. Encore puts all the pertinent meta-events in Track 0, which has nothing else.
Back to tracks: If in fact the sequencist has chosen to consider a track to be the "container" for the stuff for one instrument when composing, then it is reasonable to presume an equivalence between tracks and staves when reading a MIDI file into a score-oriented system (such as Encore) - and Encore in fact proceeds on that basis.
Doug