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.
Related
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
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
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.
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?
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.