AKSequencer时基 - 主机时间

时间:2018-04-23 22:09:12

标签: ios audiokit

无论如何要在AKSequencer播放时获得时基?

需要时基才能与某些功能和其他应用正确同步。我试过这个功能,但每个节拍时基都在减少。

func getTimebase() -> UInt64 {
    if sequencer.isPlaying {
        let posSeconds = sequencer.currentPosition.seconds
        let timeBase = mach_absolute_time() - AVAudioTime.hostTime(forSeconds: posSeconds)
        return timeBase
    } else { return 0 }
}

打印timeBase:print(“timeBase:”,timeBase)

timeBase:  24584445928131
timeBase:  24584430726122
timeBase:  24584421019729
timeBase:  24584408406139
timeBase:  24584397028323
timeBase:  24584384435312

0 个答案:

没有答案