3.5

Table Of Contents
205MainStage Effects
Tutorial script 6: Parameter Changed Callback
Print parameter changes to the plug-in console. This example also creates a slider in the
plug-in window and assigns the ParameterChanged function to it.
Text following /* shows comments that explain the JavaScript code.
var PluginParameters = [{name:"Slider", type:"lin", minValue:0, maxValue:1,
numberOfSteps:100, defaultValue:0}];
/* create a slider with a value range of 0.0 to 1.0 and a default value of 0
*/
function ParameterChanged(param, value) {
/* if it is the slider you just created */
if (param == 0) {
Trace(value); /* print the value to the console */
}
}
MainStage Scripter MIDI plug-in Reset function
Reset() is called when you bypass the Scripter plug-in and when the transport is started.
You can implement this function to clear the plug-in history and set Scripter to its default
state.
JavaScript objects overview
The Scripter plug-in provides JavaScript objects that describe or represent MIDI
information and information about MainStage, in addition to performing MIDI processing-
related functions. See these sections for details about different object types.
Use the JavaScript Event object
Use the JavaScript TimingInfo object
Use the Trace object
Use the MIDI event beatPos property
Use the JavaScript MIDI object
Use the JavaScript Event object
When the MainStage Scripter MIDI plug-in HandleMIDI function is called, an Event object
represents one MIDI event and implements several methods you can call in your script.
The Event object is not instantiated directly, but is a prototype for the following event-
specific methods, properties, and types.
Tip: You can use the JavaScript “new” keyword to generate a new instance of an Event
object of any type.