3.5

Table Of Contents
203MainStage Effects
Important: To enable the GetTimingInfo feature, you need to add var NeedsTimingInfo =
true; at the global script level (outside of any functions).
Tutorial script 4: Process MIDI Callback
Text following /* shows comments that explain the JavaScript code.
/* Define NeedsTimingInfo as true at the global level to enable
GetHostInfo() */
var NeedsTimingInfo = true;
function ProcessMIDI() {
var info = GetTimingInfo(); /* get a TimingInfo object from the host
if the transport is running */
if (info.playing) {
Trace(info.tempo); /* print the tempo in the plug-in console */
}
}
MainStage Scripter MIDI plug-in GetParameter function
The GetParameter() function retrieves information from parameters defined with
var PluginParameters. Parameter variables can include type, minimum and maximum
range values, and default values within the defined range, for example. Also see Create
MainStage Scripter MIDI plug-in controls.
The GetParameter name argument must match the defined PluginParameters name value.
Load the corresponding Tutorial setting to view the script in the Script Editor. This will help
you to understand the syntax structure and layout of code and comments. See Use the
MainStage Scripter MIDI plug-in Script Editor.
Tutorial script 5: Velocity Slider
Text following /* shows comments that explain the JavaScript code.
function HandleMIDI(event) {
event.velocity = GetParameter("Note Velocity");
/* retrieves "Note Velocity" information from the defined "Note Velocity"
parameter */
event.send(); /* sends the note event */
}
var PluginParameters = [{name:"Note Velocity", type:"lin", minValue:1,
maxValue:127, numberOfSteps:126, defaultValue:80"}];
/* create a linear parameter called "Note Velocity" with a range of 1 to
127, and a default value of 80 */