Reputation: 71
I plan to build a sequencer using audioKit.
I would like to generate midiNotes on the fly according to user interactions, so I'd like to be able to record and play midi but not only (I'd like to record some time stamped objects as well).
I guess I have to set a recursive loop with a delay somewhere, but I don't know what is the best way to have a stable clock that I could control remotely (stop or suspend, change tempo...).
Is there some components already implemented in audioKit to achieve this? Or should I use some system components (Grand central Dispatch or NSTimer...)
Any suggestion is welcome,
Thanks :-)
Upvotes: 2
Views: 1041
Reputation: 71
I got an answer from Aurelius Prochazka (AudioKit Developper) "AKOperations can't trigger arbitrary code."
I found a solution using "dispatch_after" in swift that seems to do the trick. (stable even in playground with a clock set to 1 ms per tick)
But after digging the web and according to Aurelius, using CADisplayLink seems to be more appropriate to have a stable clock.
There's an example in AudioKit playgrounds of a triggering clock (AKPlaygroundLoop.swift in AudioKit.playground/Sources folder)
Upvotes: 3