问题
I have an app that I'm working on that one of its functions is to record a sound through the iPhone microphone and be able to play it back to me.
Problem: After I record lets say, me talking for example, the playback level is extremely low. Now I did switch from AudioToolbox to AVFoundation and this happened after the switch. Do I need to code in a volume parameter for AVFoundation? I'm not seeing anything in the documentation.
I appreciate any help.
回答1:
I have solved this problem. In the AppDelegate.m I have the following in the didFinishLaunchingWithOptions
[[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayAndRecord error: &setAudioError];
if (setAudioError) { NSLog(@"error setting audio: %@", setAudioError); }
UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_Speaker;
AudioSessionSetProperty (
kAudioSessionProperty_OverrideAudioRoute,
sizeof (audioRouteOverride),
&audioRouteOverride);
The important part here, is that it was not working because I initially had AVAudioSessionCategoryPlayer error:&setAudioError
once I changed it to "PlayandRecord" I had no issues.
回答2:
When recording audio, or configuring a Record or PlayAndRecord Audio Session, the iPhone switches from using the speaker (on the bottom) to using the smaller earphone (nearer the front top), which produces a lower sound volume.
Your app can override this default by setting the Audio Session kAudioSessionProperty_OverrideAudioRoute property to kAudioSessionOverrideAudioRoute_Speaker . See Apple's Audio Session API documentation for details.
回答3:
Turn on Airplane mode in Settings. Your sound will be much higher.
来源:https://stackoverflow.com/questions/12101448/ios-iphone-sound-level-low-after-recording-sound-using-avfoundation