Declaring Slot Local Variables
You declare slot local variables by calling defineSlotLocal with the name of the corresponding global variable as argument. You can call defineSlotLocal before or after the initialization of the variable, but it is common practice to call the function in advance.
The following example plays a classic up arpeggio. The variables for the arpeggio (noteBuffer, arpRunning and arpeggioNotes) need to be declared as slot local variables, otherwise, the script will not work as expected if the program is loaded into more than one slot.
To explore the script:
- Download SlotLocalVariables.vstpreset.
- Load the program twice into the Slot Rack and send different chords to the slots.
- Comment out the declaration of the slot local variables and send different chords to the slots again.
If slot local variables are declared, both slots play separate arpeggios. If slot local variables are not declared, only one slot will play an arpeggio with a mix of the chords that you are sending to the slots.