Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios AVAudioMixerNode pan或AvaudioInSampler stereoPan属性无法更改AVAudioEngine声音输出的左/右平衡_Ios_Swift - Fatal编程技术网

Ios AVAudioMixerNode pan或AvaudioInSampler stereoPan属性无法更改AVAudioEngine声音输出的左/右平衡

Ios AVAudioMixerNode pan或AvaudioInSampler stereoPan属性无法更改AVAudioEngine声音输出的左/右平衡,ios,swift,Ios,Swift,我有下面的代码,它播放一个midi音符,但我希望能够调整平衡/平移,以便只播放左扬声器或右扬声器,或者可能是某种组合。我原以为更改“sampler.stereoPan”或“engine.mainMixerNode.pan”就可以了,但似乎没有效果。知道我做错了什么吗 engine = AVAudioEngine() sampler = AVAudioUnitSampler() sampler.stereoPan = -1.0 // doesn't work //engine.mainMixer

我有下面的代码,它播放一个midi音符,但我希望能够调整平衡/平移,以便只播放左扬声器或右扬声器,或者可能是某种组合。我原以为更改“sampler.stereoPan”或“engine.mainMixerNode.pan”就可以了,但似乎没有效果。知道我做错了什么吗

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)

您应该在连接任何节点后设置其pan,pan设置在engine.connect方法中再次默认。

根据stereopan的范围是-100到100。

是的,对于
AvaudioPayerNode.pan
,标题上写着“范围:-1.0->1.0”,但实际上是“-100->100”