# Bank preloading

**URL:** <https://qa.fmod.com/t/bank-preloading/17249>\
**Category:** FMOD Engine\
**Created:** [May 26, 2021, 10:19am UTC](https://qa.fmod.com/t/bank-preloading/17249 "2021-05-26T10:19:09Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![yohann](https://avatars.discourse-cdn.com/v4/letter/y/9fc348/32.png) [@yohann](https://qa.fmod.com/u/yohann)\
**Post date:** [May 26, 2021, 10:19am UTC](https://qa.fmod.com/t/bank-preloading/17249/1 "2021-05-26T10:19:09Z")

</div>

Hi  
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

---

<div class="post-metadata">

**Author:** ![joseph](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/joseph/32/264_2.png) [@joseph](https://qa.fmod.com/u/joseph)\
**Post date:** [May 27, 2021, 12:41am UTC](https://qa.fmod.com/t/bank-preloading/17249/2 "2021-05-27T00:41:34Z")

</div>

By default, loading a bank through [`Studio::System::loadBankFile`](https://www.fmod.com/resources/documentation-api?version=2.2&page=studio-api-system.html#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`](https://www.fmod.com/resources/documentation-api?version=2.2&page=studio-api-bank.html#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`](https://www.fmod.com/resources/documentation-api?version=2.2&page=studio-api-eventdescription.html#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`](https://www.fmod.com/resources/documentation-api?version=2.2&page=studio-api-eventdescription.html#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`](https://www.fmod.com/resources/documentation-api?version=2.2&page=studio-api-eventdescription.html#studio_eventdescription_loadsampledata), as I described above.

---

<div class="post-metadata">

**Author:** ![yohann](https://avatars.discourse-cdn.com/v4/letter/y/9fc348/32.png) [@yohann](https://qa.fmod.com/u/yohann)\
**Post date:** [May 28, 2021, 9:30am UTC](https://qa.fmod.com/t/bank-preloading/17249/3 "2021-05-28T09:30:07Z")

</div>

Many thanks Joseph

---

<div class="post-metadata">

**Author:** ![yohann](https://avatars.discourse-cdn.com/v4/letter/y/9fc348/32.png) [@yohann](https://qa.fmod.com/u/yohann)\
**Post date:** [May 28, 2021, 11:43am UTC](https://qa.fmod.com/t/bank-preloading/17249/4 "2021-05-28T11:43:37Z")

</div>

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);

thx

---

<div class="post-metadata">

**Author:** ![joseph](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/joseph/32/264_2.png) [@joseph](https://qa.fmod.com/u/joseph)\
**Post date:** [June 3, 2021, 1:17am UTC](https://qa.fmod.com/t/bank-preloading/17249/5 "2021-06-03T01:17:58Z")

</div>

> [@yohann](#):
>
> Does the “preRun” function is obligatory? or can we load bank without it?

As described in the [File Access](https://www.fmod.com/resources/documentation-api?version=2.02&page=platforms-html5.html#file-access) section of the HTML5 documentation, preRun is just one of several different possible ways to load data from the host.

---

<div class="post-metadata">

**Author:** ![yohann](https://avatars.discourse-cdn.com/v4/letter/y/9fc348/32.png) [@yohann](https://qa.fmod.com/u/yohann)\
**Post date:** [June 10, 2021, 8:04am UTC](https://qa.fmod.com/t/bank-preloading/17249/6 "2021-06-10T08:04:48Z")

</div>

Hi  
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?  
Thx

---

<div class="post-metadata">

**Author:** ![joseph](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/joseph/32/264_2.png) [@joseph](https://qa.fmod.com/u/joseph)\
**Post date:** [June 11, 2021, 3:36am UTC](https://qa.fmod.com/t/bank-preloading/17249/7 "2021-06-11T03:36:13Z")

</div>

> [@yohann](#):
>
> 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`](https://www.fmod.com/resources/documentation-api?version=2.2&page=studio-api-system.html#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`](https://www.fmod.com/resources/documentation-api?version=2.2&page=studio-api-bank.html#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`](https://www.fmod.com/resources/documentation-api?version=2.2&page=studio-api-eventdescription.html#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`](https://www.fmod.com/resources/documentation-api?version=2.2&page=studio-api-eventdescription.html#studio_eventdescription_createinstance) to load sample data whenever you call it to create an instance of an event.

---

<div class="post-metadata">

**Author:** ![yohann](https://avatars.discourse-cdn.com/v4/letter/y/9fc348/32.png) [@yohann](https://qa.fmod.com/u/yohann)\
**Post date:** [June 11, 2021, 8:22am UTC](https://qa.fmod.com/t/bank-preloading/17249/8 "2021-06-11T08:22:27Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![joseph](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/joseph/32/264_2.png) [@joseph](https://qa.fmod.com/u/joseph)\
**Post date:** [June 15, 2021, 12:22am UTC](https://qa.fmod.com/t/bank-preloading/17249/9 "2021-06-15T00:22:00Z")

</div>

> [@yohann](#):
>
> 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.
