Android: Determine number of speakers used for AudioManager.STREAM_MUSIC - android

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.

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

How many types of speakers had android device?

My question is - I need to know how many types of speaker has android phone? I mean for example regular device has one speaker and one microphone. But about speaker for example when user speak by phone hold the device near a ear, so speaker in a low volume, but also user can tap on Speaker mode and now you can hear also sound from speaker but loud. And also there one more option if user playback a music you can also hear it loud but with better quality.
Question is - is this speaker in low volume, speaker in loud volume and speaker that playback music is this one the same speaker or is it different speakers? Or maybe it is the same speaker but playback goes in different mode? Or different types?
I don't think there's a standard way to check the speaker configuration on Android. You would need to check the manufacturer specification of the handset.
The difference in quality between the voice and the music likely is due to the compression the voice undergoes in order to be transmitted in real time. The music can stream or buffer and thus can have higher fidelitiy.
It is unlikely that the difference is due specifically to the speaker configuration.

How to detect use the STREAM_VOICE_CALL or the audio speaker in android?

Take audio play in whatsapp as example, if your ear near the phone, the speaker will change to the earphone speaker, while the ear leave the phone, it use the audio speaker.
I am using the mediaplayer to play the audio file, and found that there is
setAudioStreamType(AudioManager.STREAM_VOICE_CALL);
to switch the speaker to the ear speaker. and
setAudioStreamType(AudioManager.STREAM_MUSIC)
for default audio speaker.
The problem is , how to detect when the ear is near the phone, or is it necessary to implement by my program (should have some default android API for that ? )
Thanks a lot for helping
Most (or may be all?) android devices have proximity sensor. I think it is what you need.
Check this question and Android documentation on Sensor for more details.

Hardware limitations with iPhone Microphone

I'm using EZAudio FFT to analyze audio as the iPhone "hears" it. I am listening for high-pitched sounds embedded into music (17 kHz+). When the iPhone hears the sounds with no music, it records the data perfectly and hears the pitch fine. However, when music is playing the sounds are no longer heard--or only 1 in about 8 are heard. Again, I am using EZAudio, to analyze the sound. I have an Android phone that has a similar app on it (displays an graph of Hz for incoming audio waves), but the Android phone can hear these sounds.
Why would the Android phone hear these high-pitched sounds but not the iPhone? Is it because of a flaw in EZAudio or is it due to a higher quality microphone?
The answer is most likely answer is Automatic Gain Control (AGC). This is enabled by default on the microphone, and is useful for telephony or voice recording.
At 17kHz, you're probably already at a frequency at which the microphone is not particularly sensitive, however, in the absence of audio at other frequencies, the AGC will have increase the gain of the microphone. As soon as other frequencies are present, the gain reduces again, and the 17kHz signal is in the noise.
Looking at the EZAudioFFT source code, it doesn't appear to be setting up the AVAUdioSession to use measurement-mode (which disables AGC, and the HPF on the microphone).
You can achieve this with:
NSError *pError = nil;
[[AVAudioSession sharedInstance] setMode:AVAudioSessionModeMeasurement];

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

Categories

Resources