AVAudioMixerNode平移或AVAudioUnitSampler立体声平移属性无法更改AVAudioEngine的声音输出的左右平衡 [英] AVAudioMixerNode pan or AVAudioUnitSampler stereoPan properties not working to change left/right balance of sound output for AVAudioEngine

查看:66
本文介绍了AVAudioMixerNode平移或AVAudioUnitSampler立体声平移属性无法更改AVAudioEngine的声音输出的左右平衡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码,只演奏一个中音,但我希望能够调整平衡/声像,使其仅在左扬声器或右扬声器或某些组合之外播放.我认为更改"sampler.stereoPan"或"engine.mainMixerNode.pan"会达到目的,但似乎没有效果.有什么想法我做错了吗?

I have the following code, which plays a single midi note, but I want to be able to adjust the balance/pan so that it only plays out of the left speaker or the right speaker or perhaps some combination. I thought changing "sampler.stereoPan" or perhaps "engine.mainMixerNode.pan" would do the trick but it seems to have no effect. Any ideas what I'm doing wrong?

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)

推荐答案

根据 Apple开发者论坛 stereopan 的范围是-100到100.

According to Apple Developer Forum the range of stereopan is -100 to 100.

这篇关于AVAudioMixerNode平移或AVAudioUnitSampler立体声平移属性无法更改AVAudioEngine的声音输出的左右平衡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆