![]() |
uvi-script
Musical event scripting with Lua
|
This guide provides a comprehensive overview of how to create custom user interfaces for your scripts. For a detailed reference of all available widgets and functions, see the User Interface Classes and Functions group.
The UVIScript UI system allows you to build powerful, interactive control surfaces for your instruments and effects. You can create a variety of widgets, from simple buttons and knobs to complex tables and XY pads.
Key features include:
onNote or onRelease.Let's start with a complete example. This script creates a single knob that controls the script's gain and a label to display the current value.
This example demonstrates the three core steps: creating widgets, defining a changed callback to react to user input, and using the widget's value in your script's logic.
All widgets are created using a convenient table constructor syntax. This allows you to set properties like position, size, and the changed callback at the moment of creation.
Instead of writing this:
You can write this, using curly brackets {}:
The UI canvas has a fixed width of 720px. By default, its height adjusts automatically to fit the widgets, but you can also specify a custom height. You can arrange widgets using either the automatic grid system or by setting pixel-perfect manual coordinates.
By default, widgets are placed on a grid in their creation order. Each new widget is placed in the first available empty cell, flowing from left-to-right, top-to-bottom. This is useful for quickly creating simple layouts.
The grid consists of:
Some widgets, like Knobs and Sliders, are larger and may span multiple rows or columns by default.
For precise control, you can manually position and size widgets using their properties. You can set these during creation or modify them later.
x, y: The top-left coordinate of the widget.width, height: The dimensions of the widget.position: A table {x, y}.size: A table {width, height}.bounds: A table {x, y, width, height}.You can also use the moveControl() function to snap a widget to a specific cell in the auto-layout grid.
Use setSize to set the overall dimensions of your script UI, and setHeight if you only need to adjust the height (the width defaults to 720px):
To make your script UI visible in the host's performance view, call makePerformanceView at the end of your script. This is what allows end users to see and interact with your UI during performance:
changed CallbackTo respond to user interaction, you assign a function to a widget's changed property. This function is called whenever the widget's value changes.
The callback function always receives the widget instance as its first argument, conventionally named self.
You can also use Lua's colon syntax, which provides the self argument implicitly:
For Table widgets, the callback receives a second argument: the index of the value that changed.
Knob — Rotary control, ideal for continuous parameters. Supports strip images for custom graphics via setStripImage().
Slider — Horizontal or vertical fader. Set vertical to true in the constructor for a vertical slider. Supports background and handle images.
NumBox — Numeric text input. Users can click and drag or type a value directly.
Button — Stateless push button. Triggers its callback once per click.
OnOffButton — Toggle button with on/off state. self.value is a boolean.
MultiStateButton — Cycles through multiple named states. Alternative to Menu for small option sets.
Menu — Dropdown selector for longer lists of options.
Set hierarchical to true to create nested sub-menus from path-like entries. Use "/" as separator — the menu builds the tree automatically:
See the IRLoader example for a complete hierarchical menu with impulse response loading.
Label — Text display with custom font, alignment, and colour.
Image — Displays a static image (PNG, JPG). Supports an overImage for mouse-over state.
SVG — Displays a Scalable Vector Graphics image.
Panel — Groups widgets together. Create sub-widgets using method syntax:
Viewport — Scrollable container. Useful when content exceeds available space.
A common pattern for multi-page UIs: use OnOffButton as tab selectors and toggle Panel visibility. Each tab button deselects the others and shows only the matching panel:
See the PanelSwitcher example for a complete working script.
Table — Multi-value bar editor. Commonly used for sequencer steps, velocity curves, or envelope shapes.
XY — Two-dimensional pad returning X and Y values.
AudioMeter — Real-time level meter bound to an element's audio bus.
WaveView — Displays the waveform of a sample.
FileSelector — Embedded file browser for selecting samples or presets.
DnDArea — Drag-and-drop zone. Fires a callback when a file is dropped.
Knob, Slider, and NumBox accept a Mapper and a Unit to control the value curve and display formatting.
A Mapper defines the curve between the widget's visual position and the parameter value:
| Mapper | Formula | Typical use |
|---|---|---|
| Linear (default) | min + (max-min) × pos | General purpose |
| Exponential | min × (max/min)^pos | Frequency, time |
| Quadratic | min + (max-min) × pos² | Gentle curve |
| Cubic | min + (max-min) × pos³ | Volume (perceptual) |
| SquareRoot | min + (max-min) × √pos | Inverse gentle |
See Mapper for the full list (QuarticRoot, CubeRoot, Quartic, Quintic, etc.).
A Unit tells the engine how to format the displayed value:
| Unit | Display | Auto-scale |
|---|---|---|
| Hertz | Hz | → kHz above 1000 |
| Seconds | s | → ms below 1 |
| MilliSeconds | ms | → s above 1000 |
| Cents | ct | → st above 100 |
| LinearGain | dB | linear 0..1 → dB display |
| PercentNormalized | % | 0..1 → 0%..100% |
| Decibels | dB | Direct dB value |
| SemiTones | st | Semitones |
| Pan | L/R | -1..1 pan display |
| MidiKey | C3, D#4... | MIDI note name |
See Unit for the complete list.
When no built-in unit fits, use the displayText property to override:
All colour properties accept a string in one of these formats:
| Format | Example | Description |
|---|---|---|
| Named | "red", "darkgrey", "blue" | CSS-style named colours |
| RGB hex | "#FF00CC" | 6-digit hex (opaque) |
| ARGB hex | "#3C00FECD" | 8-digit hex (with alpha) |
Common colour properties: backgroundColour, textColour, fillColour, outlineColour, thumbColour, trackColour.
Many widgets accept image paths for custom graphics. Supported formats: PNG and JPG.
For Retina / HiDPI displays, place a @2x variant alongside the standard file:
resources/knob.png — standard resolutionresources/knob@2x.png — 2× pixel dimensionsThe engine automatically picks the appropriate variant.
Set persistent to true (the default) to have widget values automatically saved and restored with the preset:
Set exported to true to expose a widget as a host-automatable parameter. The paramId is assigned automatically but can be set manually for stable mapping:
For custom data beyond widget values, use onSave / onLoad callbacks. See Asynchronous Operations for file-based persistence with saveData / loadData.
Use setKeyColour and resetKeyColour to colorize the on-screen keyboard. This is useful for indicating key ranges, keyswitches, or active notes:
Explore the full widget reference with all properties and methods in the User Interface Classes and Functions module documentation.