Scripter Javascript Tutorial
javascriptmusiclogicscripterbookexcerpttutorial72 Update Control Values
To update the value of any control, use the global
SetParameter()
function, which accepts two arguments:
Which parameter to be accessed, which can be done either as the parameter name or the index in the
PluginParameters
array. The parameter name must be exactly the same.The value to be set for the control, which is always a number.
var PluginParameters = [];
.push({name:"Linear Slider 1", type:"lin", unit:"%", minValue:0, maxValue:100, numberOfSteps:100, defaultValue:50});
PluginParametersSetParameter("Linear Slider 1", 0);
SetParameter(0, 0);
In the above example:
Lines 1–2: A linear slider parameter control is created.
Line 3: SetParameter is called with the parameter’s name.
Line 4: SetParameter is called with the parameter’s name.
When SetParameter()
is called with a name or an index
which does not exist in PluginParameters, then the following error is
shown:
SetParameter() called with an argument: (Linear Slider 2) that does not equal any registered parameter name.
SetParameter()
only works when called from either
HandleMIDI()
or ProcessMIDI()
, so the track
must be playing in order for the callback to make any changes. All
changes to parameter controls either by SetParameter()
or
by the user are captured in the ParameterChanged()
function.