Android AudioRecord Headphones with MIC - android

I am having some issues with the AudioRecord class. I have an app that records audio while someone is listening to audio through headphones. In this scenario, it works fine. Users are able to record without an issue. Any user using headphones with a built-in mic are not able to record at all. My class creates the .wav file from PCM data but no audio is being input from the mic. Its all silence.
I use the following the init my AudioRecorder:
extAudioRecorder = new ExtAudioRecorder(true,
AudioSource.MIC,
44100,
AudioFormat.CHANNEL_IN_MONO,
AudioFormat.ENCODING_PCM_16BIT);
Is there a problem trying to record using headphones w/ a mic in Android?
EDIT:
Just found out that the headphones dont even have to have a MIC and the internal mic is still disabled. Anyone know how to get around this?
http://code.google.com/p/android/issues/detail?id=4095

Found out that some phones disable the built-in microphone when headphones are plugged in. Mostly Samsung devices.

to force the use of builtin mic (at least on samsung devices), you can use MediaRecorder.AudioSource.CAMCORDER as source

Related

Disable an input from the microphone while recording audio on Android

I'm working with AudioRecord, when I plug the earphones in my device, it will record both the input sound from the microphone in earphones and the input sound from the mic in device.
How can I disable the input sound from the microphone programmatically?
Scratch previous answer, FOUND THE SOLUTION!
https://stackoverflow.com/a/21735706/5439782
Step 3 is CRUCIAL! Instead of calling default profile on all settings, call it before and store it in Profile. THEN set all the settings you need WITHOUT audio encoder and audio source. Worked for me on unrooted device :)

forcing mic input in Android

I have a weird setup where I am trying to record audio from an external device using a TRRS male-male audio cable. The way it is supposed to work, I plug in the audio cable to the device, then to the phone then use AudioRecorder to record in audio. On my HTC One M8 everything works great and I can record audio from the device. On my Samsung Galaxy S2 it records audio but from the internal mic.
I confirmed the issue is with the impedance of the mic input. If I add a resistor to the audio cable to increase the mic impedance then the S2 will record from the device correctly.
So my question is: Is there anyway to force Android to use the external mic jack? I looked into sending the ACTION_HEADSET_PLUG intent with the microphone set to -1 for external, but fail due to permission errors. It seems this intent was moved into protected permissions (https://github.com/android/platform_frameworks_base/commit/8f014059d3084fcce9e82b4b1f8b8323744ac52d)
So is there any other way to force the phone to use the mic jack without external hardware?!
Thanks!
Also, for the actual audio recording, settings are:
44100kHz sample rate
16 bit samples
Mono channel
Buffer is set to AudioRecord.MinBufferSize()

Stereo recording using 2 external mic?

I am new to android development. I am trying to record an audio file in stereo mode. I have connected two external mics using 3.5mm jack.
The only problem is that my recording is done in mono mode. Both speakers sounds same. I am using inbuilt recorder app in my phone. Is stereo recording possible in smartphones using external mic? If so, do I need to code for stereo recording? And what libraries should I use?
Speak two different words, one to each microphone and try to figure out if both speakers are getting a "blend" of both sides or if you're only getting one of the mics, then post the results to get a more accurate answer.
Take a look at this question where the topic is discussed, maybe it has to do with the configuration in your source code.

Android audio recording using phone microphone when handsfree is attached

When I connect bluetooth handsfree to Android phone device, is it possible to use phone microphone to record sound and hear it in the handsfree?
I manage to record sound by phone microphone and hear it on the phone speaker or headphones. But when the headphones has microphone, typically handsfree, it records sound using handsfree microphone by default. I need to mute somehow handsfree microphone and use phone microphone. Is it possible in Android?
I haven't found any answer. At android developers, Stackoverflow, nowhere. Thanks in advance!
you can try to use the MediaRecorder.AudioSource.CAMCORDER to record the audio.
according to the api-doc it is
Microphone audio source with same orientation as camera if available, the main device microphone otherwise

(Android) Get audio signal from the audio line-in instead of phone microphone

I'm working on an Android program whose purpose is to record a sound signal and then to analyse it.
To record this sound signal, I am using a special microphone I want to plug to my Android device directly via the audio line-in, so I won't use the mobile phone microphone.
Here is what I found on Android website :
" Defines the audio source. These constants are used with setAudioSource(int).
Summary
Constants
int CAMCORDER Microphone audio source with same orientation as camera if available, the main device microphone otherwise
int DEFAULT Default audio source
int MIC Microphone audio source
int VOICE_CALL Voice call uplink + downlink audio source
int VOICE_COMMUNICATION Microphone audio source tuned for voice communications such as VoIP.
int VOICE_DOWNLINK Voice call downlink (Rx) audio source
int VOICE_RECOGNITION Microphone audio source tuned for voice recognition if available, behaves like DEFAULT otherwise.
int VOICE_UPLINK Voice call uplink (Tx) audio source "
It seems that there is no way to define the line in as an audio source. I have tried to plug my own microphone to my mobile and then to record the sound, hoping that it will recognize my own microphone (as a handfree kit) but it keeps recording on the mobile phone microphone.
Does anyone know what to set as an audio source so I can use the line-in ?
Many thanks in advance !
You made some assumptions which might not be correct. Regular android phones have no Line Ins.They are not designed to be professional audio systems.
When you plug your headset, android automatically recognises your external MIC and you dont need to set it in your code.Just leave it in DEFAULT.
The problem is, you will need an special and compatible connector for your MIC. As you might notice the headset connector for your mobile is different from an streo Jack.So you will need an adapter or solder your own compatible Jack.If you connect your MIC with two parts, android will assume that its a headphone and not a MIC!
Here is the link to article: How do I use an external microphone with my Galaxy Nexus?

Categories

Resources