无论如何要在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