Hi to all. In my app i record and play audio at the same time. The app is almost finished. But there is one thing, that annoying me. When audio session is set to PlayAndRecord, sounds become quiet in comparison with the same sounds with the SoloAmbient category. Is there any way to make sound louder using PlayAndRecord?
Ask the user to plug in headphones?
The headphone + mic combination doesn't suffer from this problem.
I don't know if it's a bug, a consequence of the audio hardware, or if the quiet playback is just an intentional and hamfisted way of getting cleaner recordings.
UPDATE
I found out that setting the PlayAndRecord session changes your audio route to the receiver.
Apparently the use case is for telephony applications where the user holds the device up to his ear.
If that doesn't violate the Principle of Least Surprise, I don't know what does.
when you use the session for play and record, the playback comes out of the speaker used for the phone, otherwise it comes out the speaker located at the bottom of the phone. this is to prevent feedback. you can override this like so (but watch out for feedback, not an issue if you aren't doing both at once)
//when the category is play and record the playback comes out of the speaker used for phone conversation to avoid feedback
//change this to the normal or default speaker
UInt32 doChangeDefaultRoute = 1;
AudioSessionSetProperty (kAudioSessionProperty_OverrideCategoryDefaultToSpeaker, sizeof (doChangeDefaultRoute), &doChangeDefaultRoute);
this code works on 3.1.2, earlier sdk's you have to do differently.
UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_Speaker;
status = AudioSessionSetProperty (kAudioSessionProperty_OverrideAudioRoute, sizeof (audioRouteOverride), &audioRouteOverride);
you have to be careful with this method, it will override even if you have headphones plugged in, you have to monitor interruptions and change the routes accordingly. much better now using 3.1.2
I am experiencing the same problem but cannot get this way to cure the problem?
I have tried this but no matter what I get a compile error stating the k constant is not declared in scope? I have AudioServices.h imported!
[code]
[audioSession setCategory: AVAudioSessionCategoryPlayAndRecord error: &audioSessionError];
...
...
UInt32 doChangeDefaultRoute = 1;
AudioSessionSetProperty (kAudioSessionProperty_OverrideCategoryDefaultToSpeaker, sizeof (doChangeDefaultRoute), &doChangeDefaultRoute);
[/code]
and this:
[code] UInt32 allowMixing = true; AudioSessionSetProperty (kAudioSessionProperty_OverrideAudioRoute, sizeof (allowMixing), &allowMixing); [/code]
If I start out with playback only the recording and playback works once and once only.
No matter what I try I either get quiet sound or once decent record with perfect playback.
Have been trying for ages if anyone can help? please?