I guess maybe I should have gone into more detail about what’s going on.
In FMOD for Unity, the LoadBank(string bankName, bool loadSamples, string bankId)
method in the RuntimeManager
class has two ways of loading.
The first is loading from local, which ends up using the Studio::System::loadBankFile()
API.
The second is loading from a network request, which calls the loadFromWeb(string bankPath, string bankName, bool loadSamples)
method in the RuntimeManager
, which ultimately uses the Studio::System::: loadBankMemory
API. loadBankMemory` API.
Obviously, on Android and iOS platforms, files will be loaded locally, and FMOD will use Streaming data
to keep memory at a reasonable level.
But when it comes to WebGL platforms, due to various limitations, we can’t store files locally, only in memory. The Studio::System::loadBankMemory
API also downloads the entire Bank file into memory, which obviously has a huge impact on memory usage.
Therefore, we need to maintain a system that allows loading Banks into memory only when they are needed, and unloading them when they are not - similar to jeff_fmod’s idea.
However, the problem arises at this point, under the WebGL platform, each Bank file has to be downloaded from the server, so we need to control the size of the Bank file within a certain limit, otherwise it will take too long to load the Banks.
Therefore we split the Event into multiple Banks, which also leads to the possibility that the Events may have references to each other.
As an example, Event A is assigned in Bank A, and Event B is assigned in Bank B.
In Event A, Event B is used as Event Instrument.
If I want to play Event A, I need to load both Bank A and Bank B at the same time.
Based on the previous reasons, I need to load and unload the Bank files manually. Then I need to know in some way that this reference relationship exists between Event A and Event B. And make sure that both Bank A and Bank B have been loaded before playing Event A.
The way I’m currently using is to export to a json file via a script in FMOD Studio to record these relationships.
But there is a tricky problem at this point:
If there is an Event C that uses a Parameter Sheet, it is assigned in Bank C.
Also referenced in Event C are Events C1, C2, C3, …, and C10, each of which uses a very large audio file (e.g. background music).
And these Events are in turn assigned in Banks C1, C2, C3, …, and C10 (in order to ensure that the size of each Bank file does not exceed the limit).
The result of my JavaScript script execution is that when playing Event C, Bank C, C1, C2, …, and C10 need to be loaded at the same time because of the dependencies between them. But again, this results in a huge memory footprint.
Is there a better and more direct way for us to get out the relationship between Event and Bank? Or is there a better solution for this situation?
It seems that enabling “Include referenced events in banks (recommended)” when building banks doesn’t solve the problem.