ModScripter is a versatile modulator that offers boundless possibilities for creating or manipulating modulation signals.
JavaScript is the programming language used to create scripts for ModScripter. The utilized interpreter adheres to the ECMAScript E5/E5.1 specification.
The primary function of a modulator is to generate a signal that modulates other parameters, such as volume or cutoff frequencies of other plug-ins. To generate a modulation signal using ModScripter, the script must implement the processModulation function and return the signal as a numerical value within the range of zero to one, commonly referred to as a normalized value.
The most basic script is:
processModulation = function (inputValue) {
return inputValue;
}
This produces a modulation output signal identical to the input value. The input value is a generic parameter that can itself be modulated by another modulator or automated via MIDI Control Change Messages.
In addition, a script can utilize up to eight custom parameters, a sidechain audio signal, and MIDI note events to generate the final modulation signal.
Furthermore, the script can utilize all the functions defined by the ECMAScript E5/E5.1 specification.
A script can declare up to eight custom parameters. To handle a parameter, a script must implement at least two functions:
By implementing the getParamTitle function, the user interface of the modulator incorporates
elements that enable the modification of parameter values.
getParamTitle = function (paramIndex) {
if (paramIndex === 1) {
return "My Parameter";
}
};
This introduces a new UI element labeled as "My Parameter". Upon user modification of this element,
the script's onParamChange function is triggered, receiving the updated value of the parameter.
onParamChange = function (paramIndex, newValue) {
if (paramIndex === 1) {
// the value of my parameter changed
}
};
The remaining three functions are employed to enhance the user interface's representation of the normalized parameter value.
The paramValueToString function generates a string that is displayed in the user interface.
The stringToParamValue function converts any string that the user enters into the user interface to its normalized equivalent.
The getParamStepCount function is designed to retrieve the number of distinct intervals within a parameter's value range. For instance, if a parameter represents a sequence of five values, it has a step count of four distinct intervals between its minimum and maximum values.
If ModScripter is connected to a MIDI Input, the parameters can be controlled via MIDI Control Change Messages.
Two functions, onNoteOnEvent and onNoteOffEvent, handle MIDI note input.
onNoteOnEvent = function (channel, pitch, velocity, tuning, noteID) {
}
onNoteOffEvent = function (channel, pitch, velocity, tuning, noteID) {
}
These functions are triggered either when a note is pressed or when it is released.
Please note that a connection to the MIDI Input port of ModScripter is required for this functionality to work.
ModScripter can receive an audio sidechain signal.
If such a signal is present, the script's processSidechain function is invoked, including the averages of the minimum and maximum audio sample values.
processSidechain = function (minSample, maxSample, absMinSample, absMaxSample, numSamples) {
}
The following functions can be implemented by a script:
The following functions can be called from a script:
function processModulation (inputValue, numSamples) -> {Number}
Arguments:
inputValue
numSamples
Returns:
This function is called from the host, to generate the modulation signal.
The implementation of this function is required.
function processSidechain (minSample, maxSample, absMinSample, absMaxSample, numSamples)
Arguments:
minSample
maxSample
absMinSample
absMaxSample
numSamples
This function is called when the sidechain connection is established. The script can analyze the values and
use this analysis in the processModulation function, to generate the modulation signal.
The implementation of this function is optional.
function onNoteOnEvent (channel, pitch, velocity, tuning, noteID)
Arguments:
channel
pitch
velocity
tuning
noteID
This function is called when a note on event is received by the event input port of ModScripter.
The implementation of this function is optional.
function onNoteOffEvent (channel, pitch, velocity, tuning, noteID)
Arguments:
channel
pitch
velocity
tuning
noteID
This function is called when a note off event is received by the event input port of ModScripter.
The implementation of this function is optional.
function onParamChange (paramIndex, newValue)
Arguments:
paramIndex
newValue
This function is called whenever a parameter is modified, either by the user manually adjusting a knob in the user interface or by another modulation or automation source.
The implementation of this function is optional.
function paramValueToString (paramIndex, paramValue) -> {String}
Arguments:
paramIndex
paramValue
Returns:
This function is called whenever the host needs to display the parameter value to the user. The script should return a user-friendly value representation of the parameter.
The implementation of this function is optional.
function stringToParamValue (paramIndex, string) -> {Number}
Arguments:
paramIndex
string
Returns:
This function is called whenever the host needs to convert a user-edited string to the parameter value.
The implementation of this function is optional.
function getParamTitle (paramIndex) -> {String}
Arguments:
paramIndex
Returns:
This function is called whenever the host needs to display the name of the parameter to the user. When the script returns a name for a parameter, the corresponding user element is visible in the plug-in user interface.
The implementation of this function is optional.
function getParamStepCount (paramIndex) -> {Number}
Arguments:
paramIndex
Returns:
If a parameter has discrete steps, the script should return the number of steps here. The host may use a different user interface element that is easier to handle.
The implementation of this function is optional.
function getDescription () -> {String}
Returns:
The description of the script is shown in the main user interface.
The implementation of this function is optional.
function getSampleRate () -> {Number}
Returns:
Note: Can be called at any time
function getTempo () -> {Number}
Returns:
Note: Can only be called from inside the following functions: processModulation, processSidechain, onNoteOnEvent, onNoteOffEvent, onParamChange
function getProjectTimeMusic () -> {Number}
Returns:
Note: Can only be called from inside the following functions: processModulation, processSidechain, onNoteOnEvent, onNoteOffEvent, onParamChange
function getBarPositionMusic () -> {Number}
Returns:
Note: Can only be called from inside the following functions: processModulation, processSidechain, onNoteOnEvent, onNoteOffEvent, onParamChange
function normalizedToPlain (min, max, normValue) -> {Number}
Arguments:
Returns:
function plainToNormalized (min, max, plainValue) -> {Number}
Arguments:
Returns:
function normalizedToSteps (normValue, numSteps, stepStart) -> {Number}
Arguments:
Returns:
function stepsToNormalized (stepValue, numSteps, stepStart) -> {Number}
Arguments:
Returns:
function log (...)
Write something into the logging console.
The input and the eight custom parameters can be controlled via MIDI Control Change Messages.
The following table shows the mapping:
| Parameter | MIDI Control Message |
|---|---|
| Input Parameter | 1 (Mod Wheel) |
| Parameter 1 | 16 (General Purpose Controller 1) |
| Parameter 2 | 17 (General Purpose Controller 2) |
| Parameter 3 | 18 (General Purpose Controller 3) |
| Parameter 4 | 19 (General Purpose Controller 4) |
| Parameter 5 | 80 (General Purpose Controller 5) |
| Parameter 6 | 81 (General Purpose Controller 6) |
| Parameter 7 | 82 (General Purpose Controller 7) |
| Parameter 8 | 83 (General Purpose Controller 8) |