Android Volume Controls Broken By Photon Voice
The whole answer can be found below.
Try Our
Documentation
Please check if you can find an answer in our extensive documentation on Voice.
Join Us
on Discord
Meet and talk to our staff and the entire Photon-Community via Discord.
Read More on
Stack Overflow
Find more information on Stack Overflow (for Circle members only).
Android Volume Controls Broken By Photon Voice
Mandelboxed
2020-10-08 22:52:36
Hi,
I am developing for Oculus Quest and have just updated to Photon Voice 2. If I use a voice recorder with the Photon microphone type, the hardware volume controls do not work.
I can use the Unity microphone type, but I thought this should be reported.
Comments
Hi @Mandelboxed,
Thank you for choosing Photon and for your report!
What Photon Voice version is this?
When you use Photon microphone type for Android, what options do you enable from the Recorder?
You can set those in Recorder Inspector or via Recorder.SetAndroidNativeMicrophoneSettings.
The ones available (and disabled/off/false by default) are: Acoustic Echo Cancellation, Automatic Gain Control and Noise Suppression.
CheeseBrownie
2020-10-27 01:16:02
I'm getting the same problem. On Photon mic type it just doesn't work no matter how many times I try.
If I switch to Unity, it doesn't work on the first run. But if I close the app and try again it works. Might be because the first run I have to accept the mic permissions.
I'm running into the same problems. Buttons not responding at all when mic is in 'Photon' mode. When in 'Unity' mode, the buttons only work the second time the app is launched (and microphone permission is granted).
I'd love to download the previous version of Photon Voice 2 to see if this fixes the problem, but there doesn't seem to be a download archive available.
Hi @michiel,
Thank you for choosing Photon!
@ everyone:
This could be by design when using Photon microphone type, as it's a compromise (to be able to achieve audio effects AGC, AEC, etc., the app needs to have control over system volume?) in native Android plugin when using certain Android API values/calls.
my colleague @vadim will take a look when possible and see if we can avoid this.
Thank you for your patience and understanding!
CheeseBrownie
2020-11-23 21:54:11
@JohnTube any update on this issue? I thought I fixed this by having the permissions show up before you connect to photon, but now I have another problem. The volume cannot be adjusted any time the game is launched if I DO NOT accept the mic permissions.
CheeseBrownie
2020-11-25 20:07:55
@CheeseBrownie wrote: »
@JohnTube any update on this issue? I thought I fixed this by having the permissions show up before you connect to photon, but now I have another problem. The volume cannot be adjusted any time the game is launched if I DO NOT accept the mic permissions.
Seems like I was able to do a band-aid fix by disabling the gameobject with my Photon Speaker component. I'm able to adjust volume with mic permissions off but I'm not able to hear other people talk anymore.
Hi all,
I'm forwarding my colleague @vadim's input here:
There are several volume sliders (4) on Android.
- Media volume: Music, videos, games, other media
- Call volume: Volume of the other person during a call
- Ring volume: Phone calls, notifications
- Alarm volume
Depending on audio session mode, the system chooses automatically which slider to assign to hardware buttons. Read more here.
Photon mic type switches device to voice call mode to be able to use hardware AEC.
I suspect that in this case volume buttons adjust Call volume.
This volume does not affect Unity output which is most likely controlled by Media volume.
You could try to switch to the Media volume slider when changing volume.
You could also use Unity microphone type with WebRtcAudioDsp, it has AEC, NoiseSuppression, AGC and even a better VAD.
I created an Android library (aar) and added it to the Unity project. It cycles through all available volume control streams, but the ability to change the volume using the headset buttons never works. So it doesn't appear to be an issue with that..
Java code:
public class AndroidAudioStreamFix {
private static final String LOGTAG = "AndroidAudioStreamFix";
private Activity activity;
public AndroidAudioStreamFix(Activity activity) {
this.activity = activity;
}
private static int i = -1;
public void FixAudioStream() {
int streamType = i;
Log.i(LOGTAG, "Setting stream type: " + streamType);
activity.setVolumeControlStream(streamType);
i++;
if (i > 10) {
i = -1;
}
}
}
Unity code:
public class AndroidAudioStreamFix : MonoBehaviour
{
#if UNITY_ANDROID
private IEnumerator Start()
{
DontDestroyOnLoad(gameObject);
while (true)
{
FixAudioStream();
yield return new WaitForSeconds(3);
}
}
private const string JAVA_CLASS = "AndroidAudioStreamFix";
private const string UNITY_PLAYER_CLASS = "com.unity3d.player.UnityPlayer";
public static void FixAudioStream()
{
using (var javaUnityPlayer = new AndroidJavaClass(UNITY_PLAYER_CLASS))
{
using (var currentActivity = javaUnityPlayer.GetStatic<AndroidJavaObject>("currentActivity"))
{
using (var utils = new AndroidJavaObject(JAVA_CLASS, currentActivity))
{
utils.Call("FixAudioStream");
}
}
}
}
#endif
}
Hi @michiel,
Thanks for your report and your efforts to try to work around this.
My colleague @vadim will take a look and chime in.
vanhalen17
2021-02-05 19:49:16
Can confirm this still is an issue in latest version of PhotonVoice, on Oculus Quest (which only has one hardware option for volume control) Using microphone type 'Photon'
vanhalen17
2021-02-05 20:59:46
@michiel script also did not work for me
hey
we have added this to the documentation here.
but @vadim just made an Android plugin that makes media volume follow call volume when using Photon microphone type and Recorder 'is recording'. So when you use Photon mic and change volume via hardware buttons all output volume should be updated accordingly (media + call).
I hope this is the behaviour you were looking for.
Although it's not the Android's normal behaviour.
Anyway, we were hoping you could test this on your end on Oculus and see if it works and if you are happy with it.
if it's the case we could improve it a bit more to work only when needed (when Recorder is recording and when Photon mic is used)
grab files here: just add AndroidVolumeSync component next to Recorder and build again.
there is a demo video to show behaviour.
you need Unity 2018.2+
I'm using this fix for a Oculus Quest build with Voice 2, it seems to be working but every time you press the volume up/down button, the meter on the on screen display goes up or down by 3 instead of 1. This only happens with new app install, after you quit the app and play again everything's fine.
And I will add that if you try to connect the headphones (via Bluetooth or the standard one) they will not work. And it's the issue.
Hello, since latest oculus firmware update V31, whenever you press the volume buttons both AudioManager.STREAM_MUSIC and AudioManager.STREAM_VOICE_CALL change volume at the same time. This makes the trick of 'making media volume follow call volume' not working anymore.
Additionally it seems that volume buttons only command the STREAM_MUSIC, and something internally oculus side tries to replicate the change onto other streams (my logs inside the observer declared in AndroidVolumeSync).
Unfortunately, now, it seems that the call volume does not go down for real anymore.
@JohnTube @vadim could you please update your oculus quest and check how is the situation now? It would be much appreciated.
Thanks
Hi @max_one,
Thank you for choosing Photon and for reporting this.
We will take a look but I can't promise anything and this may take a while.
So we rely on your patience and understanding.
Meanwhile you could try to adjust @vadim's script if possible or find an alternative solution.
And I think, just to confirm, you can still use Unity microphone type right?
With WebRtcAudioDsp next to Recorder, you're good to go?
So this is not a blocker.