Change Android Audio Record Default input Source - android

I am currently writing an app that calls for the recording and real time processing of audio data. For this, I am using the AudioRecord class. This works all well and good, except the default setting for recording audio on my primary testing device, a galaxy nexus, is to record from the back speaker. I am assuming most phones default record source will be the back, or bottom microphones, because when you are using the phone to call, your mouth is near the bottom.
However, my app requires that I record from the speaker on the front of the phone, and so I was hoping someone could help me with how to change the AudioRecord input source programmatically. I have searched extensively for the answer to this.
Some things I have considered are:
Using the AudioManager Class and turning on the speaker phone, such as:
AudioManager am = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
am.setSpeakerphoneOn(true);
Changing the AudioSource parameter in the construction of my AudioRecord object:
AudioRecord ar = new AudioRecord(AudioSource.????, ..., ..., ..., ...);
I have found that the API's are not too specific about which AudioSource formats are which, so I was wondering if anyone else has struggled with this issue and could point me in the right direction.
Thanks in advance,

Android does not currently support call recording, so I believe you can't change it to record from the earpiece. You shouldn't really need to however, the Mic at the bottom of the phone should be able to record things to the full capacity you need. To set the AudioRecord to the mic, just do:
AudioRecord ar = new AudioRecord(AudioSource.MIC, ..., ..., ..., ...);
This will give you the best recording quality.

Related

Android audio record external jack

I would like to record the sound of the jack entry of my android phone. I've been searching about the Audio Capture class in Android, and i've found this:
https://developer.android.com/guide/topics/media/audio-capture.html
In the settings of this class, there are many options to choose the rec default mic, as this:
Set the audio source using MediaRecorder.setAudioSource(). You will probably want to use MediaRecorder.AudioSource.MIC.
What should I use to get the sound of the jack entry? Is there any example?
Thank you!
The API you provided is the correct one.
Calling mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC) (assuming the correct initialization of MediaRecorder as described here https://developer.android.com/guide/topics/media/camera.html -> Capturing Videos) will behave like this:
When you launch your app and start recording without any Jacks connected, phone's default microphones will be used. As soon as Jack microphone pin has detected a microphone connected, the system will use the Jack mic pin as an audio imput. Hovewer, you need to know that even though the audio record will have two channels, they will be identical, as Jack microphone can only record mono stream.

Android using top microphone for recording [duplicate]

How to select top microphone as audio source for recording audio in android.
Now I am using MediaRecorder.AudioSource.CAMCORDER as audio source but its not taking top mic for recording.
The developer documentation lists the supported audio sources. I am unsure what you mean with "top microphone" however I think you should use MediaRecorder.AudioSource.MIC.
In my case I used audioSource = MediaRecorder.AudioSource.MIC and channelConfig=AudioFormat.CHANNEL_IN_STEREO. Then choosing the RIGHT channel input which receive sound from TOP MIC on HUAWEI Mate10/Mate9.
Anyway this method is relate to the hardware, your code only works on specific model

Android selecting top microphone

How to select top microphone as audio source for recording audio in android.
Now I am using MediaRecorder.AudioSource.CAMCORDER as audio source but its not taking top mic for recording.
The developer documentation lists the supported audio sources. I am unsure what you mean with "top microphone" however I think you should use MediaRecorder.AudioSource.MIC.
In my case I used audioSource = MediaRecorder.AudioSource.MIC and channelConfig=AudioFormat.CHANNEL_IN_STEREO. Then choosing the RIGHT channel input which receive sound from TOP MIC on HUAWEI Mate10/Mate9.
Anyway this method is relate to the hardware, your code only works on specific model

Android AudioRecord Headphones with MIC

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

Android - Manually write()ing to AudioTrack, no appropriate MediaRecorder.AudioSource

I see that MediaRecorder allows you to record from the Microphone, or a phone call.
I'm using write() on an AudioTrack to produce sounds out of basic frequencies. Multiple AudioTracks actually.
I would have thought that there would be a MediaRecorder.AudioSource setting that captured whatever sounds the system was sending to the speakers.
I tried DEFAULT but it didn't work.
Unfortunately there is no loop back audio source for recording sounds generated by the device, just from external audio sources.

Categories

Resources