Play provides various functions to play musical material stored in Note, Phrase, Part, and Score objects.
Play.midi() uses the internal MIDI synthesizer to play musical material stored in Note, Phrase, Part, and Score objects.
| Function | Description |
| Play.midi(material) | Play musical material through the Java synthesizer (material may be a Note, Phrase, Part, or Score). |
The other Play functions are more advanced, and are intended for building interactive musical instruments.
| Play.noteOn(pitch, volume, channel, panning) | 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), with panning (0-127). |
| 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). If the pitch is not sounding on this channel, this has no effect. |
| Play.note(pitch, start, duration, volume, channel, panning) | Plays 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), with panning (0-127). |
| Play.allNotesOff() | Stops all notes from sounding on all channels. |
Same as above, but using frequencies (e.g., 440.0 is same as A4).
| Play.frequencyOn(frequency, volume, channel, panning) | Starts frequency sounding. Specifically, it sends a NOTE_ON message for this frequency (in Hz), at given volume (0-127 – default is 100), to played on channel (0-15 – default is 0), with panning (0-127). |
| Play.frequencyOff(frequency, channel) | Stops frequency from sounding. Specifically, it sends a NOTE_OFF message for this frequency (in Hz), on given channel (0-15 – default is 0). If the frequency is not sounding on this channel, this has no effect. |
| Play.frequency(frequency, start, duration, volume, channel, panning) | Plays a note with this frequency (in Hz) to be sounded after start milliseconds, lasting duration milliseconds, at given volume (0-127 – default is 100), on channel (0-15 – default is 0), with panning (0-127). |
| Play.allFrequenciesOff() | Stops all frequencies from sounding on all channels. |
You can also make global changes interactively on instrument, volume, panning, and pitch bend.
| Function | Description |
| 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. |
| Play.getInstrument(channel) | Returns the MIDI instrument (0-127) assigned to channel (0 – 15, default is 0). |
| Play.setVolume(volume, channel) | 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). NOTE: Global panning does not affect the panning of a score being played through Play.midi() or Play.audio(). |
| 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 (this is the default). |
| Play.getPitchBend(channel) | Returns the current pitch bend for this channel (0-15 – default is 0). |