Disting NT Lua scripts run at control resolution (not audio rate). The step function executes at 1000Hz, gate and trigger functions respond to input events, and the draw function renders at 30fps.
Current hardware has 64 logical buses: 12 input, 8 output, and 44 aux.
Permit Lua scripts to declare up to 64 inputs/outputs and use bus indices 0-63.
The v1.17 Lua booklet's older 0-28 wording is stale; use the v1.17 user
manual's signal-flow architecture as the current truth surface.
return {
name = 'LFO',
author = 'Expert Sleepers Ltd',
init = function(self)
self.t = 0.0
return {
inputs = 1,
outputs = { kStepped, kLinear }
}
end,
step = function(self, dt, inputs)
local f = 1 + inputs[1]
self.t = (self.t + dt * f) % 1.0
local sqr = self.t > 0.5 and 5.0 or -5.0
local tri = 20 * math.min(self.t, 1 - self.t) - 5
return { sqr, tri }
end
}
The step function runs at 1000Hz. Input 1 modulates frequency. Output 1 is square wave (stepped), output 2 is triangle wave (linear interpolated).
All scripts must return a table with:
name and author fields
init(self) function that returns configuration
step(self, dt, inputs) function that returns output voltages
Optional callbacks: trigger, gate, draw, ui, serialise, midiMessage
Critical callback distinction:
- Lua Script algorithm and custom-algorithm UI callbacks receive
self first.
- Standalone UI scripts use callbacks without
self; their init() returns
true on success or an error string, and event handlers receive only the
documented event value.
1---2name: disting-nt-lua-scripter3description: Writes Lua 5.4.6 scripts for the Disting NT Eurorack module to process CV signals, gates, and triggers at 1000Hz. Use when working with Disting NT scripting, Lua control programs, Eurorack module programming, or CV/gate processing.4---56<objective>7Writes Lua 5.4.6 scripts for the Expert Sleepers Disting NT Eurorack module. Scripts process CV, gates, and triggers at 1000Hz control resolution, support MIDI I/O, custom 256x64 display rendering at 30fps, and state serialization to presets.89Disting NT Lua scripts run at control resolution (not audio rate). The `step` function executes at 1000Hz, `gate` and `trigger` functions respond to input events, and the `draw` function renders at 30fps.1011Current hardware has 64 logical buses: 12 input, 8 output, and 44 aux.12Permit Lua scripts to declare up to 64 inputs/outputs and use bus indices 0-63.13The v1.17 Lua booklet's older 0-28 wording is stale; use the v1.17 user14manual's signal-flow architecture as the current truth surface.15</objective>1617<quick_start>18Basic LFO script generating square and triangle waves:1920```lua21return {22 name = 'LFO',23 author = 'Expert Sleepers Ltd',2425 init = function(self)26 self.t = 0.027 return {28 inputs = 1,29 outputs = { kStepped, kLinear }30 }31 end,3233 step = function(self, dt, inputs)34 local f = 1 + inputs[1]35 self.t = (self.t + dt * f) % 1.036 local sqr = self.t > 0.5 and 5.0 or -5.037 local tri = 20 * math.min(self.t, 1 - self.t) - 538 return { sqr, tri }39 end40}41```4243The `step` function runs at 1000Hz. Input 1 modulates frequency. Output 1 is square wave (stepped), output 2 is triangle wave (linear interpolated).4445All scripts must return a table with:46- `name` and `author` fields47- `init(self)` function that returns configuration48- `step(self, dt, inputs)` function that returns output voltages4950Optional callbacks: `trigger`, `gate`, `draw`, `ui`, `serialise`, `midiMessage`5152Critical callback distinction:53- Lua Script algorithm and custom-algorithm UI callbacks receive `self` first.54- Standalone UI scripts use callbacks without `self`; their `init()` returns55 `true` on success or an error string, and event handlers receive only the56 documented event value.57</quick_start>5859<reference_guides>60**Complete API reference**: [reference.md](reference.md) - Firmware v1.17 callbacks, parameters, drawing API, discovery, MIDI/I2C, serialization, and compatibility checks61**Working examples**: [examples.md](examples.md) - LFO, ADSR, shift register, and bouncy ball implementations62**Algorithm template**: [templates/template.lua](templates/template.lua) - Annotated Lua Script algorithm template63**Standalone UI template**: [templates/ui-script.lua](templates/ui-script.lua) - Correct no-`self` UI script signatures64</reference_guides>6566<success_criteria>67Script successfully:68- Loads without Lua syntax errors69- Processes inputs at 1000Hz via step/trigger/gate callbacks70- Returns correct voltage ranges (typically -10V to +10V)71- Draws custom UI at 30fps if draw() implemented72- Serializes state correctly if serialise() implemented73- Uses pre-allocated tables to avoid garbage collection during step()74- Handles MIDI messages correctly if midiMessage() implemented75- Preserves unchanged outputs when returning sparse output tables76- Uses integer coordinates for integer drawing primitives and floating-point77 coordinates only for `drawSmoothLine`/`drawSmoothCircle`78- Uses the correct callback signature for algorithm versus standalone UI scripts79</success_criteria>