X

Table Of Contents
Chapter 9 MIDI plug-ins 19 4
Retrieve plug-in parameter values
Call GetParameter() with the parameter name to return a value (number object) with the
parameter’s current value. GetParameter() is typically used inside the HandleMIDI function or
ProcessMIDI function.
This code example converts modulation events into note events and provides a slider to
determine note lengths.
m Type the following in the Script Editor window. Text following “//” describes the
argument function.
var PluginParameters = [{name:"Note Length"}]; // create a slider
(default range 0.0 - 1.0)
function HandleMIDI(e) {
if (e instanceof ControlChange && e.number == 1) { // if event is
modulation wheel
var note = new NoteOn; // create a NoteOn
object
note.pitch = e.value; // use cc value as note
pitch
note.velocity = 100; // use velocity 100
note.send(); // send note on
var off = new NoteOff(note); // create a NoteOff
object that inherits the NoteOn's pitch and velocity
var delayInBeats = GetParameter("Note Length") + 0.1; // retrieve the
parameter value of the slider you created (add 0.1 to guarantee note on and
off are not simultaneous)
off.sendAfterBeats(delayInBeats); // send note off after
the length in beats is set via the slider
}
}