Here's some info about iMUSE, gleaned from its patent specs:
http://www.google.com/patents/US5315057 This is actually quite helpful, because it tells us exactly the commands that are expected to be given outside of the standard MIDI commands:
Jumping/looping md-- jump (sound, chunk, beat, tick)
md-- set-- loop (sound, count, start-- beat, start-- tick, end-- beat, end-- tick)
md-- clear-- loop (sound)
The jump and set loop points are probably defined by SysEx messages in the MIDI file. Clear-loop is probably given by the engine to proceed in a song to a later part.
md-- scan (sound, chunk, beat, tick)
I think this is how those 2 seconds of opening silence are skipped. The patent specs says this skips silence in the file until a musical note is found, while ensuring that MIDI system commands in that silent gap are handled. Probably used so that the composers had a lot of room to edit in commands at the beginning without having to worry about overwriting or pushing back the actual music data. So, this would be called every time a new file is played.
Enabling/disabling instruments like the concourse doors do
md-- set-- part-- enable (sound, chan, state)
md-- set-- part-- vol (sound, chan, vol)
Seems straightforward. Chan tells which MIDI channel to enable/disable. In the main concourse song, the Training door flute is Channel 4, the Historical Mission trumpet is Channel 7 and the TOD Desk trumpet is Channel 6. For recorded music implementation, we can just split those channels into separate music files.
md-- set-- hook (sound, class, val, chan)
md-- enqueue-- trigger (sound, marker-- id)
md-- enqueue-- command (param1 . . ., param7)
md-- clear-- queue ()
md-- query-- queue (param)
This is probably how the inflight state transitions and event interludes are handled. State changes are placed into a queue and played at an appropriate time (such as the end of a measure). So momentary event cues like Ship Arrival are probably most simply done by queuing the Event song and then queuing the current state after it, so it goes back.
The ones we probably don't need to care about: md-- set-- vol (sound, vol)
md-- fade-- vol (sound-- number, vol, time)
These are just standard volume changes. We can define it on our own easy.
md-- set-- speed (sound, speed)
I dont think X-Wing ever calls for speed changes outside of the tempo changes defined regularly in the MIDI files, so set speed can probably be ignored.
md-- set-- transpose (sound, rel-- flag, transpose)
md-- set-- detune (sound, detune)
md-- set-- pan (sound, pan)
I don't think X-Wing even uses these. It was probably used a lot in the Monkey Island games, but that's not our problem!
md-- set-- priority (sound, priority)
Used for playing sound effects and music on the same soundcard, accommodating their limited channels. We don't need to worry about that today!
Also, the .GMID files are actually nothing more than Midi Type 2 with some extra information in front of the "MThd" MIDI header. So, if you wanted to parse it directly with the MIDI player, just skip everything until "MThd" is encountered until we figure out what the extra header stuff signifies. So special format interpretation beyond figuring out what each SysEx command does is probably not necessary. Note that Type 2 MIDIs can contain several songs in one. For example, the main concourse MIDI file contains 4 tracks: the main track, the transition from the Register room, taking the shuttle to a new ship, and one other one I can't quite place.