Android Independent Volume Control - android

As of now, the volume can be set per Stream type. I am just wondering if there is a way to control the volume per application. For example, for this specific game application I can set to to volume level 10 without changing the volume for other application which has the same stream type.
Any feedback will be greatly appreciated.
Thanks,
artsylar

This is not supported by the OS.
You are welcome to try to fake it by remembering the current volume level, changing it, then restoring the original volume level. However, it will be impossible to cover all the cases where the volume level needs to be reset (e.g., your app crashes).

Related

Service lowers volume even when volumes are on max

In my app I have an additional library for SIP calling, which on some phones (Huawei 5.1) locks volume to around 50% (or even less) for some reason and it keeps it like that for the whole phone volume meanwhile service is running.
I tried setting:
am.SetStreamVolume(Android.Media.Stream.Music,am.GetStreamMaxVolume(Android.Media.Stream.Music), 0);
And playing beeping noise with MediaPlayer/Soundpool.
I also tried setting Microfone to
Mode.Ringtone / Mode.Normal,...
but the volume is still low when this library/service is running.
Is there any other setting option possible that could override some setting in the library, because if I look current volumes, it's all on MAX (Media/Notification/Ringtone/...)?
In this library, you have to initialize sampleRate / buff size, which I do with getting default values from Android
String rate = audioManager.getProperty(AudioManager.PROPERTY_OUTPUT_SAMPLE_RATE);
String size = audioManager.getProperty(AudioManager.PROPERTY_OUTPUT_FRAMES_PER_BUFFER);
Some companies add a volume limit to protect user. I met similar issue before on samsung note 4. I am not sure whether APP has the permission to break this limit(mostly not allow).
In order to find the relative setting, please try this: Play music by the default music player, and press volume+. Keep volume up and then your phone may toast a dialog to tip you. And you can change this setting.
Hope it works :)

Android microphone sensitivity change after phone call

My application is measuring volume of captured audio as a function of samples absolute amplitude.
I've noticed and unexpected behavior in android.media.AudioRecord of Android SDK. Let's assume following flow:
Application is launched
Audio volume is being measured
Phone call is answered/dialed
Audio volume is being measured
The noise around the microphone is produced by TV with constant volume setting. Values measured for point 2 are in range [55-65] and values measured for point 4 are in range [15-25] (please see the audio visualization for 2. and 4. below).
I understand that there must be some volume adjustment going on when phone call occurs. Is it possible to monitor those adjustments or to get rid of them?
I've tried AutomaticGainControl but it is not supported on my Nexus 5 and I do not want to use it since the target devices might not support it as well.
Update
This volume adjustment is happening not only after phone call. I've just noticed the same behavior when phone was just lying on the table measuring volume.
In regard to resources that your app is sharing with other apps (the microphone in this matter) - you should always treat them carefully and assume there configuration may change during a phone call or other usage like switching to another app that's using the microphone.
Instead of trying to monitor for changes in gain , which may require root or other elevated privileges - I would take another approach and do the following:
Save the mic sensitivity level to a configuration file (shared_prefs) in your recording activity when the user is recording . do the same if the user changes it of course during usage of your app.
In the onResume proc of your recording activity - load the mic sensitivity level value and set it before continuing to record (How to adjust microphone sensitivity while recording audio in android - Solved)
If there is a phone call that throws your app to the background and takes control of the mic, once it's finished - your app will return to the foreground and retain the mic sensitivity level for further recording.
Hope this helps.

Adjusting the mic sensitivity while recording audio in android

I am developing an android application which records audio in PCM using the AudioRecord API. I want to adjust the mic sensitivity to low, medium and high as the user chooses it in the settings.
Is it possible to adjust the mic sensitivity? Your answers will be highly appreciated :)
Not really. It's usually possible to get at least two different "sensitivities" (acoustic tunings used by the platform) implicitly by using different AudioSources.There should at least be one tuning for handset recording and one for far-field recording. On some devices you might also have different far-field tunings, e.g. one for recording audio a few decimeters away and one for recording audio a few meters away.
The problem is that you can't really know which AudioSource corresponds to which tuning, as there's no standard for it. CAMCORDER typically means far-field, and VOICE_RECOGNITION often means handset mode, but there's no guarantee for it. You should also keep in mind that vendors typically apply automatic gain control, noise reduction, etc that you as a user / app developer can't disable, in order to meet acoustic requirements for their products.
Your best bet would probably be to use a single AudioSource and then do attenuation of the signal in your app to simulate a lower mic sensitivity. You could do amplification as well, but that would be akin to using digital zoom in the camera app (it works, but doesn't look all that good because you're just scaling the existing data).

How to increase the maximum audio output power

Once I did dig into Android programing and find the interface AudioTrack.setStereoVolume(lv,rv) to set the output audio power. But the problem is that it just adjusts the volume within the range that the cellphone vendor specifies in its system.
How can I change that range within the Android system with NDK or something else? I want to make my phone able to output more power to help people with weak hearing to catch music or ringtone.
I think it's only possible to increase the volume of your device out of the range specified by the vendor and have good sound, when you have root access on the device. But you have to be careful with increasing the volume out of the range specified by the vendor, so that you don't damage the speaker. Or doing this can also decrease the lifetime of your speakers and your device. So, I think it's not a very good idea to do this.
But, I've found an how-to how you can increase the volume out of the specified range (not tested by my own) if you have root access on your device:
http://androidadvices.com/increase-volume-android-mobile-phones/
Good luck!
Kr

Android fine volume control

I want to fine tune the volume of the current media file playing.
So there are two applications here, the mediaplayer application, that could be the default Music application, and my application, where I want to tune the volume.
What I do now is to use setStreamVolume, but the index only goes from the max volume to 0, and that's 15 levels only (at least in the emulator).
What I want is to fine tune it in for example, 100 or 200 levels.
Is that possible?
Thanks!
I just searched around for a bit and it seems like this isn't possible using the android API.
I think Fine Volume Control is what you want. It provides 100 levels of adjustment. You can get it in market

Categories

Resources