Skip to content

Play

The Play functions use a 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.

Creating a Play

Play is a static utility; you don't instantiate it like other objects. Call its methods on the class itself. For example,

Play.midi(score)

Functions

The following Play functions are always available:

Playing MIDI Material

Function Description
Play.midi(material) Play music library material through the synthesizer.
Play.stop() Stop all music started through Play from sounding.
Play.note(pitch, start, duration) Schedule a note to play after a delay and last a set time.
Play.noteOn(pitch) Start a pitch sounding, and leave it sounding.
Play.noteOnPitchBend(pitch) Start a pitch sounding with a pitch bend, and leave it sounding.
Play.noteOff(pitch) Stop a pitch from sounding.
Play.allNotesOff() Stop every note from sounding, on all channels.
Play.frequency(frequency, start, duration) Schedule a frequency to play after a delay and last a set time.
Play.frequencyOn(frequency) Start a frequency sounding, and leave it sounding.
Play.frequencyOff(frequency) Stop a frequency from sounding.
Play.allFrequenciesOff() Stop every frequency from sounding, on all channels.
Play.setPitchBend() Set the pitch bend for a channel, used for notes played next.
Play.getPitchBend() Return the current pitch bend for a channel.
Play.setInstrument(instrument) Set the instrument for a channel.
Play.getInstrument() Return the instrument set for a channel.
Play.setVolume(volume) Set the main volume for a channel.
Play.getVolume() Return the main volume for a channel.
Play.setPanning(panning) Set the main stereo position for a channel.
Play.getPanning() Return the main stereo position for a channel.
Play.getSoundfont() Return the path of the soundfont currently used for playback.
Play.setSoundfont(soundfont) Set the soundfont used for playback.

Playing Musical Material with AudioSamples

Function Description
Play.audio(material, audioSamples) Play music library material using audio samples as the instruments.
Play.audioNote(pitch, start, duration, audioSample) Schedule a note to play with an audio sample, after a delay and lasting a set time.
Play.audioOn(pitch, audioSample) Start a pitch sounding with an audio sample, and leave it sounding.
Play.audioOff(pitch, audioSample) Stop a pitch from sounding on an audio sample.
Play.allAudioNotesOff() Stop every note from sounding on all audio samples.

Running Code with Musical Material

Function Description
Play.code(material, actions) Run your own functions in time with music library material.