aboutsummaryrefslogtreecommitdiffhomepage
path: root/configs/demo.lua
diff options
context:
space:
mode:
authorcbdev <cb@cbcdn.com>2019-07-13 17:51:11 +0200
committercbdev <cb@cbcdn.com>2019-07-13 17:51:11 +0200
commitee4a46105acecb6a7adc1e7189e8b0a66404b421 (patch)
treed7b8b48c917027fcf2ef09c1896b943ba47ce0b0 /configs/demo.lua
parent86b9706220ca285db961ea43ec0859ea99cc9f71 (diff)
downloadmidimonster-ee4a46105acecb6a7adc1e7189e8b0a66404b421.tar.gz
midimonster-ee4a46105acecb6a7adc1e7189e8b0a66404b421.tar.bz2
midimonster-ee4a46105acecb6a7adc1e7189e8b0a66404b421.zip
Improved Lua backend with intervals
Diffstat (limited to 'configs/demo.lua')
-rw-r--r--configs/demo.lua45
1 files changed, 33 insertions, 12 deletions
diff --git a/configs/demo.lua b/configs/demo.lua
index e816ac4..24a8396 100644
--- a/configs/demo.lua
+++ b/configs/demo.lua
@@ -1,21 +1,42 @@
--- This example MIDIMonstaer Lua script spreads one input channel onto multiple output
+-- This example MIDIMonster 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)
+function polynomial(x)
+ return math.exp(-40 * input_value("width") * (x - input_value("offset")) ^ 2)
end
--- Handler function for the input channel
-function input(value)
- foo = foo + 1
- print("input at ", value, foo)
-
+-- Evaluate and set output channels
+function evaluate()
for chan=0,10 do
- output("out" .. chan, polynomial(value, (1 / 10) * chan))
+ output("out" .. chan, polynomial((1 / 10) * chan))
+ end
+end
+
+-- Handler functions for the input channels
+function offset(value)
+ evaluate()
+end
+
+function width(value)
+ evaluate()
+end
+
+-- This is an example showing a simple chase running on its own without the need
+-- (but the possibility) for external input
+
+-- Global value for the current step
+current_step = 0
+
+function step()
+ if(current_step > 0) then
+ output("dim", 0.0)
+ else
+ output("dim", 1.0)
end
+
+ current_step = (current_step + 1) % 2
end
+
+interval(step, 1000)