I've been searching all over to find some sample code of how to use Apple's MusicSequence framework or anything else available. I'm an Objective C programmer, so I find the MusicSequence documentation (and also WWDC videos) rather thin and TBH, without some sample code, unusable from where I stand.
I am able to send MIDI messages using PGMidi but what I can't find is how to create events and sequence/loop them in real time, allowing the possibility to change the pattern while it's playing - classic drum machine / step sequencer style. I found some references to CADisplayLink for accurate timing, but that doesn't help either (although it's being called 60 times/second - every 0.016667 sec, a BPM of 135 would need calls every 0.44444 which is not divisible by the 0.016667 frame).
I've been looking at libpd also and while it's possible to create a sequencer directly in pd, the recommendation is to use iOS' timing.
Everything else I found on GitHub is more than two years old and usually comes with many compiler errors.