Scripting in Lua

Scripting in Falcon uses UVIScript, a domain-specific scripting language built on top of the Lua scripting language. Scripts in Falcon are essentially MIDI effects with advanced capabilities, with access to all of Falcon’s synthesis engine modules. Scripts can also define their own interface, so that you can interact with the script in real time.

UVIScripts are saved as text documents with a .lua extension, and loaded with Falcon’s Script Processor module. For general information on using the Script Processor module, see Interface › Events Tab and Event Processors › Script Processor.

Example

To help demonstrate UVIScript, here’s a simple example script for a pitch inverter (available in the Script Processor module as a factory preset, under UtilitiesInvert Pitch).

CenterPitch = Knob("Center Pitch", 60, 0, 127, true)

function onNote(e)
    local center = CenterPitch.value
    local delta = e.note - center
    local note = center - delta
    if note >= 0 and note <= 127 then
        playNote(note, e.velocity)
    end
end

function onRelease()
    --
end

Here’s what this script looks like in Falcon’s Script Processor.

INVERT PITCH SCRIPT

This script creates one knob, which sets the script’s center pitch value (line 1). When a Note-on event occurs (line 3), the note’s pitch value is evaluated and modified relative to the center pitch value (lines 4–6), and then the note is played with its modified pitch value (lines 7–8). For example, if the center pitch is set to C3, when a C2 is triggered a C4 would be played instead.

The empty onRelease function swallows incoming note-off events instead of passing them on. The inverted note does not need them: a note started with playNote and no duration is released automatically when the key that triggered it is released.

Full Documentation

For more information on writing your own UVIScripts, please refer to the latest online documentation at: uvi.net/uviscript.

For more information on the underlying Lua scripting language, see lua.org/docs.html.