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

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

Related

Android use internal mic and bluetooth headset as speaker with high quality media protocol during calls

I have bluetooth earbuds with great sound quality and built-in microphones. In my android bluetooth device settings, I have to switches for media profiles: 'Call audio' and 'media audio'
Behavier with both activated:
when mic not needed: high quality sound protocol (1-directional, phone to headset)
when mic needed: switches to low quality sound protocol (2-directional, headset mic also streamed to phone)
Problem: I want better audio quality during calls, because I often am on long calls (mostly on discord) and I want to listen to music in the background with great quality.
Therefore I want to use the 1-directional great protocol and the internal built-in microphone
I did some testing using the audio recorder at first:
turned off 'Call audio' switch in bluetooth settings
earbuds not recognized as possible microphone
recording startet, music on earbuds paused, internal mic was being recorded, I could listen to music in great quality (had to hit play again) on my earbuds with great quality simultaneously -> perfect
So I thought I discoverd the solution, BUT:
On Discord (or any other call app) the earbuds did not show up as a possible speaker.
When listing to music on the earbuds and then joining a call, the audio output immediatly switched to the speaker/earpiece speaker (call audio and music). Probably because the call profile was disabled.
Does anyone have a solution/workaround?
sure, wired headphones would work
Maybe there is a way to redirect my call output from discord to a media stream and then into my earbuds (Then the voice quality on discord would not improve, but I could listen to music in high quality). I found an app (BTmono) doing basically the oppsite for headsets with a call profile only: It converts your media output into a mono stream and outputs it as call audio
maybe, I can somehow mark my earbud's media profile as a call profile too
or maybe anyone got some other workaround that did not come to my mind yet.
I would really appreciate a proper solution to my problem, thanks

Recording audio with a mic on Android

I am developing an Android application which is supposed to capture audio with the built-in mic of the smartphone and save it.
For the further processing purposes I would like to have some control over the quality of audio captured. For instance, to my knowledge some smartphones have high-quality audio recording mode and I would like to make use of it, if that is possible.
I am aware of mediaRecorder, but I am not sure how to use its methods or input arguments to get the best quality of sound possible. I would be very grateful if somebody could point out that for me or provide references to other libraries that allow to adjust the quality of recorded sound.

Android: Determine number of speakers used for AudioManager.STREAM_MUSIC

I have attempted to find any info regarding the detection of the number of speakers available. When the AudioTrack streaming mode is set to music (allowing the phone's loud speakers to be used) I would like to detect if the sound will be coming from multiple speakers or only one.

Audio Track for playback in android

Audio track allows streaming PCM audio buffers to the audio hardware for playback. This is achieved by "pushing" the data to the Audio Track object using one of the write(byte[], int, int) and write(short[], int, int) methods.
PCM is Pulse code modulation is it that PCM that modulate analog voice to digital during Phone calls?and which list of hardware to playback? only speaker or some more? Can PCM allow to play audio on GSM network?
PCM is Pulse code modulation is it that PCM that modulate analog voice to digital during Phone calls?
I'm not entirely sure what you're asking, but typically there will be a piece of hardware in the phone called a codec. The codec controls the internal loudspeaker, earpiece, microphones, etc - and this is where the analogue audio singals will be sampled into digital audio streams (typically 48 kHz linear PCM).
What happens to the audio after that varies a bit between different platforms. It might for example be passed to an audio DSP (Digital Signal Processor) which applies various filters (e.g. noise suppression); and from there to the modem which takes care of compressing the audio (typically using AMR) and transmitting it to the network.
and which list of hardware to playback? only speaker or some more??
Any device that the phone can route audio to. A phone will typically have an earpiece, one or more loudspeakers, a 3.5mm stereo jack, and a Bluetooth chip capable of both voice (SCO) and media (A2DP) audio. Some phones also support audio playback over USB and WiFi. Applications don't have direct control of the routing, though. The best you can do is give a hint to the OS about where you'd like the audio to be routed.
Can PCM allow to play audio on GSM network??
No. This has nothing to do with the encoding of the audio. There simply isn't any API in Android for injecting audio into the uplink of a voice call.

(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