MIDI Player

MIDI has three different use cases: MIDI file playback, interactive MIDI playing, and a mix of these: MIDI file playback with interaction.

MIDI file playback

Playback for a MIDI file works exactly in the same way as for other audio content types.

Interactive MIDI playing

A player is created with the locator device://midi for pure interactive MIDI. Interactive playing is possible by using MIDIControl. MIDIControl can be used for various tasks, for example change MIDI channel volumes, change instrument assignments to channels, play notes, and so forth.

When the player is created this way, default instruments are assigned to channels as follows: Drum set on channel 9, piano on all the others. Processing of MIDI events is started when a player is prefetched, meaning that MIDI commands sent with MIDIControl.shortMidiEvent and MIDIControl.longMidiEvent will take effect right away. Starting the player explicitly is not needed.

MIDI file playback with interaction

In this case a player is created as for plain MIDI file playback, but MIDIControl is obtained and used to control playback and to play along interactively. MIDIControl can be used in the same way as for pure interactive MIDI playing, with a few exceptions:

Default instruments are not assigned to any channels. Only instruments used by the MIDI file are assigned to their corresponding channels. The rest are left unassigned, but can be assigned with MIDIControl.setProgram as suitable.

Processing of MIDI events is started when the player is started, in contrary to the purely interactive case. MIDI events can be sent with MIDIControl.shortMidiEvent and MIDIControl.longMidiEvent when the player is prefetched, but they are queued until the player is started.