10

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

这是我进行切换的代码,它是由路由更改触发的。(我不太确定我是否正确地进行了更改,所以我也在这里问。)

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

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

码头。

- (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];
}  
}
4

4 回答 4

7

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

Voice I/O 的存在将导致输入/输出的处理方式非常不同。我们不希望这些单位有相同的增益水平,但水平不应该像你所说的那样大幅下降。

也就是说,Core Audio 工程表明您的结果可能与创建语音块的时间有关,它也会影响 RIO 实例。经过进一步讨论,Core Audio 工程师认为,由于您说电平差异非常大,因此如果您可以通过一些录音提交错误以突出您在语音 I/O 和远程 I/O 以及您的测试代码,这样我们就可以尝试在内部重现,看看这是否确实是一个错误。将上面概述的单个 IO 单元测试的结果以及进一步的比较结果包括在内是一个好主意。

没有 API 可以控制这个增益级别,一切都由操作系统内部设置,具体取决于音频会话类别(例如,VPIO 预计将始终与 PlayAndRecord 一起使用)以及已设置的 IO 单元。通常不期望两者同时实例化。

结论?我认为这是一个错误。:/

于 2013-01-15T10:43:08.333 回答
2

如果您没有正确处理您的音频单元,就会有一些关于低音量问题的讨论。基本上,第一个音频组件保留在内存中,任何后续播放都将在您或其他应用程序下进行,从而导致音量下降。

解决方案: 音频单元是 AudioComponentInstance 的,必须使用 AudioComponentInstanceDispose() 释放。

于 2012-12-20T19:04:57.143 回答
2

当我从语音处理 io (PlayAndRecord) 更改为 Remote IO (SoloAmbient) 时更改音频会话类别时,我取得了成功。确保在更改此设置之前暂停音频会话。您还必须取消初始化您的音频图。

于 2013-08-06T14:43:52.700 回答
0

来自我与 Apple AVAudioSession 工程师的一次谈话。

VPIO - 在音频样本上添加音频处理,这也会创建回声消除,这会导致音频电平下降

RemoteIO - 不会进行任何音频处理,因此音量将保持较高。

如果您在使用 RemoteIO 选项时正在寻找回声消除,您应该在渲染回调中创建自己的音频处理

于 2021-07-07T08:24:22.257 回答