Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to increase Microphone volume level in Android PJSIP?

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.

like image 385
Nandhakumar Kittusamy Avatar asked May 09 '17 04:05

Nandhakumar Kittusamy


2 Answers

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.

like image 166
Preview Avatar answered Sep 24 '22 14:09

Preview


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.

like image 38
jafarbtech Avatar answered Sep 25 '22 14:09

jafarbtech