Android using top microphone for recording [duplicate] - android

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

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 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

Is there any way to select specific speaker for android device?

We are developing a VOIP application, there is one component which need to record the audio from mic, and play the remote audio to speaker. And we need to do some audio/signal processing for the recorded audio.
But on some android device, the selected mic and speaker is so near, the audio captured from MIC clipping (too loud) because of the audio played by speaker. This cause the captured audio waveform have nonlinear losses, and make the audio/signal processing component doesn't work.
We doesn't want to set AUDIO_STREAM_VOICE_CALL to enable build-in AEC, because it will make the recorded audio sample rate to be 8k while I'd like the recorded audio to be 48k.
So We have consider following solution:
Decrease the mic volume. Base on this SO question and this discussion thread, it seams impossible.
Using specific speaker and mic to make the distance a little bit far, so the mic captured audio volume is low.
So any way to select specific speaker on android platform?
If the distance between microphone and the speaker is crucial here maybe is would be enough to use camera's mic:
MediaRecorder.AudioSource.CAMCORDER

Change Android Audio Record Default input Source

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.

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