Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I achieve very accurate timing in Swift?

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?

like image 647
PlateReverb Avatar asked Jul 15 '17 16:07

PlateReverb


1 Answers

For acceptable musically accurate rhythms, the only suitable timing source is using Core Audio or AVFoundation.

like image 50
hotpaw2 Avatar answered Sep 28 '22 05:09

hotpaw2