How to increase volume of sound recorded using AVAudioRecorder

17,930

Solution 1

When recording audio, set the audio session to AVAudioSessionCategoryPlayAndRecord or just AVAudioSessionCategoryRecord. When you're done, set it back to just AVAudioSessionCategoryPlayback.

Solution 2

Solution for iOS 12 + Swift 5.0:

  • When starting recording use:

    recordingSession.setCategory(.record) // recordingSession is of type AVAudioSession

  • When playing the record audio use:

    recordingSession.setCategory(.playback)

Note: Place the statements into a do-catch block.

Share:
17,930
Parth Bhatt
Author by

Parth Bhatt

I am iPhone and iPad developer. https://github.com/akashraje/BidirectionalCollectionViewLayout ^[-_,A-Za-z0-9]$ NSRegularExpression *reg = [NSRegularExpression regularExpressionWithPattern:@"(#[a-zA-Z0-9_-]+)" options:NSRegularExpressionCaseInsensitive error:nil]; NSString *stringData = @"This is Parth known as #parth and this is an awesome place. I am fan of #scganguly."; int count = [reg numberOfMatchesInString:stringData options:0 range:NSMakeRange(0, [stringData length])]; NSLog(@"%d",count); if(count>0) { NSArray *array = [reg matchesInString:stringData options:0 range:NSMakeRange(0, [stringData length])]; NSLog(@"%@",array); NSMutableArray *stringArray = [[NSMutableArray alloc] init]; for (NSTextCheckingResult *result in array) { NSString *stringFinal = [stringData substringWithRange:result.range]; if(stringFinal != nil) { [stringArray addObject:stringFinal]; } } NSLog(@"stringArray: %@",stringArray); } For @user: @"(@[a-zA-Z0-9_]+)" NSLog(@"Request String: %@", requestString); NSData *requestData = [NSData dataWithBytes: [requestString UTF8String] length: [requestString length]]; // NSString *fileLoc = [[NSBundle mainBundle] pathForResource:@"url" ofType:@"plist" ]; // NSDictionary *fileContents = [[NSDictionary alloc] initWithContentsOfFile:fileLoc]; // NSString *urlLoc = [fileContents objectForKey:@"baseURL"]; NSString *urlLoc = @"http://portal.abc.com/candidate/post-info"; NSLog(@"URL is %@",urlLoc); NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL: [NSURL URLWithString: urlLoc]]; NSString *postLength = [NSString stringWithFormat:@"%d", [requestData length]]; [request setHTTPMethod: @"POST"]; [request setValue:postLength forHTTPHeaderField:@"Content-Length"]; [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"]; [request setHTTPBody: requestData]; http://blog.stackoverflow.com/archive/ https://developer.apple.com/library/prerelease/ios/documentation/General/Conceptual/CocoaTouch64BitGuide/Introduction/Introduction.html http://nscookbook.com/2013/03/ios-programming-recipe-19-using-core-motion-to-access-gyro-and-accelerometer/ http://code4app.net/category/coremotion http://www.devx.com/wireless/Article/44799 upload audio file to php ios Android post request on IOS https://developers.facebook.com/docs/ios/share https://github.com/oliverbarreto/FastFavs/blob/master/TODO2.h

Updated on June 06, 2022

Comments

  • Parth Bhatt
    Parth Bhatt almost 2 years

    I am using the link mentioned below to record audio through my iPhone app:

    How do I record audio on iPhone with AVAudioRecorder?

    When I try to play my recordings using AVAudioPlayer on my device, I have seen that the sound volume of my recordings is very low even when my device volume is full.

    Recording is working fine.

    What can be done to increase the volume?

  • Parth Bhatt
    Parth Bhatt about 13 years
    Category is already set to AVAudioSessionPlayAndRecord. I have posted the link I am using. I am using the same code as given there by @unforgiven so may be you can see there and give some suggestions.
  • Hollance
    Hollance about 13 years
    Right, so when you're done, set it back to AVAudioSessionCategoryPlayback. That will make the sound louder. For some reason, playback and recording at the same time reduces the volume, probably because doing both requires more battery power.
  • TK189
    TK189 almost 12 years
    Thank again. This post helps me a lot.
  • MikeyWard
    MikeyWard over 10 years
    The volume difference may also be to help prevent feedback from the speaker back into the microphone when simultaneously recording and playing.
  • Pawan Sharma
    Pawan Sharma over 9 years
    Didn't work for me. I have set volume level to 1.0 however it works fine in iPad. Any suggestions?