【问题标题】:Can't connect converter Audio Unit to Reverb Effect无法将转换器音频单元连接到混响效果器
【发布时间】:2014-04-16 05:28:39
【问题描述】:

我正在尝试重塑一个看起来像这样的AUGraph

multichannel mixer -> remote I/O

变成这样:

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

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

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

(之前使用AudioUnitSetProperty手动将转换器1的输入设置为整数)

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

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

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

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

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;之后的图形更新会引发错误。

【问题讨论】:

    标签: ios core-audio audiounit


    【解决方案1】:

    所以,堆栈溢出的黄金法则又来了:

    发布一个问题,5 分钟内你会在你的手机上找到答案 自己的。但前提是你发布它!

    除了笑话,这就是我解决它的方法:

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

    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),然后才能连接此转换器。现有的多通道混音器和新的混响滤波器之间的那个不知何故设法自动设置......(仍然有点困惑,但又一次......Core Audio,对吗?)

    【讨论】:

    • 如果有人发布了一个解释进一步发生了什么的答案,例如在这种情况下,你需要做什么和不需要做什么,我都会接受。我还在发现这些东西......
    • 更新:没有人出现,所以我接受了自己的答案。
    • 拯救了我的一天!奇怪的是必须得到reverbUnit 格式,而不是仅仅使用规范的格式……如果有人知道为什么,我会感兴趣的。
    • 我想这与格式的传播方式有关......我仍在弄清楚自己。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多