Send two CC based on time

Hi everyone,

I was wondering if it would be possible to send two messages with a single button depending on how we trigger it.

To be more precise, IF WE TAP the button it should send the following:
send('midi:device_name', '/control', 1, 15, 1)

Then in the case where WE HOLD that same button for let's say 5 seconds it would send:
send('midi:device_name', '/control', 2, 15, 1)

Would that be possible?

With a button in push mode, the following scripts should do

// onCreate
locals.holding = false

// onValue
if (value === 1) {
  locals.hold = true
  setTimeout(()=>{
    send('midi:device_name', '/control', 2, 15, 1)
    locals.hold = false
  }, 5000) // 5s
} else {
  if (locals.hold) {
    clearTimeout()
    locals.hold = false
    send('midi:device_name', '/control', 1, 15, 1)
  }
}
2 Likes