Bank preloading

We are porting a game into HTML5 using Fmod.
We’ve got some existent bank files to use.
Question : what would be the best practice to load the bank event only when we need it without having to preload the entire bank (long time)
Many thanks

By default, loading a bank through Studio::System::loadBankFile only loads that bank’s metadata, not its sample data. Metadata takes very little time to load, and is therefore unlikely to have a significant impact on your game’s load times.

Sample data, however, can take significant amounts of time to load. There are three different ways to load sample data, each with its own advantages and disadvantages.

  • It sounds like you want to avoid Studio::Bank::loadSampleData, as it loads all the sample data in the bank at once. This is useful for games where loading times aren’t a concern or where you can guarantee loading will happen in the background, but is not useful in your case.
  • Instead, you probably want to use Studio::EventDescription::loadSampleData, which loads the sample data only for the specified event, allowing you to load your bank’s sample data piecemeal. By calling it some time in advance of playing an instance of the event, you can guarantee the sample data will be loaded in time for the event to play.
  • You could also potentially rely on Studio::EventDescription::createInstance. Creating an instance of an event automatically loads the sample data for that event if it is not loaded already. The disadvantage of this method is that if the sample data for an event is not fully loaded by the time the event instance is supposed to play, the event instance will wait until all its sample data is loaded before it begins, meaning that event instances may sometimes play with a noticeable delay. To avoid this, load the sampledata for an event in advance using Studio::EventDescription::loadSampleData, as I described above.

Many thanks Joseph

Hi Joseph
Does the “preRun” function is obligatory? or can we load bank without it?

This method take a long time :
FMOD.FS_createPreloadedFile(folderName, fileName[count], fileUrl + fileName[count], canRead, canWrite);


As described in the File Access section of the HTML5 documentation, preRun is just one of several different possible ways to load data from the host.

Thanks for your reply. It changes nothing regarding the loading time.
What we need is to call a sound/event from a bank without preloading the bank.
Is there a way to do this?

As I said in my earlier post, loading a bank with Studio::System::loadBankFile just loads that bank’s metadata, which is small and does not take long to load.

If you are trying to reduce your game’s load times, you need to avoid calling Studio::Bank::loadSampleData, as it loads all the sample data associated with the bank when it is called, potentially taking a considerable amount of time and memory. You should instead either use Studio::EventDescription::loadSampleData, which loads the sample data only for the specified event when called, or avoid preloading sample data entirely by relying on Studio::EventDescription::createInstance to load sample data whenever you call it to create an instance of an event.

Thanks for your reply.
I talk about the previous step : preload bankfile.
AFAIK you need to preload the bank, that’s what we need to avoid.
Is there a way to avoid the preload bank file function?

To play an event, you must first load a bank that includes that event. There is no way to avoid this, as it is impossible to play an event without loading it.

If your banks are taking too long to load, have you considered splitting your events up into multiple banks? Doing so would allow you to amortize the load times by only loading the bank or banks for the events that your game needs in the immediate future.