List of callbacks

GP Script provides the following callbacks:

Initialization

Initialization()

Initialization code here. There can only be one of these.

Rackspace activation

On Activate()

Called whenever rackspace is activated

On Deactivate()

Called whenever we deactivate a rackspace

Variations

On Variation(oldVariation, newVariation)

Called when you switch to another variation

Parameters
  • oldVariation (Integer) – The index of the variation from which you came

  • newVariation (Integer) – The index of the variation you are in now

MIDI Events

Important

All these callbacks require a global GP Script variable associated with a MIDI In block. For the examples in the reference, the name of the MIDI In block will be A800.

On NoteOnEvent(m) From A800

Called whenever a NoteOn message is received

Parameters

m (NoteMessage) –

Requirement

A global GP Script variable associated with a MIDI In block

On NoteOffEvent(m) From A800

Called whenever a NoteOff message is received

Parameters

m (NoteMessage) –

Requirement

A global GP Script variable associated with a MIDI In block

On NoteEvent(m) From A800

Called whenever a NoteOn or NoteOff message is received

Parameters

m (NoteMessage) –

Requirement

A global GP Script variable associated with a MIDI In block

Warning

This callback will not be invoked for NoteOn events or for NoteOff events if you have defined NoteOnEvent or NoteOffEvent respectively callbacks.

On ControlChangeEvent(c) From A800
Parameters

c (ControlChangeMessage) –

Requirement

A global GP Script variable associated with a MIDI In block

On PitchBendEvent(p) From A800
Parameters

p (PitchBendMessage) –

Requirement

A global GP Script variable associated with a MIDI In block

On AftertouchEvent(a) From A800
Parameters

a (AfterTouchMessage) – Represents the current channel Aftertouch pressure

Requirement

A global GP Script variable associated with a MIDI In block

Todo

How can the data in a be accessed?

On PolytouchEvent(p) From A800
Parameters

p (PolyTouchMessage) – Represents note-specific pressure

Requirement

A global GP Script variable associated with a MIDI In block

On ProgramChangeEvent(p) From A800
Parameters

p (ProgramChangeMessage) –

Requirement

A global GP Script variable associated with a MIDI In block

Constrained MIDI events

The Note events (NoteEvent, NoteOnEvent, NoteOffEvent) and the ControlChangeEvent callbacks can optionally include a constraint that specifies either a range or an explicit sequence of numbers for which the callback is triggered. For example:

On NoteEvent (m : NoteMessage) Matching [C3..C4] From A800
   // This event is only called if you play a note with
   // a MIDI note number that is in the range 60 to 72
End
On ControlChangeEvent (c : ControlChangeMessage) Matching 1,7,14 From A800
   // This event is only called for controller numbers
   // 1, 7 or 14
End

When you used constrained events, you can have multiple events of the same kind as long as their ranges have no overlaps. The main purpose of this mechanism is to allow you to specify callbacks for specific purposes without having to handle all events in your script. For example, you might create a callback to handle key switches where the bottom octave of your keyboard is used for controlling some effects while notes in other octaves are handled normally. If you create a callback with no constraints, then any subsequent callbacks with constraints will cause a compilation error because your non-constrained callback is handling all possible values. On the other hand, if you create some callbacks with constraints and add a non-constrained callback afterwards, then that last callback will apply just to values that have not been specified in previously defined constrained callbacks.

Widget Events

On WidgetValueChanged(newValue) From SomeWidget
Parameters

newValue (Double) – represents a value between 0.0 and 1.0

Requirement

A global variable associated with widget

Plugin Events

On ParameterValueChanged(index, value)
Parameters
Requirement

A global variable associated with a plugin block

Generator events

On TimePassing(x, y)
Parameters
  • x (Integer) – linear time based on the length (or frequency) of the generator

  • y (Double) – an amplitude with a value ranging between 0.0 and 1.0. The actual value for y at some position x depends on the kind of generator and the settings being used.

Requirement

A global variable associated with a generator

OSC messages

On OSCMessageReceived(message) Matching StringConstant

StringConstant will be an explicit OSC Address to which this callback will respond. Use the OSC functions in the system library to access the arguments of the received message.

Parameters

message (OSCMessage) –

Playhead events

On BeatChanged(barNumber, beatNumber, tick)

Called every time that beatNumber increments

Parameters
  • barNumber (Integer) – currently unused

  • beatNumber (Integer) – number of the current beat

  • tick (Integer) – currently unused

Warning

This is experimental!

System events

On SystemEvent(newValue) Matching PlayheadStateChanged
Parameters

newValue (Double) – 1.0 when playhead has been started, 0.0 when stopped

Warning

This is experimental!