Parameter

<< Click to Display Table of Contents >>

Navigation:  Reference >

Parameter

Usage: Scriptlet plugins only.

A Scriptlet plugin can define variables representing three different kinds of parameters:

Continuous - continuous parameters can have floating point values between 0.0 and 1.0

Var Foo : continuous parameter = 0// Declare a continuous parameter called Foo

Var a,b,c : parameter = 0.5 // Declare three parameters initialized to 0.5

 

Subrange - a subrange parameter is a sequence of integer values. Note that MIDI Note Names can be used in place of integer values

Var subrange Channel : parameter 1..16 // Declare a subrange parameter called Channel

Var ScaleRoot : parameter C3 .. B3 = D3; // Define a range of scale roots and initialize to D

 

Discrete - a discrete parameter can hold any one of predefined number of strings

Var Leslie : discrete  parameter "Slow", "Off", "Fast"

 

Note that the types continuous, subrange and discrete are optional in parameter declarations as they can be inferred from the clause on the right hand side of the parameter keyword. However, should you need to use an array of parameters, you will need to refer to these types explicitly. It is not possible to have an array containing different parameter types.

 
The AsNoteNames operator can be used to create a discrete parameter that is intended to allow a sequence of note names to be conveniently defined. This is particularly useful if you need parameters to span a significant number of MIDI notes. For example:

Var notes : parameter AsNoteNames C3 .. E3

 
is equivalent to writing:

Var notes : parameter "C3", "C#3", "D3", "D#3", "E3"

 
Changing a parameter value from your script is as simple as assigning a new value to the parameter variable. Examples:

Channel = 2

Leslie = "Off"

 
As with most other variables, you can (and should) follow a declaration with an initialization. The compiler will produce a warning message if you do not include an initialization.

Var Leslie : parameter "Slow", "Off", "Fast" = "Off"

 
Assignments to parameter variables are checked at runtime so if, for example, you tried to assign 17 to that Channel parameter above, it will quietly fail. In any such failure situation, the parameter will be set to the minimum possible value.

When you declare a parameter variable for a Scriptlet plugin, the name of that variable is used automatically as the parameter name that you see in the plugin editor or in the widget mapping parameter list. This can cause conflicts if the parameter name you want to use is the same as some other variable or is the same as an existing system function. For example, you cannot declare a parameter variable called "Transpose" since there is already a GPScript system function with that name. However, since it might typically be desirable to use such a word for display purposes, you can optionally include an explicit parameter name in the declaration.

Example:

Var MyTranspose("transpose") : parameter -12 .. 12

 
The declaration above will declare a new variable called MyTranspose which you will use to reference the parameter in your script. However, the word "transpose" will be used for the parameter name for that plugin as far as widgets are concerned.

Parameter numbers

Under the covers, parameters are integer numbers. Parameter numbers start at zero and increment by one for each new parameter that you declare. You can access the parameter number directly by appending a hashsign '#' to the parameter identifier.

Var a,b,c : parameter = 0.5 // Declare three parameters initialized to 0.5

Print(b) // Prints the value 0.5, the value of that parameter

Print(b#) // Prints 1, the second parameter number