UVI introduced a new type of module in its core engine: Event Processors.
Event Processors are like MIDI effects with some extensions that allows to go beyond the limitations of MIDI.
UVI scripts are written using the Lua programming Language and a UVI-specific API.
Lua is a simple yet very efficient and powerful scripting language used in many applications. For general information about learning the Lua language, you can have a look at the Lua Reference Manual and the very well written online book Programming in Lua
This document aims to help to write your first UVI script.
In the Main Edit page, click on the EventProcessors tab -> Add -> ScriptProcessor.
Now open your favourite TextEditor with Lua syntax support (NotePad++, TextWrangler ... etc ) and create an empty text file vibrato.lua.
Click on the load Button in the ScriptProcessor toolbar and locate your script.
At this point you have an empty but valid script loaded inside the ScriptProcessor. You can now proceed to writing the actual script instructions. Don't forget to click on reload each time you want to test your changes.
UVI script is an event oriented programming interface. The default behaviour is to let all incoming events pass-through unmodified. This behaviour can be customized by writing event callbacks:
Here we will write a very short vibrato script and analyze it line by line to explain what's happening:
Here we initialize two global variables freq to define the frequency of the vibrato and grain to define its refresh period. We will use it later during the note callback execution
Here we write our own onNote callback function to customize its behaviour. We also initialize a local variable (duration) that we will use to measure the time elapsed since we started the callback.
Here we just forward the incoming note event to the output of this script untouched but we store its (voice) id in a local variable that will be needed later own to change this specific voice's pitch.
Here every 5 milliseconds, while the note that created this callback is still held:
here we will add some knobs on the user interface to make the frequency and depth of the vibrato editable:
we only changed 3 lines of code:
we now declare freq and depth to be Knobs instead of scalar variables. freq as a default value of 4Hz and a range of [0;10] while depth has a default initial value of 0.1 with a range of [0;1]
freq and depth are now Knob objects, so instead of using them as scalar values, we access their value attribute.
We have implemented with very few lines of code a vibrato script. Although being simple, this example has demonstrated several important concepts:
You can now get further by looking at the reference documentation.