Issue with BGM Cutting Off in FMOD

Hello,

I am using FMOD in Unity to manage the same BGM across two banks (Bank A and Bank B). In Map A, I play the BGM using Bank A, and when transitioning to Map B, I only load Bank B while keeping the same BGM instance that was loaded in Map A. However, when unloading Bank A, the BGM cuts off and only resumes after some time.

I would like to ensure that the BGM remains uninterrupted when transitioning from Bank A to Bank B.

Are there any alternative approaches to resolve this issue? What would be the best way to prevent the BGM from cutting off in FMOD?

Thank you.

Can you confirm that Bank A is being unloaded after Bank B has been loaded?
Is the event being created/controlled from a persistent scene or gameobject?
Can you describe in more detail how you play, load, and unload the event and banks?

An alternate solution for this could be to have a bank for events that are persistent across multiple scenes, this would remove the need for loading/unloading banks with shared data.

I am currently loading Bank A in Map A and playing BGM A. Upon moving to Map B, I load Bank B, and after 5 seconds, I unload Bank A. However, this causes the currently playing instance to disconnect, and when the BGM loop restarts after the track ends, it plays again.

To address this, I tried a different approach: destroying the currently playing BGM instance, then loading Bank B and creating a new instance. However, the same issue still occurs.

Additionally, this problem does not occur in the editor environment but continues to happen in the build environment. So far, I’ve only tested the Windows build.

This doesn’t sound right. I have tried to repro this myself but I am unable to produce the issue.

Can you provide more detail on how you are loading and unloading the banks?

  • Are you manually doing it from a script?
  • Are you using the StudioBankLoader script?
  • Is the event triggered and maintained outside of ‘Map A’?

I assigned the background music (BGM) ‘cave’ to both Bank A and Bank B. I am playing the BGM through Bank A. When transitioning to a new map, Bank B is loaded as the new map is loaded, and I set a timer to unload Bank A 5 seconds after. I’m loading and unloading the banks using Unity Addressables. Also, I’m playing the BGM through RuntimeManager via a script. Here is the playback code attached below.

========================
var eventPath = GetEventPath(key);
if (string.IsNullOrEmpty(eventPath))
{
return default;
}

            var instance = RuntimeManager.CreateInstance(eventPath);

            instance.start();
            instance.release();

            return instance;

========================

I am unable to reproduce the behavior, even using addressables, but I must be doing something different to you.

Are you doing anything with the addressable assets other than just calling RuntimeManager::LoadBank(assetReference)?

I’m calling it using the function you provided.
I’m not doing any other tasks.
It works fine in the editor environment, but the issue only occurs in the Windows build.
Cameron, do you also not experience this issue in the Windows build?
Is there something I might be doing wrong?
My suspicion is that since the BGM has the Stream option, even if I load Bank B, the BGM being played is still based on Bank A, so it might be cutting off because of this.

That’s because the music starts playing again around the time the BGM ends and loops.

After forcing the Unity bank file to load as an Addressable and commenting out the relevant code, I noticed the same issue now appears in the editor as well. Below is the commented-out code:

private static void LoadBank(TextAsset asset, bool loadSamples, string ankId)
{
if (Instance.loadedBanks.ContainsKey(bankId))
{
ReferenceLoadedBank(bankId, loadSamples);
}
else
{
#if UNITY_EDITOR

    // {
    //     LoadBank(bankId, loadSamples, bankId);
    //     return;
    // }

#endif

    LoadedBank loadedBank = new LoadedBank();
    FMOD.RESULT loadResult = Instance.studioSystem.loadBankMemory(asset.bytes, FMOD.Studio.LOAD_BANK_FLAGS.NORMAL, out loadedBank.Bank);
    Instance.RegisterLoadedBank(loadedBank, bankId, bankId, loadSamples, loadResult);
}

}

Thank you for all the information, this is a limitation of loadBankMemory which is is currently required to load the banks from the Addressables.

A workaround for this would be to use a separate bank for events that are persistent across the game that do not need to be unloaded.

It seems that when using Unity Addressables, you can’t use “assign” in this way.
Thank you for your help, Cameron!