如何在Swift中实现非常精确的计时? [英] How do I achieve very accurate timing in Swift?

查看:267
本文介绍了如何在Swift中实现非常精确的计时?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一种具有琶音/音序功能的音乐应用程序,该功能需要很高的定时精度。目前,使用计时器可以达到平均抖动约为5ms的准确度,但最大抖动约为11ms,这对于8、16和9音符的快速琶音来说是不可接受的。特别是第32个音符。

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.

我读过'CADisplayLink'比'Timer'更准确,但是由于它的精确度限制为1/60秒(〜16- 17ms),这似乎比使用 Timer 所实现的方法要不准确。

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.

进入CoreAudio是实现我想要的唯一方法吗?还有其他方法可以实现更准确的计时吗?

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

推荐答案

对于可接受的准确音乐节奏,唯一合适的计时源是使用Core音频或AVFoundation。

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

这篇关于如何在Swift中实现非常精确的计时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆