How do I achieve very accurate timing in Swift?

Viewed 3751

I am working on a musical app with an arpeggio/sequencing feature that requires great timing accuracy. Currently, using `Timer' I have achieved an accuracy with an average jitter of ~5ms, but a max jitter of ~11ms, which is unacceptable for fast arpeggios of 8th, 16th notes & 32nd notes especially.

I've read the 'CADisplayLink' is more accurate than 'Timer', but since it is limited to 1/60th of a second for it's accuracy (~16-17ms), it seems like it would be a less accurate approach than what I've achieved with Timer.

Would diving into CoreAudio be the only way to achieve what I want? Is there some other way to achieve more accurate timing?

3 Answers

I'm working on a sequencer App myself, and I would defiantly recommend using AudioKit for those purposes. It has a its own sequencer class. https://audiokit.io/

Related