如何让位置音频在SceneKit中工作?

Jed*_*ane 11 audio ios scenekit

我无法让位置音频在SceneKit中工作.从Xcode生成的SceneKit游戏模板开始,我在handleTap方法的末尾添加了以下代码:

let ship = scnView.scene!.rootNode.childNode(withName: "ship", recursively: true)!  
if let source = SCNAudioSource(fileNamed: "art.scnassets/monoAudioTest.wav")  
{  
    source.volume = 1  
    source.isPositional = true  
    source.shouldStream = true  
    source.loops = true  
    source.load()  
    let player = SCNAudioPlayer(source: source)  
    ship.addAudioPlayer(player)  
}  

ship.runAction(SCNAction.move(to: SCNVector3(0, 0, -10000), duration: 8)) 
Run Code Online (Sandbox Code Playgroud)

音频播放但是当喷嘴远离相机时音量不会减小.我错过了一些步骤或做出了一些错误的假设吗?

交叉发布到Apple开发者论坛.

Ada*_*eld 8

正如Jed Soane所提到的,并且Apple在Radar中证实,问题是我的音频文件是立体声而不是单声道.只有单声道音频文件才能用于定位音频.


mnu*_*ges 3

您应该能够使用 获得位置音频source.shouldStream = false