[SOLVED] Can we get a simple `setTimeout()` mechanism for the MIDI Remote API?

Having an equivalent to other JS runtimes’ setTimeout() available in the MIDI Remote API would be awesome :sunglasses:


Sometimes, it would be nice to take actions a specified time after an event handler has been invoked. A prominent use cases is showing a changed value on a remote device display for a certain amount of time after the value was changed (like the MCU protocol does). Currently, the only hacky workaround I found is using an action binding’s makeRepeating() to repeatedly activate a sub page – which seems to introduce a considerably large runtime overhead.


I’m thinking of something like setTimeout(functionRef, delay) to invoke functionRef (approximately) after delay ms. No need to implement pass-through parameters (they’re just syntactic sugar), and no need to return timeout IDs and implement clearTimeout(timeoutId) – we (devs using the MR API) can take care of this ourselves if we need to.

What’s important though is that the function provided to setTimeout() is invoked with an activeDevice context argument so it can do everything regular event handlers can do too (like setting process values or sending MIDI messages).


I know Duktape doesn’t bring an event loop out of the box, and I’m also not requesting a full-featured JS event loop. Maybe it’s worth pointing to the simple event loop example in the Duktape repo, but that is already more than a basic setTimeout() might need.

Anyway, this would be a super useful addition to the MR API!

@Jochen_Trappe May I bother you with this? :innocent:

Hi mate, totally reasonable request!
Till then, maybe you can give this one a try? Works for me, but who knows :slight_smile:

1 Like

This can be solved nicely with the new mOnIdle callback available in the MR API v1.1 – thanks @Jochen_Trappe! :tada:


You’re welcome! :hugs: