Play Functions

The Play functions use the Java MIDI synthesizer to play musical material. The first function, Play.midi(), is used to render musical compositions stored in Note, Phrase, Part, and Score objects. The other Play functions are more advanced, as they are intended for building interactive musical instruments and installations.

Function

Description

Play.midi(material)

Play musical material through the Java synthesizer (material may be a Note, Phrase, Part, or Score).

Play.noteOn(pitch, volume, channel)

Starts pitch sounding. Specifically, it sends a NOTE_ON message with pitch (0-127), at given volume (0-127 – default is 100), to played on channel (0-15 – default is 0) through the Java synthesizer.

Play.noteOff(pitch, channel)

Stops pitch from sounding. Specifically, it sends a NOTE_OFF message with pitch (0-127), on given channel (0-15 – default is 0) through the Java synthesizer. If the pitch is not sounding on this channel, this has no effect.

Play.allNotesOff()

Stops all notes from sounding on all channels.

Play.setInstrument(instrument, channel)

Sets a MIDI instrument (0-127 – default is 0) for the given channel (0 – 15, default is 0). Any notes played through channel will sound using instrument.

Sets the global (main) volume (0-127) for this channel (0-15) This is different from the velocity level of individual notes – see Play.noteOn().

Play.getVolume(channel)

Returns the global (main) volume (0-127) for this channel (0-15).

Play.setPanning(position, channel)

Sets the global (main) panning position (0-127) for this channel (0-15) The default position is in the middle (64).

Play.getPanning(channel)

Returns the global (main) position (0-127) for this channel (0-15).

Play.setPitchBend(bend, channel)

Sets the pitch bend for this channel (0-15 – default is 0) to the Java synthesizer object. Pitch bend ranges from -8192 (max downward bend) to 8191 (max upward bend). No pitch bend is 0 (which is the default). If you exceed these values the outcome is undefined, (it may wrap around or it may cap depending on the system.)

Play.getPitchBend(channel)

Returns the current pitch bend for this channel (0-15 – default is 0).

Play.frequencyOn(frequency, volume, channel)

Starts a note sounding at the given frequency and volume (0-127 – default is 100), on channel (0-15 – default is 0).Warning: You should play only one frequency per channel. (Since this uses pitch bend indirectly, it will affect the pitch of all other notes sounding on this channel.)

Play.frequencyOff(frequency, channel)

Stops a note sounding at the given frequency on channel (0-15 – default is 0).Warning: You should play only one frequency per channel. (Since the frequency gets translated to a pitch and a pitch bend, this will also affect notes with nearby frequencies on this channel.)

Play.allFrequenciesOff()

Same as Play.allNotesOff(). Stops all notes from sounding on all channels.

Play.note(pitch, start, duration, volume, channel)

Schedules a note with pitch (0-127) to be sounded after start milliseconds, lasting duration milliseconds, at given volume (0-127 – default is 100), on channel (0-15 – default is 0) through the Java synthesizer.