使用 iOS 3d 混合器

发布于 2024-11-16 11:06:03 字数 480 浏览 1 评论 0原文

我的 AUGraph 设置相当简单,将多通道混音器连接到 I/O 单元。通过回调函数访问播放,一切正常。

我正在尝试切换到 3D 混音器而不是多通道混音器。因此,我将参数从 kAudioUnitSubType_MultiChannelMixer 切换为 kAudioUnitSubType_AU3DMixerEmbedded 并保留所有其他设置相同。

结果是一种高音调的呜呜声,听起来像是什么东西,然后就变成了呜呜声。我已经检查了每个 3D 混音器单元的 参数 并将它们设置为默认值,但是没有任何变化。不过,打开和关闭 k3DMixerParam_Enable 参数确实可以使播放静音和取消静音。

我可能错过了什么设置?或者知道在哪里可以找到可用的 3d 混合器的示例?

I have a AUGraph setup fairly simply with a multichannel mixer connected to an I/O unit. The playback is accessed through a callback function and everything works nicely.

I am trying to switch over to the 3D Mixer instead of the Multichannel mixer. So I switched the parameter from kAudioUnitSubType_MultiChannelMixer to kAudioUnitSubType_AU3DMixerEmbedded and left all the other setup the same.

The result was sort of a high pitched whine that seemed to start sounding like something then became just whine-ish. I have gone through each of the 3D Mixer unit's parameters and set them to their defaults but there was no change. Flipping on and off the k3DMixerParam_Enable parameter did work at muting and unmuting the playback though.

What setup I might have missed? or know where to find an example of a working 3d Mixer?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

掌心的温暖 2024-11-23 11:06:03

正如已经指出的,3d 混音器需要单声道输入。但您还必须使用 UInt16 作为输入示例数据类型。这是一个有效的 AudioStreamBasicDescription:

AudioStreamBasicDescription streamFormat = {0};
size_t bytesPerSample = sizeof (UInt16);

streamFormat.mFormatID          = kAudioFormatLinearPCM;
streamFormat.mFormatFlags       = kAudioFormatFlagsCanonical;
streamFormat.mBytesPerPacket    = bytesPerSample;
streamFormat.mFramesPerPacket   = 1;
streamFormat.mBytesPerFrame     = bytesPerSample;
streamFormat.mChannelsPerFrame  = 1;
streamFormat.mBitsPerChannel    = 8 * bytesPerSample;
streamFormat.mSampleRate        = graphSampleRate;

// Set the input stream format of the desired 3D mixer unit audio bus
AudioUnitSetProperty (
                      mixerUnit,
                      kAudioUnitProperty_StreamFormat,
                      kAudioUnitScope_Input,
                      audioBus,
                      &streamFormat,
                      sizeof (streamFormat)
                      );

As already pointed out the 3d mixer needs mono inputs. But you also have to use UInt16 as the input sample data type. This is a working AudioStreamBasicDescription:

AudioStreamBasicDescription streamFormat = {0};
size_t bytesPerSample = sizeof (UInt16);

streamFormat.mFormatID          = kAudioFormatLinearPCM;
streamFormat.mFormatFlags       = kAudioFormatFlagsCanonical;
streamFormat.mBytesPerPacket    = bytesPerSample;
streamFormat.mFramesPerPacket   = 1;
streamFormat.mBytesPerFrame     = bytesPerSample;
streamFormat.mChannelsPerFrame  = 1;
streamFormat.mBitsPerChannel    = 8 * bytesPerSample;
streamFormat.mSampleRate        = graphSampleRate;

// Set the input stream format of the desired 3D mixer unit audio bus
AudioUnitSetProperty (
                      mixerUnit,
                      kAudioUnitProperty_StreamFormat,
                      kAudioUnitScope_Input,
                      audioBus,
                      &streamFormat,
                      sizeof (streamFormat)
                      );
郁金香雨 2024-11-23 11:06:03

正如所有答案已经提到的:iOS 上的 3D Mixer 需要单声道输入。

在 iOS 8 / Xcode 6 上,规范格式的概念已被弃用,我发现这个(并且只有这个)单声道流格式描述用作 3D 混合器输入总线流格式描述:

AudioStreamBasicDescription monoStreamFormat = {0};
monoStreamFormat.mSampleRate        = sampleRate;
monoStreamFormat.mFormatID          = kAudioFormatLinearPCM;
monoStreamFormat.mFormatFlags       = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked;
monoStreamFormat.mBitsPerChannel    = 16;
monoStreamFormat.mChannelsPerFrame  = 1;
monoStreamFormat.mFramesPerPacket   = 1;
monoStreamFormat.mBytesPerPacket    = 2;
monoStreamFormat.mBytesPerFrame     = 2;

应该设置采样率,然后从 AVAudioSession

在连接到 3D 混合器输入的音频单元的输出上设置此格式。这可能是一个 AUConverter 单元...

但是请注意,这尚未经过测试 << iOS 8。

As all answers already mention: the 3D Mixer on iOS needs mono inputs.

On iOS 8 / Xcode 6, the concept of canonical formats is deprecated and I found this (and only this) mono stream format description working as 3D Mixer input bus stream format description:

AudioStreamBasicDescription monoStreamFormat = {0};
monoStreamFormat.mSampleRate        = sampleRate;
monoStreamFormat.mFormatID          = kAudioFormatLinearPCM;
monoStreamFormat.mFormatFlags       = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked;
monoStreamFormat.mBitsPerChannel    = 16;
monoStreamFormat.mChannelsPerFrame  = 1;
monoStreamFormat.mFramesPerPacket   = 1;
monoStreamFormat.mBytesPerPacket    = 2;
monoStreamFormat.mBytesPerFrame     = 2;

The sample rate should be set and then obtained from the AVAudioSession.

Set this format on the output of the Audio Unit connected to the 3D Mixer input. Which is probably a AUConverter Unit...

Note however, this hasn't been tested for < iOS 8.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文