Load single dialogue line from localized audio tables

Hi there!

I have started using FMOD Studio along with Unity for our game project. One of the exciting features of FMOD for us is the support of localized dialogue using Localized Audio Tables and Programmer Instruments. I have used the example FMOD project along with the source code example for Unity (https://www.fmod.com/resources/documentation-unity?version=2.02&page=examples-programmer-sounds.html) and managed to get it to work just fine but I have run into a couple of things that might create issues for us in the long run. I will try to explain my thought process of trying to fix these, so please correct me on anything I might be doing wrong.

After setting everything up and testing that the localized dialogues work, I have noticed that every time I played one of the dialogues FMOD would log the following warning:
[FMOD] SoundSourceInstrumentInstance::startChannelIfReady : Loading delay exceeded, sound may play at incorrect time

Investigating this, I found out that the source of this warning is the fact that the desired sound is not yet loaded into memory so FMOD needs to do that first, which might introduce slight delay. For small enough sounds this delay should not be noticeable (I believe our dialogue lines should fit into this area) and can generally be ignored. The only way of fixing this would be to preload the sample data which not only doesn’t work for audio tables but would load all the dialogue lines in the bank into memory. Considering we could have thousands of dialogue sounds, I can see that being an issue. So loading the needed dialogue line right when it needs to be spoken using the createSound method should be the desired way of doing things.

I investigated a bit further just in case and set the logging level to “Log” in the FMOD settings. In the extra logging information I found out that the bahavior is different from what I expected. Instead of the individual line being loaded in, played and then unloaded, it creates sounds for all the dialogue lines in the bank through the SystemI::createSoundInternal method. It also does this every time I play any of the dialogues.

Looking into the createSound method it seems to load things based on the data gained by the getSoundInfo method, so I cannot really alter its behaviour. Also the only thing passed into the getSoundInfo method is a string containing the key identifying the dialogue line, so I don’t see myself fixing the issue here either.

What I would like to ask is if it is possible to change the behaviour of the createSound method to only load the individual sound for the given dialogue line instead of loading all of them contained in the same bank? Am I somehow using the entire concept of localized audio tables and programmer instruments incorrectly?

If this is the expected behaviour, is there a way I should be working around this? Creating all the sounds beforehand and storing them would be overly demanding on memory as mentioned before. Another way I could maybe see helping would be to structure the dialogue sounds into multiple banks instead of a singular one. Although this might make the process of creating, loading and unloading them more complex that what we would like. Any tips are greatly appreciated.

Version of Unity and FMOD I am using in case this info is relevant to my issue:
Unity version: 2021.2.0f1
FMOD for Unity package version: 2.02.04
FMOD Studio version: 2.02.04

Thanks in advance.


I have looked a bit deeper into this. Using the FMOD Studio Debug overlay and the profiler in FMOD Studio and tracking the memory usage I have found out that the dialogue lines are indeed loaded separately as they are used. This is also confirmed by them being released after they are done playing which I failed to notice before. Sadly Unity’s memory profiler doesn’t seem to be able to track the memory FMOD actually uses for loading in and playing the audio clips but given the fluctuations in the total memory used by the application it seems that the information provided by FMOD is (at least for the most part) correct.

It might be worth looking into the log message created by SystemI::createSoundInternal as it is a bit misleading with its name, since it seems to be just scanning through the audio table rather than actually creating a sound.

I now consider this issue resolved so feel free to close down this topic. While I was looking into this and FMOD in general I have run into another problem though and have created a separate thread for it here: Short sounds not released after they finish playing. Any help with that issue would be greatly appreciated.