我有以下代碼,它播放單個MIDI信息,但我希望能夠調整平衡/平移,以便它只能播放左邊的揚聲器或右邊的揚聲器或者可能是某種組合。我認爲改變「sampler.stereoPan」或者「engine.mainMixerNode.pan」可以做到這一點,但它似乎沒有效果。任何想法我做錯了什麼?AVAudioMixerNode pan或AVAudioUnitSampler stereoPan屬性無法改變AVAudioEngine的聲音輸出的左/右平衡
engine = AVAudioEngine()
sampler = AVAudioUnitSampler()
sampler.stereoPan = -1.0 // doesn't work
//engine.mainMixerNode.pan = -1.0 // doesn't work
engine.attachNode(sampler)
engine.connect(sampler, to: engine.mainMixerNode, format: engine.mainMixerNode.outputFormatForBus(0))
var error: NSError?
engine.startAndReturnError(&error)
sampler.startNote(65, withVelocity: 64, onChannel: 1)
是的,對於'AVAudioPlayerNode.pan'同樣的事情,標題寫着「範圍:-1.0 - > 1.0」,但真的是「-100 - > 100「 –