Hi guys,
I'm still in learning curve, I'm trying to make the button continuously repeat sending a MIDI messages until I release my hand from the button.
I tried this but "Open Stage Control" crashes once I run it !! :
while (value == 127)
{
send('/control', 1,1,127)
}
any ideas.
hi @abdulrahman
O-S-C crash is due to an infinite loop as your while condition is alway true.
Actually, i don't how to get what you want but hope some smart people will help you (and me )
hum
i tried that with a button set on push in the onValue property
but it seems an infinite loop occured and stuck O-S-C
this works
var out = 0
console.log(value)
while ( value && out < 5000) {
console.log(out)
out = out+200
}
console.log("sortie du while")
1 Like
Use setInterval to execute an action periodically:
if (value == 127) {
setInterval(()=>{
send('/control', 1,1,127)
}, 500) // every 0.5s
} else {
clearInterval()
}
2 Likes
thank you @Greenman & @jean-emmanuel for your quick reply. setInterval did the need. thank you all again.
hum @abdulrahman you get what you want ? i mean it sends message until you release the button ?!
If you can post here your session file, it will be kind
Yes @Greenman, It sends message until I release the button, unfortunately, I'm not able to share files yet as I'm still new user.
But, basically copy the code that @jean-emmanuel shared, and then paste it in your button, in the onValue property.
For testing purpose, and to see how the result will look like in the console, I changed the "send" function to "hello" (I don't know how to print the midi message in the console, thats why I changed it to print just " hello")
The result: you will see the console is keep printing the word "hello" until you release the button.
if (value == 127) {
setInterval(()=>{
console.log('hello')
//send('/control', 1,1,127)
}, 500)
} else {
clearInterval()
}
btw, if anyone can teach me how to print a midi message for a button in the Console that will be great !!
Finally I can share files now, here is the example session for using setInterval to repeat sending messages:
Example setInterval.json (2.1 KB)