iOS audio gets quiet when connecting to a channel in Vivox 16

We are making a Unity game with Vivox 16. On our iOS build, as soon as we connect to a Vivox voice channel, all game audio becomes very muffled.

Our ultimate goal for this iOS version is to have all audio (including voice chat) come from in-game sources, so that if you were to take a screen recording, you would also hear the voice chat as though it was coming from in-game. We have accomplished this using an AudioTap, and the recordings themselves sound fine, so the only issue happens when actively using the game.

I’ve seen a few other posts on the issue, but none have an actual fix. I believe it is because of this: https://support.unity.com/hc/en-us/articles/4418772243476-Vivox-Why-does-audio-volume-shift-on-iOS-when-using-Vivox-

Since we are working in Unity (2021.3.19f1), I don’t know if it’s possible for us to even alter the AVAudioSession. We also tried using the “SkipPrepareForVivox” flag, but it had no effect (unless we used it incorrectly):

VivoxConfigurationOptions config = new VivoxConfigurationOptions();
config.SkipPrepareForVivox = true;

InitializationOptions options = new InitializationOptions();
options.SetVivoxCredentials(server, domain, issuer, tokenKey);
await UnityServices.InitializeAsync(options);
await VivoxService.Instance.InitializeAsync(config);

What can we do to fix this issue? We theoretically don’t need the microphone, so would it be possible to avoid changing the AVAudioSession at all?

Two things to try:

  1. Since you may not need the microphone, as you say, try setting the input device to “No Device”. That will prevent Vivox from configuring the device for platform echo cancellation.
  2. Rather than disabling the microphone input, you can disable Dynamic Voice Processing Switching. With that VivoxConfigurationOptions config, add config.DynamicVoiceProcessingSwitching = false;. There are other issues you may experience with the audio after disabling Dynamic Voice Processing Switching, but maybe this is all you need.

Yeah, using “No Device” did the trick for us. Thank you so much!

Hi @mhakala , when I join voice channel and open screen recorder. Screen recorder cannot get sound from device ios.

Hey @vuthang , that might be a privacy feature of iOS so that voice chat cannot be recorded. If you try with wired headphones on iOS, does screen recorder then capture the voice? Or if you configure Vivox to use Bluetooth A2DP instead of the default Bluetooth HFP, does it then record the voice?

Vivox automatically uses a voice processing route when in a speakerphone or Bluetooth Hands-Free Profile configuration. In those configurations, we suspect that iOS will not record voice for the sake of privacy.

If you disable ‘DynamicVoiceProcessingSwitching’ like mentioned above and follow a guide like this to set the AVAudioSession category to PlayAndRecord (so the microphone can work), then voice might be retrievable by screen recorders in all configurations, but there could be unwanted audio quality changes by disabling Dynamic Voice Processing Switching (mainly lack of platform Acoustic Echo Cancellation when in speakerphone mode).

  • I try with wired headphones on iOS, screen recorder not capture the voice and sound music in game.
  • When I disable ‘DynamicVoiceProcessingSwitching’ and set the AVAudioSession category to PlayAndRecord, vivox is not work. Other player cannot hear me

@vuthang , I checked our implementation and I was wrong about wired headphones making a difference in this case. I was remembering our Android implementation. Wired headphones with DVPS enabled will still cause the device to be configured for voice chat purposes.

What surprises me is that you are saying the screen recorder is not able to capture game music either. I figured it might have just been voice that wasn’t appearing in the capture. Can you confirm that no audio (voice, game music, or game sounds) is being captured by the screen recorder while Vivox is active without DVPS disabled?

As for disabling DynamicVoiceProcessingSwitching (DVPS) and setting the AVAudioSession category to PlayAndRecord, you might also have to set the AVAudioSession mode to something other than Default. Perhaps setting the mode to AVAudioSessionModeVoiceChat makes voice transmission work, but that might bring on the same problem with screen recording again.

It’s beginning to sound like this is a use case that we need to work to support unless we find that circumventing Apple’s voice chat privacy intentions would lead to App Store rejection.

Yes. I test on my iOS and no audio (voice, game music, or game sounds) is being captured by the screen recorder while Vivox is active. I test DVPS disabled or enable but the result is same.

@vuthang , does setting the PlayAndRecord category cause this problem by itself? If not, then it might be that having any microphone open for capture can cause this. But when Vivox isn’t transmitting after you disable DVPS and set PlayAndRecord yourself, is the microphone indicator showing at the top of the phone? It would be odd if the recording indicator is showing but voice isn’t working.

When screen recording stops capturing all audio due to Vivox, does leaving the voice session immediately fix the issue?

What if you try opening a Unity Microphone instead of joining a Vivox session. Does simply starting capture on a Unity Microphone lead to the screen recorder’s lack of all audio? See: Unity - Scripting API: Microphone

When I set PlayAndRecord, vivox can work normal. When I disable DVPS, I cannot see the recording indicator and vivox is not working.
This is step I produce this bug:

  • Open screen recorder and not join any voice chat channel
  • Screen recorder can record music and sound in game.
  • Join voice channel. After join success, screen recorder CANNOT record any sound, music in game while sound, music can hear normally.
  • Leave voice channel. Screen recorder can record music and sound in game normal.