MidiSequencer

The MidiSequencer plays Standard Midi Files (SMF files or SMF's). It is modeled on how the SampleActor plays .aiff files.

To use the MidiSequencer implementation, load midi.so and create an actor of type MidiSequencer.

MidiSequencer

In addition to the messages understood by all actors, the MidiSequencer understands the following messages:
PlayFile hActor szFile
Load, play, and unload an SMF file ( PlayFile(szFile) ).
The argument szFile is a string.
RewindAll hActor
Rewind all SMF's ( RewindAll() ).
SetDirectory hActor szFile
Set default directory to load SMF's from ( set_Directory(szFile) ).
The argument szFile is a string.
SetAllDirectory hActor szFile
For all handlers, set directory to load SMF's from ( set_AllDirectory(szFile) ).
The argument szFile is a string.
SetAllBounds hActor tMin tMax
For all handlers, set start and end of played segment (in seconds) ( set_AllBounds(tMin, tMax) ).
The argument tMin has a range of [0, 3600] and defaults to 0.
The argument tMax has a range of [0, 3600] and defaults to 60.
SetLoop hActor bool
Toggle looping ( set_Loop(bool) ).
The argument bool has a range of [0, 1] and defaults to 0.
The argument bool has a range of [0, 1.4013e-45] and defaults to 0.
SetAllLoop hActor tMin tMax [ bool ]
For all handlers, toggle looping ( set_AllLoop(tMin, tMax, bool) ).
The argument tMin has a range of [0, 3600] and defaults to 0.
The argument tMax has a range of [0, 3600] and defaults to 60.
The argument bool has a range of [0, 1] and defaults to 0.
The following MidiSequencer messages are under construction.
SetPlaybackRate hActor rate
Set default playback rate (1 = unchanged, 0.5 = half speed, 0 = frozen) ( set_playbackRate(rate) ).
The argument rate has a range of [0, 1000] and defaults to 1.
SetAllPlaybackRate hActor rate
For all handlers, set playback rate (1 = unchanged, 0.5 = half speed, 0 = frozen) ( setAll_playbackRate(rate) ).
The argument rate has a range of [0, 1000] and defaults to 1.

MidiSequencer handler messages

In addition to the messages understood by all handlers, the handler for the MidiSequencer understands the following messages. Defaults start off with the values specified below, but are in fact whatever the handler's actor's defaults are (possibly changed by sending one of the messages listed above).
DeleteWhenDone hSound
Unload this SMF when it finishes playing ( DeleteWhenDone() ).
JumpTo hSound when
Turn all notes off, then skip to a point in the SMF ( JumpTo(when) ).
The argument when has a range of [0, 3600] and defaults to 1.
Rewind hSound
Turn all notes off, then rewind the SMF to its beginning ( Rewind() ).
SetDirectory hSound szFile
Set directory to load SMF's from ( set_Directory(szFile) ).
The argument szFile is a string.
SetFile hSound szFile
Load an SMF ( set_File(szFile) ).
The argument szFile is a string.
SetBounds hSound tMin tMax
Set start and end of played segment (in seconds) ( set_Bounds(tMin, tMax) ).
The argument tMin has a range of [0, 3600] and defaults to 0.
The argument tMax has a range of [0, 3600] and defaults to 60.
SetLoop hSound [[ tMin tMax ] [ bool ]]
Toggle looping.
The argument tMin has a range of [0, 3600] and defaults to 0.
The argument tMax has a range of [0, 3600] and defaults to 60.
The argument bool has a range of [0, 1] and defaults to 0.
SetPlaybackRate hSound rate
(under construction)
Set playback rate (1 = unchanged, 0.5 = half speed, 0 = frozen) ( set_PlaybackRate(rate) ).
The argument rate has a range of [0, 1000] and defaults to 1.

Examples

LoadDSO midi.so;
midiseq = Create MidiSequencer;
Play two songs in a row:

PlayFile midiseq "MaryHadALittleLamb.mid";
PlayFile midiseq "ThreeBlindMice.mid";

Play one song over and over again:

SetLoop midiseq 1;
PlayFile midiseq "Barneys_Song.mid";

Play two songs at the same time:

seq1 = BeginSound midiseq SetFile "foo.mid";
seq2 = BeginSound midiseq SetFile "bar.mid";

Play two songs over and over again at the same time:

seq1 = BeginSound midiseq SetFile "foo.mid" SetLoop 1;
seq2 = BeginSound midiseq SetFile "bar.mid" SetLoop 1;