Delay over Bluetooth with Fmod api 1.09.06 on android

hi,

sorry for my English,
im developed car engine sound in Fmod Studio …
right now im using the build in car engine sound from the examples from Vehicles
integrated to my android app…

im having a audio delay of 2-3 sec over Bluetooth in a few cars in A2DP protocol.
i have checked my app over couple of phones nexus 6p, nexus 5x , android 8.0, galaxy s7 , android 7.1 (same delay)…

i saw in the website that there is an update soon (1.09.07), maybe the fix is on its way…
or maybe im doing something wrong, im not doing nothing to route the audio output( speaker, aux, bluetooth and etc…) and maybe i should.

i just calling the rpm value parameter from the car event and change
its value with a slider in a loop…

in speaker(phone) and aux (cable direct to the audio system) the sound works perfectly…
in Bluetooth there is a problem- delay of 2-3 sec.

please help,
thanks
tal

Hi Tal,

Unfortunately, bluetooth lag on Android devices is a common issue and is unrelated to FMOD. This is something that needs to be fixed by Android.

Thanks,
Richard

1 Like

hi,

Ok , i will try to figure it out from the android system aspect…
i have another problem in some of the bluetooth devices…
when the bluetooth is connected, and the sound is played
i can hear the sound disrupted , not clean , broken, not fluid.

what can i do to fix this issue?

thanks

Hello Tal,

There are situations with newer Android devices when if a bluetooth device is connected it can cause the audio to sound corrupted. Please try the following code which will detect if a bluetooth device is connected and set FMOD’s output type to audiotrack.

// check for bluetooth headset on android N (or above)
try
{
#if UNITY_ANDROID && !UNITY_EDITOR
int androidVersion = -1;
AndroidJavaClass buildClass = new AndroidJavaClass("android.os.Build$VERSION");
androidVersion = buildClass.GetStatic<int>("SDK_INT");

if (androidVersion >= 24)
{
bool bluetoothAudioIsOn = false;

AndroidJavaClass playerClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject activity = playerClass.GetStatic<AndroidJavaObject>("currentActivity");
AndroidJavaClass audioManagerClass = new AndroidJavaClass("android.media.AudioManager");
AndroidJavaObject audioManager = activity.Call<AndroidJavaObject>("getSystemService", audioManagerClass);

bool isBluetoothA2dpOn = audioManager.Call<bool>("isBluetoothA2dpOn");
bool isBluetoothScoOn = audioManager.Call<bool>("isBluetoothScoOn");
bluetoothAudioIsOn = isBluetoothA2dpOn || isBluetoothScoOn;

if (bluetoothAudioIsOn)
{
result = lowlevelSystem.setOutput(FMOD.OUTPUTTYPE.AUDIOTRACK);
CheckInitResult(result, "Set output");
}
}
#endif
}
catch (Exception e)
{
Debug.LogWarning("Unable to determine android version or bluetooth status. Output is set to default.");
}

Please note this code will only work if the bluetooth device is connected before launching the FMOD application. If you wanted, you could also use the same detection to provide a suggestion to users to not use bluetooth headphones.

Thanks,
Richard

1 Like

Hi,
I’m using native Android (Java), and cpp (c++) native for fmod
So the check for bscoOn and the ba2dp is on for the n and above I will do in java
The low level is the same code for c++
Thnks

update,

thanks it worked for me…
the lag of the Bluetooth is still happening,
there is no mode to work with low latency in FMOD to make it happen without the lag…

to check the latency over bluetooth im using the drrickorang LoopBack app,
and the bluetooth device that cause me the problem (lag) says it take 10ms (loopback ), its the same latency with the bluetooth device without the issue/lag.

maybe there is a some configuration in fmod to solve this issue .

also, i have noticed the var isBluetoothA2dpOn return true from bluetooth with the lag and isBluetoothScoO return false.

thanks,
tal

Hi Tal,

We will take a look into bluetooth on Android in future releases however, there isn’t anything that can be done at the moment unfortunately.

Thanks,
Richard