我正在编写一个小应用程序来录制多个曲目并相互播放。我正在使用 PlaybackAndRecord 模式,并将我的输出路由到主扬声器。问题是底部麦克风仍然用于输入,所以现在我在录制时从其他轨道的输出在新轨道上非常响亮。这是我到目前为止所拥有的:
audioSession = [AVAudioSession sharedInstance];
[audioSession setCategory:AVAudioSessionCategoryPlayAndRecord error:nil];
OSStatus propertySetError = 0;
UInt32 allowMixing = true;
propertySetError = AudioSessionSetProperty(kAudioSessionProperty_OverrideCategoryMixWithOthers, sizeof(allowMixing), &allowMixing);
UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_Speaker;
AudioSessionSetProperty (kAudioSessionProperty_OverrideAudioRoute,sizeof (audioRouteOverride),&audioRouteOverride);
[audioSession setActive:YES error:nil];