Finger, developers of two of the first iOS apps to implement MIDI Clock Sync effectively, MoDrum and BassLine, have shared their take on Avoiding the Pitfalls of CoreMIDI Programming:
- Do not block the CoreMIDI realtime thread.
Do not call blocking functions like printf(), NSLog(), malloc() or Objective C method calls from any CoreMIDI I/O context such as the input callback.
- Take event timestamps into account.
Consult Technical Q&A QA1643 for informations on how to deal with host time on iOS.
- Schedule output in advance
Schedule outgoing messages for future delivery, especially when sending over network (see thekMIDIPropertyAdvanceScheduleTimeMuSec property).
We’re reprinting their suggestions here, because incomplete MIDI support is one of the biggest problems with current iOS music apps. And effective MIDI implementation becomes more and more useful as more and more apps support it.
You can see Finger’s implementation in action above, with their demonstration of sync between their MoDrum and BassLine iOS apps.
If you’re a developer and your app supports MIDI Clock Sync like this, leave a comment below and let people know about it!