Ios Can';t将转换器音频单元连接到混响效果
我正在尝试重塑一个Ios Can';t将转换器音频单元连接到混响效果,ios,core-audio,audiounit,Ios,Core Audio,Audiounit,我正在尝试重塑一个AUGraph,它看起来像这样: multichannel mixer -> remote I/O callback -> converter1 -> bandpass -> reverb -> converter2 -> mixer(bus 0) -> remote I/O AudioStreamBasicDescription filterStreamDesc = { 0 }; UInt32 size = sizeof(fil
AUGraph
,它看起来像这样:
multichannel mixer -> remote I/O
callback -> converter1 -> bandpass -> reverb -> converter2 -> mixer(bus 0) -> remote I/O
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)
变成这样:
multichannel mixer -> remote I/O
callback -> converter1 -> bandpass -> reverb -> converter2 -> mixer(bus 0) -> remote I/O
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)
图形初始化并启动后(即“动态”)。为了允许流格式传播和音频单元协商每个连接的格式,我将按以下顺序附加新创建的音频单元:
AUGraphClearConnections()
)mixer
->远程I/O
)转换器2
连接到混频器
,总线0(转换器2将其输出匹配到混频器:整数)带通
连接到混响
(两者都使用浮点)converter1
连接到bandpass
(converter1应将其输出匹配到带通:float)AudioUnitSetProperty
手动设置为整数)
…最后,将渲染回调连接到转换器1的输入
我检查所有核心音频功能的返回值(错误代码)。此外,连接每个节点后,我在图上调用AUGraphUpdate()
和CAShow()
最后一步(“5.将转换器1连接到带通效应”)失败,代码为-10868(kAudioUnitErr\u FormatNotSupported
)
这是在调用AUGraphUpdate()
之前的CAShow()
输出:
那么,发生了什么事
注意最后一次调用
AUGraphConnectNodeInput()
本身返回noErr
;在这之后,图形更新会抛出错误 因此,堆栈溢出的黄金法则再次出现:
发布一个问题,5分钟内你会在你的网页上找到答案
拥有但前提是你把它贴出来
撇开玩笑不谈,我就是这样解决的:
在连接外部转换器#1(在源渲染回调和第一个过滤器之间)之前,我获取了过滤器的本机流格式,并手动将其设置为转换器流格式(输出范围),如下所示:
multichannel mixer -> remote I/O
callback -> converter1 -> bandpass -> reverb -> converter2 -> mixer(bus 0) -> remote I/O
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)。现有的多声道混频器和新的混响滤波器之间的混频器以某种方式自动设置。。。(仍然有点困惑,但还是…核心音频,对吗?如果有人发布了一个答案,进一步解释发生了什么,例如,在这种情况下,你需要做什么和不需要做什么,我会接受。我仍然在发现这些东西…更新:没有人出现,所以我接受了我自己的答案。拯救了我的一天!奇怪的是,必须获得
reverbUnit
格式,而不仅仅是使用规范格式…如果有人知道为什么,我会感兴趣。我想这与格式如何传播有关。。。我还在琢磨自己。