Extremely Slow MIDI response

Hi folks,

I'm actually testing TouchOSC with Keyboard Maestro, which open quite some great perspectives.
However, I'm a bit surprised by how the thing is slow.
You'll find attached a screenshot of my basic test: setting the system volume based on the value sent by TouchOSC (simple slider from 0 to 100)
When I move the TouchOSC slider, values are instantly sent, but the system struggle to handle them. The system volume slider hangs, beach ball and so on.
I'm running a boosted Mac Pro early 2008 which doesn't show any significant performance issues (and should specially not for this kind of things).

Any idea? Thanks in advance.

Setting the system volume is done with AppleScript. So it is a relatively slow process. Even on my relatively fast Mac it takes about 0.2 seconds.

However a MIDI change can happen hundreds of times a second (probably more - and then Keyboard Maestro will have no chance of keeping up with it).

You will be able to improve your results a lot by ensuring that only one of these macros happens at a time using the Semaphore Lock action, something like this:

  • Set Variable Latest to %TriggerValue[3]%
  • Semaphore Lock "My MIDI Lock" with timeout 0.01 seconds, no failure notification
  • Until
    • Set Variable LocalValue to %Variable% Latest%
    • Use Variable LocalValue to set the system volume
  • Until variable LocalValue is %Variable% Latest%

It's not completely perfect, it is possible the final value set will not always be the final MIDI value sent for a number of race condition reasons, but generally it should work a lot better than your current macro.

1 Like

This have been a big help!
Thank you @peternlewis!