我有一个 AVAudioEngine 播放多个 AVAudioPlayerNodes。我正在使用 AVAudioEnvironmentNode 来模拟这些的定位。该职位似乎运作正常。但是,我希望这些能够与头部跟踪一起使用,这样如果用户移动他们的头部,播放器发出的声音也会相应地移动。我不知道该怎么做,也找不到关于这个主题的任何文档。
要跟踪头部的位置,您需要使用:
->
CMHeadphoneMotionManager
func startDeviceMotionUpdates(to: OperationQueue, withHandler: CMHeadphoneMotionManager.DeviceMotionHandler)
.CMDeviceMotion
的值需要是
转换为 AVAudioEnvironmentNode
.listenerPosition: AVAudio3DPoint, listenerAngularOrientation: AVAudio3DAngularOrientation, listenerVectorOrientation: AVAudio3DVectorOrientation
)