Load Banks in real time from Android

Hello Support,

I’m trying to integrate FMOD to our Unity project. Since we need to run on mobile and we want to offer potentially unlimited contents, we are trying to download all the assets the player will need for the current level only.

To do so, I need to be able to download the banks and load them while the app is running.

Following the tutorials on how to play sounds on Unity from FMOD I was able to understand the logic of Events etc, but since I don’t have all the banks at app launch, I cannot rely on the option “Load All Event Data at Initialization”, and as Import Type I’ve selected Asset Bundle.

If I’m letting the FMOD integratio loads the Event data from the StreamingAssets, everything works fine and I can play all the events I want, but as soon as I removed the check from load all event data, I wasn’t able anymore to even load a single bank and play a single sound.

This is what I’m trying to do to load a bank:

    studioSystem = FMODUnity.RuntimeManager.StudioSystem;
    FMOD.Studio.CPU_USAGE cpuUsage;
    studioSystem.getCPUUsage(out cpuUsage);

    FMOD.Studio.System bankload;
    FMOD.Studio.System.create(out bankload);
    var loadingResult = bankload.loadBankFile(System.IO.Path.Combine(Application.streamingAssetsPath, bankName), FMOD.Studio.LOAD_BANK_FLAGS.NORMAL, out loadedBank);

    loadedBank.loadSampleData();

But doing that will result in a FMOD.RESULT err_invalid_handle.

I’ve also tried to not create a new bank and use the RuntimeManager to load a bank:

FMODUnity.RuntimeManager.LoadBank(bankName, true);

But again, no luck and no error messages, beside the fact that sometime after loading the bank I get an exception:

“BusNotFoundException: FMOD Studio bus not found ‘bus:/’
FMODUnity.RuntimeManager.GetBus (System.String path) (at Assets/Plugins/FMOD/RuntimeManager.cs:825) etc…”

And in all cases, if I try to PlayOneShot one of my events just after loading the bank, I get another error saying the event cannot be found.

Is there a tutorial or somebody who can tell me the proper procedure to load banks as Asset Bundle on run time?

Thank you for your assistance!

Andrea

In the code snippet you provided, you are creating a new system instead of using the studioSystem from the RuntimeManager.

In the case of Asset Bundles, you are required to handle the loading of ALL banks, including the Master and strings banks.
https://fmod.com/resources/documentation-api?page=content/generated/engine_new_unity/assetbundle.html#/

2 Likes

Hello Cameron,

Thank you for your assistance. I’ve fixed the problem by loading also Master and Master.string during initialization, also if (like in my case) I have nothing inside the Master bank (everything is assigned in specific banks with specific names).

Thanks!

THANK YOU @andreasimeone

When using AssetBundles, you MUST load Master and Master.string with RuntimeManager.LoadBank otherwise you will get errors when trying to play.