MidiOut

The MidiOut class may be used in your programs to send output to MIDI devices that accept output events (e.g., an external MIDI synthesizer).  These devices need to be physically connected (via wire) to your computer.

To use it, you need following in your program:

Use the following function to create a MidiOut object:

Function Description
MidiOut() Creates a new MidiOut object to connect to an output MIDI device.  When called, it presents the user with a GUI to select one from the available MIDI devices (see figure 9.4).

 

Once a MIDI output object, synth, has been created the following functions are available:

Function Description
synth.noteOn(pitch, velocity, channel) Sends a NOTE_ON message with pitch (0-127), at a given velocity (0-127 – default is 100), to channel (0-15 – default is 0) on the mOutput device.
synth.noteOff(pitch, channel) Sends a NOTE_OFF message with pitch (0-127), on given channel (0-15 – default is 0) on the mOutput device.  If the pitch is not sounding on this channel, this has no effect.
synth.setInstrument(instrument, channel) Sets a MIDI instrument (0-127 – default is 0) for the given channel (0 – 15, default is 0) on the mOutput device.  Any notes played through channel will sound using instrument.
synth.playNote(pitch, start, duration, velocity, channel) Schedules playing of a note with pitch at the given start time (in milliseconds from now), with duration (in milliseconds from start time), velocity (0-127 – default is 100), to channel (0-15 – default is 0) on the mOutput device.
synth.play(material) Play music library material (Score, Part, Phrase, Note) on the mOutput device.

For more information, see chapter 9.