获取 CPU 时钟时间 AVAudioEngine

Getting CPU clock time AVAudioEngine

如何在 运行 AVAudioEngine 上获取时钟时间或采样准确时间?

来自文档:

The AVAudioEngine class defines a group of connected AVAudioNode objects, known as audio nodes. You use audio nodes to generate audio signals, process them, and perform audio input and output.

对于时钟 and/or 采样时间,您需要在有效的 AVAudioNode 实例上调用 lastRenderTime

lastRenderTime 方法 return 是一个 AVAudioTime 对象。使用 AVAudioTime,您可以检索时间:

  1. sampleTime将return采样时间为sampleTimeValidreturnsYES.
  2. hostTime 将 return 主机时间如果 hostTimeValid returns `YES.