Good idea with json file reading, looks like there is already a json library for Lua. I think would be good to include some more libraries, like Numeric Lua. And then showing a warning on the panel when instantiating the module that you shouldn’t use any script from any source without looking at it first
I gave it a try with my current old test implementation and inline arrays. Looks like this:
-- create GUI
addLabel(50, 124, "Trigger", 20)
inp = addInput(20, 120)
addLabel(180, 124, "Out", 20)
out = addOutput(150, 120)
-- init some variables
lastInput = 0
value = 0
-- pentatonic scale, G-flat major
values = {
1.083, 1.250, 1.500, 1.667, 1.833,
2.083, 2.250, 2.500, 2.667, 2.833
}
-- output random voltages of the scale on trigger
function process()
v = getVoltage(inp)
if lastInput == 0 and v > 0 then
value = values[math.floor(math.random(#values))]
end
lastInput = v
setVoltage(out, value)
end
and sounds like this:
The trigger is a bit simple, works only with perfect digital gate signals, should be a Schmitt-Trigger. I think this could be in an extra Lua library, which provides some useful utility classes.