3.5

Table Of Contents
207MainStage Effects
Tutorial script 7: Event Creation
In MainStage, this example replaces every received MIDI event with a modulation control
change message.
Text following /* shows comments that explain the JavaScript code.
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 */
}
Tutorial script 8: Event Modification
In MainStage, this example replaces every received MIDI event with a C3 note on/off. The
example also uses the NeedsTimingInfo variable. See Use the JavaScript TimingInfo object.
Text following /* shows comments that explain the JavaScript code.
Tip: You can use the JavaScript “new” keyword to generate a new instance of an
Event object of any type.
var NeedsTimingInfo = true; /* needed for .sendAfterBeats() to work */
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 */
}
Tutorial script 15: Control Plug-ins
In MainStage, you can create user-definable MIDI CC messages, or you can control plug-in
parameters. TargetEvent reads the parameter to be modified from a menu where the user
can select a destination MIDI CC. Alternately, you can use the Learn Plug-in Parameter
feature to assign any plug-in parameter inserted after (below) Scripter in the same channel
strip. The chosen destination is saved with the plug-in setting.
Text following /* shows comments that explain the JavaScript code.
Tip: You can use the JavaScript “new” keyword to generate a new instance of an
Event object of any type.
TargetEvent properties:
TargetEvent.target(string) /* Name of target menu entry */
TargetEvent.value(float) /* Value of set Target from 0.0 to 1.0 */