Jump to content

Programming Reference:MidiPlayer Class: Difference between revisions

From BCI2000 Wiki
Mellinger (talk | contribs)
No edit summary
 
Mellinger (talk | contribs)
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
==Location==
<tt>BCI2000/src/shared/modules/application/audio</tt>
==Synopsis==
==Synopsis==
The <tt>MidiPlayer</tt> class provides [http://en.wikipedia.org/wiki/MIDI MIDI] output on the level of individual notes, and sequences of notes.
The <tt>MidiPlayer</tt> class provides [http://en.wikipedia.org/wiki/MIDI MIDI] output on the level of individual notes, and sequences of notes.
Line 7: Line 10:
===MidiPlayer(instrument, volume, note, note length, balance)===
===MidiPlayer(instrument, volume, note, note length, balance)===
This constructor creates a <tt>MidiPlayer</tt> object that plays a certain instrument at a given volume. Optionally, a default note, note length, and balance may be specified.
This constructor creates a <tt>MidiPlayer</tt> 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 )===
===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 single note with given length and velocity. All arguments are optional; when unspecified, the default is used.
===PlaySequence(sequence)===
===PlaySequence(sequence)===
Plays a sequence of MIDI notes. The sequence is given as an array of <tt>struct MidiNote</tt> type records. A <tt>MidiNote</tt> 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.
Plays a sequence of MIDI notes. The sequence is given as an array of <tt>struct MidiNote</tt> type records. A <tt>MidiNote</tt> 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.
===StopSequence===
===StopSequence===
Stops sequence playback. When no sequence is being played, this method does nothing.
Stops sequence playback. When no sequence is being played, this method does nothing.
==Remarks==
Each <tt>MidiPlayer</tt> 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 <tt>MidiPlayer</tt> instances using a single channel, one should take care not to have more than 14 <tt>MidiPlayer</tt> instances at any given time.


==See also==
==See also==

Latest revision as of 13:07, 19 June 2008

Location

BCI2000/src/shared/modules/application/audio

Synopsis

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

Methods

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.

PlaySequence(sequence)

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.

StopSequence

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

Remarks

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