Script widgets and custom modules are two different things, you can’t use timing functions (ie setTimeout
) in widget’s formulas (JS{{}}
/ #{}
) so you’ll need to write a custom module that will look like this:
module.exports = {
oscOutFilter: function(data) {
var {address, args, host, port} = data
// Assuming the push button's address is /control_sequence_1
// and value is 1 (with no preArgs)
if (address == '/control_sequence_1' && args[0].value == 1) {
setTimeout(()=>{
send('192.168.254.20', 8000, '/push_01', 16, 114, 127)
setTimeout(()=>{
send('192.168.254.20', 8000, '/push_01', 16, 114, 0)
setTimeout(()=>{
send('192.168.254.20', 8000, '/push_01', 16, 114, 3)
setTimeout(()=>{
send('192.168.254.20', 8000, '/push_01', 16, 114, 7)
}, 100)
}, 100)
}, 100)
}, 100)
return // ignore original message
}
return {address, args, host, port}
}
}
Notes:
-
setTimeout
calls must be nested because it’s not a blocking function (https://nodejs.org/en/docs/guides/blocking-vs-non-blocking/) - to send midi messages you’d write something like
send('midi', 'OpenStageControl', '/control', 16, 114, 3)
or (if the push button’s target is “midi:OpenStageControl”):
send(host, port, '/control', 16, 114, 3)
- you are using invalid quote characters (aka “smart quotes”) , avoid using these as they will prevent your code from working