2012-12-10 35 views
8

在我的应用程序中,我需要在这两个不同的AudioUnit之间切换。 每当我从VPIO切换到RemoteIO时,录制音量都会有所下降。相当大的下降。 虽然没有改变播放音量。任何人都经历过这个?RemoteIO和VPIO之间的录制音量下降切换

下面是我做开关的代码,它由路由更改触发。 (我不太确定我是否做了正确的改变,所以我也在这里问。)

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

谢谢,感谢任何帮助,我可以得到。

码头。

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

回答

5

我用我的苹果开发者支持。 这里的支持说的:会导致

语音I/O的存在正在处理非常不同的输入/输出。我们不希望这些单位的收益水平完全相同,但是这些水平不应该像你指出的那样急剧下降。

也就是说,核心音频工程表明您的结果可能与语音模块创建时相关,它也影响RIO实例。经过进一步的讨论,Core Audio工程师认为,由于您认为级别差异非常激烈,因此如果您可以通过录制某个错误来突出显示您在语音I/O和远程I/O以及您的测试代码,因此我们可以尝试在内部进行复制并查看这是否确实是一个错误。包含上面列出的单位IO单元测试的结果以及进一步的比较结果将是一个好主意。

没有API控制此增益级别,所有内容都由操作系统根据音频会话类别进行内部设置(例如,VPIO有望始终与PlayAndRecord一起使用)以及设置了哪个IO单元。一般来说,预计两者都不会被同时实例化。

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

2

如果您没有正确处置音频设备,有一些关于低音量问题的讨论。基本上,第一个音频组件停留在内存中,任何连续的播放都会在您的或其他应用程序下闪烁,导致音量下降。

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

+1

嗨,洛基,我试过了。因为我使用AUGraphNodeInfo(theGraph,remoteIONode,0,&_remoteIOUnit);获取remoteIO实例,似乎我无法使用AudioComponentInstanceDispose(它崩溃)。我读过你似乎在谈论的帖子。似乎并不适合我:/ – lppier

2

当我从语音处理io(PlayAndRecord)转到远程IO(SoloAmbient)时,我更改了音频会话类别。确保在更改前暂停音频会话。您还必须取消初始化您的音频图。

+0

这适用于我,谢谢! – scharli