aboutsummaryrefslogtreecommitdiffhomepage
path: root/backends/lua.md
diff options
context:
space:
mode:
authorcbdev <cb@cbcdn.com>2020-04-19 20:40:42 +0200
committercbdev <cb@cbcdn.com>2020-04-19 20:40:42 +0200
commit79b7e7dae5814942c04ca33e94e92b89547ffeb2 (patch)
tree0b1ca9a30b95d43604c81e7bde78786c33f8c186 /backends/lua.md
parent7c1a283c9213dd273d04af72e24b08beb83aec12 (diff)
parent462b409d3d1fa16fcab0c7f8b475bb8d8e8b3e90 (diff)
downloadmidimonster-79b7e7dae5814942c04ca33e94e92b89547ffeb2.tar.gz
midimonster-79b7e7dae5814942c04ca33e94e92b89547ffeb2.tar.bz2
midimonster-79b7e7dae5814942c04ca33e94e92b89547ffeb2.zip
Merge current master to rtpmidirtpmidi
Diffstat (limited to 'backends/lua.md')
-rw-r--r--backends/lua.md15
1 files changed, 12 insertions, 3 deletions
diff --git a/backends/lua.md b/backends/lua.md
index 05509b6..e59e513 100644
--- a/backends/lua.md
+++ b/backends/lua.md
@@ -13,10 +13,11 @@ The following functions are provided within the Lua interpreter for interaction
| Function | Usage example | Description |
|-------------------------------|-------------------------------|---------------------------------------|
-| `output(string, number)` | `output("foo", 0.75)` | Output a value event to a channel |
+| `output(string, number)` | `output("foo", 0.75)` | Output a value event to a channel on this instance |
| `interval(function, number)` | `interval(update, 100)` | Register a function to be called periodically. Intervals are milliseconds (rounded to the nearest 10 ms). Calling `interval` on a Lua function multiple times updates the interval. Specifying `0` as interval stops periodic calls to the function |
-| `input_value(string)` | `input_value("foo")` | Get the last input value on a channel |
-| `output_value(string)` | `output_value("bar")` | Get the last output value on a channel |
+| `cleanup_handler(function)` | `cleanup_handler(shutdown)` | Register a function to be called when the instance is destroyed (on MIDIMonster shutdown). One cleanup handler can be registered per instance. Calling this function when the instance already has a cleanup handler registered replaces the handler, returning the old one. |
+| `input_value(string)` | `input_value("foo")` | Get the last input value on a channel on this instance |
+| `output_value(string)` | `output_value("bar")` | Get the last output value on a channel on this instance |
| `input_channel()` | `print(input_channel())` | Returns the name of the input channel whose handler function is currently running or `nil` if in an `interval`'ed function (or the initial parse step) |
| `timestamp()` | `print(timestamp())` | Returns the core timestamp for this iteration with millisecond resolution. This is not a performance timer, but intended for timeouting, etc |
| `thread(function)` | `thread(run_show)` | Run a function as a Lua thread (see below) |
@@ -43,8 +44,13 @@ function run_show()
end
end
+function save_values()
+ -- Store state to a file, for example
+end
+
interval(toggle, 1000)
thread(run_show)
+cleanup_handler(save_values)
```
Input values range between 0.0 and 1.0, output values are clamped to the same range.
@@ -86,6 +92,9 @@ be called.
Output values will not trigger corresponding input event handlers unless the channel is mapped
back in the MIDIMonster configuration. This is intentional.
+Output events generated from cleanup handlers called during shutdown will not be routed, as the core
+routing facility has already shut down at this point. There are no plans to change this behaviour.
+
To build (and run) the `lua` backend on Windows, a compiled version of the Lua 5.3 library is required.
For various reasons (legal, separations of concern, not wanting to ship binary data in the repository),
the MIDIMonster project can not provide this file within this repository.