aboutsummaryrefslogtreecommitdiffhomepage
path: root/backends/lua.md
diff options
context:
space:
mode:
authorcbdev <cb@cbcdn.com>2020-03-08 17:12:03 +0100
committercbdev <cb@cbcdn.com>2020-03-08 17:12:03 +0100
commite0000797c80789d9d4559bb5264b982c187e1137 (patch)
tree746a063886aa0a3e51a21ce83bc8e2189d6adcd9 /backends/lua.md
parent8558c3acef273833d7366e1af3659514fff9c942 (diff)
parent5f4b349aff49be0a5f6895631a93c47fcafcff93 (diff)
downloadmidimonster-e0000797c80789d9d4559bb5264b982c187e1137.tar.gz
midimonster-e0000797c80789d9d4559bb5264b982c187e1137.tar.bz2
midimonster-e0000797c80789d9d4559bb5264b982c187e1137.zip
Merge branch 'master' into debian/master
Diffstat (limited to 'backends/lua.md')
-rw-r--r--backends/lua.md30
1 files changed, 21 insertions, 9 deletions
diff --git a/backends/lua.md b/backends/lua.md
index f38e189..db4cf39 100644
--- a/backends/lua.md
+++ b/backends/lua.md
@@ -1,9 +1,9 @@
### The `lua` backend
-The `lua` backend provides a flexible programming environment, allowing users to route and manipulate
-events using the Lua programming language.
+The `lua` backend provides a flexible programming environment, allowing users to route, generate
+and manipulate events using the Lua scripting language.
-Every instance has it's own interpreter state which can be loaded with custom handler scripts.
+Every instance has its own interpreter state which can be loaded with custom handler scripts.
To process incoming channel events, the MIDIMonster calls corresponding Lua functions (if they exist)
with the value (as a Lua `number` type) as parameter.
@@ -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 |
-| `interval(function, number)` | `interval(update, 100)` | Register a function to be called periodically. Intervals are milliseconds (rounded to the nearest 10 ms) |
+| `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 |
-
+| `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 |
Example script:
```
@@ -45,7 +46,7 @@ The `lua` backend does not take any global configuration.
|---------------|-----------------------|-----------------------|-----------------------|
| `script` | `script.lua` | none | Lua source file (relative to configuration file)|
-A single instance may have multiple `source` options specified, which will all be read cumulatively.
+A single instance may have multiple `script` options specified, which will all be read cumulatively.
#### Channel specification
@@ -58,9 +59,20 @@ lua1.foo > lua2.bar
#### Known bugs / problems
-Using any of the interface functions (`output`, `interval`, `input_value`, `output_value`) as an
-input channel name to a Lua instance will not call any handler functions.
+Using any of the interface functions (`output`, `interval`, `input_value`, `output_value`, `input_channel`,
+`timestamp`) as an input channel name to a Lua instance will not call any handler functions.
Using these names as arguments to the output and value interface functions works as intended.
Output values will not trigger corresponding input event handlers unless the channel is mapped
-back in the MIDIMonster configuration.
+back in the MIDIMonster configuration. This is intentional.
+
+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.
+You will need to acquire a copy of `lua53.dll`, for example by downloading it from the [luabinaries
+project](http://luabinaries.sourceforge.net/download.html).
+
+To build the `lua` backend for Windows, place `lua53.dll` in a subdirectory `libs/` in the project root
+and run `make lua.dll` inside the `backends/` directory.
+
+At runtime, Windows searches for the file in the same directory as `midimonster.exe`.