录制RemoteIO和VPIO之间的音量下降切换

2022-09-01 ios core-audio remoteio

在我的应用程序中,我需要在这两个不同的AudioUnits之间切换。 每当我从VPIO切换到RemoteIO时,我的录制音量都会下降。降幅相当大。 但播放音量没有变化。有人经历过这种情况吗?

下面是我进行切换的代码,它是由路由更改触发的。(我不太确定我的更改是否正确,因此我也在此询问。)

如何解决录制音量下降的问题?

谢谢,感谢我能得到的任何帮助。

Pier。

- (void)switchInputBoxTo : (OSType) inputBoxSubType
{
OSStatus result;

if (!remoteIONode) return; // NULL check

// Get info about current output node
AudioComponentDescription outputACD;
AudioUnit currentOutputUnit;

AUGraphNodeInfo(theGraph, remoteIONode, &outputACD, &currentOutputUnit);

if (outputACD.componentSubType != inputBoxSubType)
{
    AUGraphStop(theGraph);
    AUGraphUninitialize(theGraph); 
    result = AUGraphDisconnectNodeInput(theGraph, remoteIONode, 0);
    NSCAssert (result == noErr, @"Unable to disconnect the nodes in the audio processing graph. Error code: %d '%.4s'", (int) result, (const char *)&result);
    AUGraphRemoveNode(theGraph, remoteIONode);
    // Re-init as other type

    outputACD.componentSubType = inputBoxSubType;
    // Add the RemoteIO unit node to the graph
    result = AUGraphAddNode (theGraph, &outputACD, &remoteIONode);
    NSCAssert (result == noErr, @"Unable to add the replacement IO unit to the audio processing graph. Error code: %d '%.4s'", (int) result, (const char *)&result);

    result = AUGraphConnectNodeInput(theGraph, mixerNode, 0, remoteIONode, 0);
    // Obtain a reference to the I/O unit from its node
    result = AUGraphNodeInfo (theGraph, remoteIONode, 0, &_remoteIOUnit);
    NSCAssert (result == noErr, @"Unable to obtain a reference to the I/O unit. Error code: %d '%.4s'", (int) result, (const char *)&result);

    //result = AudioUnitUninitialize(_remoteIOUnit);

    [self setupRemoteIOTest]; // reinit all that remoteIO/voiceProcessing stuff
    [self configureAndStartAudioProcessingGraph:theGraph];
}  
}

解决方案

为此,我使用了我的苹果开发人员支持。 以下是支持人员所说的:

语音I/O的存在将导致以非常不同的方式处理输入/输出。我们根本不希望这些单元具有相同的增益水平,但这些水平不应该像您所指出的那样急剧下降。

也就是说,Core Audio工程表明,您的结果可能与创建语音块的时间有关,它也会影响RIO实例。在进一步的讨论中,Core Audio Engineering认为,既然您说级别差异非常大,因此,如果您可以提交一个错误,并记录一些录音,以突出您听到的语音I/O和远程I/O之间的级别差异,以及您的测试代码,这样我们就可以尝试在内部复制,看看这是否真的是一个错误。最好包括上述单个IO单元测试的结果以及进一步的比较结果。

没有控制此增益级别的API,所有内容都由操作系统根据音频会话类别(例如,VPIO应始终与PlayAndRecord一起使用)以及已设置的IO单元在内部设置。通常情况下,不应同时实例化这两个实例。

结论?我觉得这是个窃听器。:/

相关文章