How to increase Microphone volume level in Android PJSIP?
Asked Answered
C

2

10

I have Integrated PJSIP with android. While making call in my application, the Speaker is working perfectly but Recording microphone volume is too low. My voice is not hearable by other side.

Note: But in some mobiles it's working properly.

Even i tried with adjustStreamVolume(), setStreamVolume(), setMode(),adjustVolume() methods to increase my volume level, it doesn't increase in anyway. Please give me a suggestion to solve this problem to increasing microphone Volume level in Android or from PJSIP.

Thanks in Advance.

Convenient answered 9/5, 2017 at 4:52 Comment(2)
When you say ~"in some mobiles it's working properly", what devices did you mean?Mute
In moto e3 power, redmi 3s prime mobiles the microphone volume is in acceptable level.But in lenovo k5 plus microphone volume is very low. I don't know how to increase volume for microphone.Convenient
R
5

Problem is Microphone volume level is too low when our application access through microphone. When you got low volume, you need to check multiple things.

One of them is MODE OF THE AUDIO MANAGER when microphone is used.

Getting MODE of the Android Audio manager::

AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
long mode = am.getMode();   
Log.e(TAG,"audio mode "+mode);

Setting MODE of the Android Audio manager::

AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
am.setMode(3);

You can access the mode of audio manager through this above code for your app. There are
1.MODE_NORMAL
2.MODE_RINGTONE
3.MODE_IN_CALL
4.MODE_IN_COMMUNICATION

P.S. : Whenever you change the mode of the AudioManager, please change into MODE_NORMAL after using microphone otherwise it won't work once you restart the mobile.

Reviewer answered 19/5, 2017 at 10:59 Comment(1)
Thanks,am.setMode() is worked perfect for me.My issue:when I's set audiomanager.setSpeakerphoneOn(ture),the speaker's voice is too low even though I had set all volumes to max value and finnally I fixed the issue after use am.setMode(MODE_IN_COMMUNICATION).Armadillo
C
4

It looks like to me setStreamVolume and the like are more used for speakers rather than to control the microphone.

From the PJSIP docs, you can see there is a method called that could adjust the signal level received.

You can use it like the following, where volume is between 0 and 2.0.

pjsua_conf_adjust_rx_level(0, volume);

I saw in a few places that you might need root access to modify this parameter anyway, or that you need to have a MediaTek chip.

What you can do instead is increase the gain from your stream directly. This answer shows you how you could do it, where the gain is also in the same range.

Coryphaeus answered 17/5, 2017 at 15:15 Comment(9)
Would this leverage the PJMEDIA_AUD_DEV_ROUTE_LOUDSPEAKER constant from audiodev.h?Mute
@Mute by looking at the pjmedia_conf_adjust_rx_level that gets called and this line, I don't think that's the case.Coryphaeus
@Mute PJMEDIA_AUD_DEV_ROUTE_LOUDSPEAKER is just for speaker only know, but i want for increasing microphone volume.Convenient
@Apercu thanks for your solution.But If thats the problem means, why its working on some mobiles perfectly. And I already checked this method and it remains same low volume. I think its device specific, not in pjsip and need to increase the mic volume for my dialer app in android app level. Any other ideas to increase mic volume level particularly in android ?Convenient
@NandhaKumar did you tried to increase the gain of your stream instead as showed in the answer I linked?Coryphaeus
@Apercu I tried this method pjsua_conf_adjust_rx_level(0, 2.0) and it doesnt increase volume level of microphone.Convenient
I'm talking about this answer, where you basically manually modify your data stream to increase the gain. Modifying the microphone level requires won't work in some devices, you have to take another route.Coryphaeus
Let us continue this discussion in chat.Convenient
when using recording through microphone, it shows E/AudioPolicyManager: unknown stream type 13 error in logcat window.Convenient

© 2022 - 2024 — McMap. All rights reserved.