Input sound built in mic lower when headphones are plugged
I have an app that record by the built in mic of the iPhone even if headphones are plugged with TAAE. To do that I used :
let session = AVAudioSession.sharedInstance()
session.setPreferredInput(session.availableInputs[0] as! AVAudioSessionPortDescription, error: nil)
The problem is that when headphones are plugged, the voice of the user is recorded by the built in mic but at a lower level that if no headphones are plugged. We almost don't here his voice.
I tried to print the gain of the input with and without headphones but in both case it is at 1.0, the maximum.
Any idea from where it can come ?
Comments
some more code please....
Ran into the same problem. My problem when I plugged in headphones, it was using headphone mic. Using "session.availableInputs[0]" does not guarantee that you'll use same mic with headphones in or out.
This will force to bottom device mic
Also, it is worthwhile setting up route change notification to handles this too. In your viewController:
Other things, from my testing inputGain will always be 1.0 if session category is not Record or PlayAndRecord. Different microphones will have different default inputGain values. I did not test trying to adjust the gain, so I can't provide any info with that.
Mmm, my mistake. My code above shows how to make sure the bottom mic is used when headphones plugged in, but it does not balance the recorded volume between plugged in and not plugged in.
So, an answer is still needed.
Are you using Measurement Mode? This is usually the culprit when it comes to weird input levels.
That was it. Thanks Michael!!
No problem
Ah, Measurement Mode. If you don't use it, you lose all the bass response. If you use it, you get input level weirdness. Damned if you do, damned if you don't. We love you, iOS audio.
(PS. I think I'll be adding an AENormalizeModule/AEAutoGainModule or similar to TAAE2 to address these shenanigans at some stage)
@Michael What audio enhancements does Measurement Mode do? Need to improve sound quality of my recorded tracks. Recordings sound flat (for lack of better description).
Exactly that - for some bizarre reason, the default mode strips out almost all bass response. Turning on Measurement Mode bypasses that highpass filter so you get a decent response, but it also turns off all the auto gain control stuff. Sigh.
Thanks @Michael. I guess I should've stated that I am new to the audio world, so I don't know a lot about what all the filters do and how they work. Got any good references that give a good background on the basics of audio recording/processing?
No idea, I'm afraid!
Hey @Michael! Any thoughts on when you might be adding AENormalizeModule/AEAutoGainModule? My biz partner is eager to improve our recording quality.
Not entirely sure @scott4arrows, but if you'd like to help/get started, pop an AEDynamicsProcessorModule in your signal chain after your mic input module and play with the parameters; this is my Plan A for the auto gain module (basically a subclass of AEDynamicsProcessor with the appropriate defaults). Not 100% sure yet whether it'll be suitable for the purpose, but that's my first port of call.
Thanks @Michael. I'll give that a go.