Event callbacks are functions called when different types of events are received by the ScriptProcessor. More...
Functions | |
function | onAfterTouch (e) |
event callback that will receive all incoming channel after-touch events if defined. More... | |
function | onController (e) |
event callback that will receive all incoming control-change events when defined. More... | |
function | onEvent (e) |
event callback that will receive all incoming events if defined. More... | |
function | onInit () |
initial callback that is called just after the script initialisation if the script was successfully analyzed. More... | |
function | onLoad (data) |
callback that is called when restoring a ScriptProcessor state if custom data has been saved. More... | |
function | onNote (e) |
event callback that will receive all incoming note-on events if defined. More... | |
function | onPitchBend (e) |
event callback that will receive all incoming pitch-bend events if defined. More... | |
function | onPolyAfterTouch (e) |
event callback that will receive all incoming polyphonic after-touch events if defined. More... | |
function | onProgramChange (e) |
event callback that will receive all incoming program-change events if defined. More... | |
function | onRelease (e) |
event callback executed whenever a note off message is received. More... | |
function | onSave () |
callback that is called when saving the ScriptProcessor state. More... | |
function | onTransport (playing) |
event callback that is called when the host transport bar state changes. More... | |
Event callbacks are functions called when different types of events are received by the ScriptProcessor.
The default behaviour (if you don't write your own) is to forward the incoming event to the output of the ScriptProcessor. You can customize the default behaviour by writing your own function.
Each callback act as a different thread of execution with its own environment but, unlike threads in traditional Operating Systems, a callback cannot be interrupted unless you ask for it. They can be paused for some specific amount of time (sample-accurate) using the wait function. During that time, other callbacks can be started or resumed in parallel.
You can start new callbacks if you need to using the spawn function.
function onInit | ( | ) |
initial callback that is called just after the script initialisation if the script was successfully analyzed.
This the place to start a background process that doesn't require external input like algorithmic event generation.
n.b.: Don't try to create User Interface widgets here, widget creation functions are disabled right after the main script chunk.
Example:
function onLoad | ( | data | ) |
callback that is called when restoring a ScriptProcessor state if custom data has been saved.
This is called just after the script initialisation and after restoring widgets values when the processing hasn't started yet.
data | a lua value as saved by your onSave function |
Example:
Example2:
Example3:
function onSave | ( | ) |
callback that is called when saving the ScriptProcessor state.
This is the place where you can save additional data if you need to. supported lua types are number, boolean, strings and (nested) tables without (cyclic) references.
Example:
Example2:
Example3:
function onEvent | ( | e | ) |
event callback that will receive all incoming events if defined.
if this callback is defined it will take over the other more specialized callbacks like onNote, onRelease all incoming events are tables with at least the type field defined
e | event table, see other callbacks for the different kind of table fields |
Example:
function onNote | ( | e | ) |
event callback that will receive all incoming note-on events if defined.
Example:
e | event table with the following fields:
|
function onRelease | ( | e | ) |
event callback executed whenever a note off message is received.
Release trigger Example:
e | event table with the following fields:
|
function onProgramChange | ( | e | ) |
event callback that will receive all incoming program-change events if defined.
e | event table with the following fields type, program |
Program Change to MIDI channel Example:
e | event table with the following fields:
|
function onController | ( | e | ) |
event callback that will receive all incoming control-change events when defined.
e | event table with the following fields: type, controller, value |
Example:
Be aware that you need to forward MIDI CC using postEvent(e) if you want your users to be able to MIDI learn script parameters or use pre-programmed MIDI CC modulations
e | event table with the following fields:
|
function onPitchBend | ( | e | ) |
event callback that will receive all incoming pitch-bend events if defined.
Example:
e | event table with the following fields:
|
function onAfterTouch | ( | e | ) |
event callback that will receive all incoming channel after-touch events if defined.
AfterTouch to pitch Example:
e | event table with the following fields:
|
function onPolyAfterTouch | ( | e | ) |
event callback that will receive all incoming polyphonic after-touch events if defined.
Example:
e | event table with the following fields:
|
function onTransport | ( | playing | ) |
event callback that is called when the host transport bar state changes.
playing | boolean flag that tells whether the transport bar is in playing state |