
ParameterChanged function in Scripter MIDI plug-in in MainStage
The ParameterChanged() function lets you perform tasks triggered by changes to plug-in parameters. ParameterChanged is called each time one of the plug-in parameters is set to a new value. ParameterChanged is also called once for each parameter when you load a plug-in setting.
ParameterChanged is called with two arguments, first the parameter index (an integer number starting from 0), then the parameter value (a number).
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 Script Editor.
Tutorial script 7: 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 */
}
}