3

Table Of Contents
Chapter 9 MIDI plug-ins 178
The Event object is not instantiated directly but is a prototype for the following event-
specic object types. All of the following types inherit the methods described above and the
channel property.
Event types
The event types and their properties are passed to HandleMIDI as follows:
NoteOn.pitch(integer number): Pitch from 1–127.
NoteOn.velocity(integer number): Velocity from 0–127. A velocity value of 0 is interpreted as a
note o event, not a note on.
NoteO.pitch(integer number): Pitch from 1–127.
NoteO.velocity(integer number): Velocity from 0–127.
PolyPressure.pitch(integer number): Pitch from 1–127. Polyphonic aftertouch is uncommon
on synthesizers.
PolyPressure.value(integer number): Pressure value from 0–127.
ControlChange.number(integer number): Controller number from 0–127.
ControlChange.value(integer number): Controller value from 0–127.
Tip: Use MIDI.controllerName(number) to look up the name of the controller.
ProgramChange.number(integer number): Program change number from 0–127.
ChannelPressure.value(integer number): Aftertouch value from 0–127.
PitchBend.value(integer number): 14-bit pitch bend value from -8192–8191. A value of 0 is center.
Replace every MIDI event received with a modulation control change message
m Type the following in the Script Editor window. Text following “//” describes the
argument function.
Tip: You can use the JavaScript new keyword to generate a new instance of an Event object of
any type.
function HandleMIDI() {
var cc = new ControlChange; // make a new control change message
cc.number = 1; // set it to controller 1 (modulation)
cc.value = 100; // set the value
cc.send(); // send the event
cc.trace(); // print the event to the console
}
Replace every MIDI event received with a C3 note on/o
m Type the following in the Script Editor window. Text following “//” describes the
argument function.
Tip: You can use the JavaScript new keyword to generate a new instance of an Event object of
any type.
function HandleMIDI() {
var on = new NoteOn; // make a new note on
on.pitch = 60; // set its pitch to C3
on.send(); // send the note
var off = new NoteOff(on); // make a note off using the note on to
initialize its pitch value (to C3)
off.sendAfterBeats(1); // send a note off one beat later
}