gpt4 book ai didi

ios - 无法将转换器音频单元连接到混响效果

转载 作者:行者123 更新时间:2023-11-29 12:48:16 25 4
gpt4 key购买 nike

我正在尝试 reshape 一个看起来像这样的 AUGraph:

multichannel mixer -> remote I/O

像这样:

callback -> converter1 -> bandpass -> reverb -> converter2 -> mixer(bus 0) -> remote I/O

在图表初始化并启动后(即“运行中”)。为了允许流格式传播和音频单元协商每个连接的格式,我按以下顺序附加新创建的音频单元:

  1. 清除所有现有连接 (AUGraphClearConnections())。
  2. 重建默认连接(mixer -> remote I/O)
  3. converter2 附加到 mixer,总线 #0 (converter2 将其输出匹配到 mixer:整数)
  4. reverb 附加到 converter2 (converter1 将其输入匹配到 reverb:float)
  5. bandpass附加到reverb (都使用float)
  6. converter1 附加到 bandpass (converter1 应匹配其输出到带通:float)

(converter1 的输入之前使用 AudioUnitSetProperty 手动设置为整数)

...最后,将渲染回调连接到转换器 #1 的输入。

我检查了所有 Core Audio 函数的返回值(错误代码)。此外,在连接每个节点后,我在图上调用了 AUGraphUpdate()CAShow()

最后一步(“5. 将转换器 #1 连接到带通效果器”)失败,代码为 -10868 (kAudioUnitErr_FormatNotSupported)。

这是对 AUGraphUpdate() 的违规调用之前的 CAShow() 输出:

AudioUnitGraph 0x305A000:
Member Nodes:
node 1: 'aumx' 'mcmx' 'appl', instance 0x17822d0e0 O I
node 2: 'auou' 'rioc' 'appl', instance 0x17822cd80 O I
node 3: 'aufc' 'conv' 'appl', instance 0x170833e40 O
node 4: 'aufx' 'bpas' 'appl', instance 0x170827b60 O I
node 5: 'aufx' 'rvb2' 'appl', instance 0x170835100 O I
node 6: 'aufc' 'conv' 'appl', instance 0x170a21460 O I
Connections:
node 1 bus 0 => node 2 bus 0 [ 2 ch, 44100 Hz, 'lpcm' (0x00000C2C) 8.24-bit little-endian signed integer, deinterleaved]
node 6 bus 0 => node 1 bus 0 [ 2 ch, 44100 Hz, 'lpcm' (0x00000C2C) 8.24-bit little-endian signed integer, deinterleaved]
node 5 bus 0 => node 6 bus 0 [ 2 ch, 44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
node 4 bus 0 => node 5 bus 0 [ 2 ch, 44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
CurrentState:
mLastUpdateError=0, eventsToProcess=F, isInitialized=T, isRunning=T (1)

那么,这是怎么回事?

注意 最后一次调用 AUGraphConnectNodeInput() 本身返回 noErr;它是图形更新之后抛出错误。

最佳答案

因此,Stack Overflow 的黄金法则再次出现:

Post a question, and within 5 minutes you will find the answer on your own. But only if you post it!

开个玩笑,我是这样解决的:

在连接外部转换器 #1(在源渲染回调和第一个过滤器之间)之前,我获取了过滤器的 native 流格式,并手动将其设置为转换器流格式(输出范围),如下所示:

AudioStreamBasicDescription filterStreamDesc = { 0 };

UInt32 size = sizeof(filterStreamDesc);

// GET
result = AudioUnitGetProperty(reverbUnit,
kAudioUnitProperty_StreamFormat,
kAudioUnitScope_Input, // output or global should work, too?
0,
&(filterStreamDesc),
&size);

[self checkAudioResult:result]; // (custom method that compares against noErr)

// SET
result = AudioUnitSetProperty(converterUnit0,
kAudioUnitProperty_StreamFormat,
kAudioUnitScope_Output,
0,
&(filterStreamDesc),
size);

//(input stream format already set above)

[self checkAudioResult:result]; // (custom method that compares against noErr)

总而言之,出于某种原因,我必须在连接此转换器之前直接设置两种流格式:输入(int)和输出(float)。介于现有的多 channel 混音器和新的混响滤波器之间的那个以某种方式设法自动设置自己......(仍然有点困惑,但话又说回来......核心音频,对吧?)

关于ios - 无法将转换器音频单元连接到混响效果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23100726/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com