I tried using AVAudioSession
and AVAudioPlayer
to record and play sounds respectively but the sound volume is very low.
I tried putting volume value of AVAudioPlayer
to 1.0 and more but didn't help much.
What could be my other options to record sound which can be loud enough to play back?
Swipe down from the top of your screen to see the quick settings tiles and tap the screen recorder button. A floating bubble will appear with a record and microphone button. If the latter is crossed out, you're recording internal audio, and if it's not, you get sound straight from your phone's mic.
Using the Audio Recorder, you can record your voice, an instrument, or any other sound using the microphone on your iPhone, and play it back in GarageBand.
This code should be useful for you:
#import <AudioToolbox/AudioServices.h>
UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_Speaker;
AudioSessionSetProperty (kAudioSessionProperty_OverrideAudioRoute,
sizeof (audioRouteOverride),&audioRouteOverride);
It will increase volume. The functionality of the code is to convert the ordinary sound to speaker sound on ur iPhone. That's why kAudioSessionOverrideAudioRoute_Speaker is used.
Since iOS7 you can fix this issue directly with AVAudioSession
The overrideOutputAudioPort method does the same than AudioSessionSetProperty
NSError *setOverrideError;
NSError *setCategoryError;
AVAudioSession *session = [AVAudioSession sharedInstance];
[session setCategory:AVAudioSessionCategoryPlayAndRecord error:&setCategoryError];
if(setCategoryError){
NSLog(@"%@", [setCategoryError description]);
}
[session overrideOutputAudioPort:AVAudioSessionPortOverrideSpeaker error:&setOverrideError];
if(setOverrideError){
NSLog(@"%@", [setOverrideError description]);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With