21

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?

Community
  • 1
  • 1
Parth Bhatt
  • 19,381
  • 28
  • 133
  • 216
  • 2
    This should not have been marked as a duplicate IMO; the "duplicate" question has answers in Objective C, while the answer provided here is Swift related – verbose Mar 18 '15 at 22:32
  • +1 for not a duplicate. This is asking specifically about playback volume not the generic "How do I record stuff" question linked. – Eric98118 May 13 '15 at 03:17

3 Answers3

40

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

Hollance
  • 2,958
  • 16
  • 15
  • 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. – Parth Bhatt Apr 14 '11 at 10:57
  • 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. – Hollance Apr 15 '11 at 22:08
  • 1
    Thank again. This post helps me a lot. – TK189 Jun 26 '12 at 04:05
  • 1
    The volume difference may also be to help prevent feedback from the speaker back into the microphone when simultaneously recording and playing. – MikeyWard Dec 28 '13 at 20:20
  • Didn't work for me. I have set volume level to 1.0 however it works fine in iPad. Any suggestions? – Pawan Sharma Aug 16 '14 at 08:43
1

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.

Baran
  • 2,710
  • 1
  • 23
  • 23
-1

you can try AVaudioSession.sharedInstance().overrideOutputAudioPort(AVAudioSessionPortOverride.Speaker) this is because your output device set to inbuilt speaker in iPhone. while iTab have only speaker so no problem occurs.

Pirate X
  • 3,023
  • 5
  • 33
  • 60