aboutsummaryrefslogtreecommitdiffhomepage
path: root/configs
diff options
context:
space:
mode:
authorcbdev <cb@cbcdn.com>2019-07-06 17:25:12 +0200
committercbdev <cb@cbcdn.com>2019-07-06 17:25:12 +0200
commitb618c4a6b74a52f830ca53029e1cc680d56a2501 (patch)
tree6da5459b45db4448936cb8f0225490b9f5135b1e /configs
parentee75bee08b8fb280fc1d76e8635cf29c576835da (diff)
downloadmidimonster-b618c4a6b74a52f830ca53029e1cc680d56a2501.tar.gz
midimonster-b618c4a6b74a52f830ca53029e1cc680d56a2501.tar.bz2
midimonster-b618c4a6b74a52f830ca53029e1cc680d56a2501.zip
Implement Lua backend
Diffstat (limited to 'configs')
-rw-r--r--configs/demo.lua21
-rw-r--r--configs/lua.cfg35
2 files changed, 56 insertions, 0 deletions
diff --git a/configs/demo.lua b/configs/demo.lua
new file mode 100644
index 0000000..e816ac4
--- /dev/null
+++ b/configs/demo.lua
@@ -0,0 +1,21 @@
+-- This example MIDIMonstaer Lua script spreads one input channel onto multiple output
+-- channels using a polynomial function evaluated at multiple points. This effect can
+-- be visualized e.g. with martrix (https://github.com/cbdevnet/martrix).
+
+-- This is just a demonstration of global variables
+foo = 0
+
+-- The polynomial to evaluate
+function polynomial(offset, x)
+ return math.exp(-20 * (x - offset) ^ 2)
+end
+
+-- Handler function for the input channel
+function input(value)
+ foo = foo + 1
+ print("input at ", value, foo)
+
+ for chan=0,10 do
+ output("out" .. chan, polynomial(value, (1 / 10) * chan))
+ end
+end
diff --git a/configs/lua.cfg b/configs/lua.cfg
new file mode 100644
index 0000000..9182122
--- /dev/null
+++ b/configs/lua.cfg
@@ -0,0 +1,35 @@
+; This configuration uses a Lua script to distribute one input channel (from either a mouse
+; button or an axis control) onto multiple output channels (on ArtNet).
+
+[backend artnet]
+bind = 0.0.0.0
+
+[evdev mouse]
+device = /dev/input/by-path/platform-i8042-serio-2-event-mouse
+
+[evdev xbox]
+input = Xbox Wireless
+axis.ABS_X = 34300 0 65535 255 4095
+
+[lua lua]
+script = configs/demo.lua
+
+[artnet art]
+universe = 0
+destination = 255.255.255.255
+
+[map]
+mouse.EV_KEY.BTN_LEFT > lua.input
+xbox.EV_ABS.ABS_X > lua.input
+
+art.1 < lua.out0
+art.2 < lua.out1
+art.3 < lua.out2
+art.4 < lua.out3
+art.5 < lua.out4
+art.6 < lua.out5
+art.7 < lua.out6
+art.8 < lua.out7
+art.9 < lua.out8
+art.10 < lua.out9
+art.11 < lua.out10