Programming Reference:MidiPlayer Class

From BCI2000 Wiki
Jump to: navigation, search




The MidiPlayer class provides MIDI output on the level of individual notes, and sequences of notes.


Default Constructor, Copy Constructors, Assignment Operator, Destructor

These provide the full set of methods required to use MidiPlayer as a data type in STL containers, such as std::vector<MidiPlayer>.

MidiPlayer(instrument, volume, note, note length, balance)

This constructor creates a MidiPlayer object that plays a certain instrument at a given volume. Optionally, a default note, note length, and balance may be specified.

Play(note, length, velocity)

Plays a single note with given length and velocity. All arguments are optional; when unspecified, the default is used.


Plays a sequence of MIDI notes. The sequence is given as an array of struct MidiNote type records. A MidiNote record has a "note" field which describes the MIDI note to play, and a "duration" field which describes the note's duration in ms. A note field of -1 indicates a pause, a duration field of 0 indicates the end of a sequence.


Stops sequence playback. When no sequence is being played, this method does nothing.


Each MidiPlayer instance reserves its own MIDI channel for output. Omitting channel 10, which is reserved for percussion, 14 channels are available in the MIDI standard. To avoid undesired effects from multiple MidiPlayer instances using a single channel, one should take care not to have more than 14 MidiPlayer instances at any given time.

See also

Programming Reference:TextToSpeech Class, Programming Reference:WavePlayer Class