We are experiencing very weird behavior with our music which is implemented as an event with OneShot=False, Streaming=True, 3D=False.
Projects settings are configured to LoadAllBanks=True, LoadAllSampleData=True,LockAllBuses=True,LoggingLevel=LEVEL LOG
Music starts playing only if it is called right at the start of the game. If we call PlayEvent2D() (or any other play event function) AFTER the inital automatic load of banks, then music is ignored and FMod logs nothing about playing the sound into output log.
It took me some time to debug it but these are steps I used for debugging:
If I play music on the game start - music starts
If I play music 2 seconds (Delay in blueprint) after the game start - music does not start
If I play music 1 second after the game start - behavior is random, sometimes it starts, sometimes it does not - so it probably depends on the load times of the bank
So, I used 2 seconds Delay (situation in which no music is started) and after that I called manually BP nodes UnloadBank() and LoadBank(Blocking=false,LoadSampleData=False). This makes play music work at any time (no matter when I call it after loading the bank). But… If I change any LoadBank() parameter to true, then I am back at our problem -> Music plays only if I trigger it right after loading the bank!
I checked the source and it makes sense that changing any LoadBank() parameter to true fixes the problem. Both parameters are doing the same thing:
FMOD_STUDIO_LOAD_BANK_FLAGS flags = (bBlocking || bLoadSampleData) ? FMOD_STUDIO_LOAD_BANK_NORMAL : FMOD_STUDIO_LOAD_BANK_NONBLOCKING;
In order to be able to play music at any time without actually calling UnloadBank() and LoadBank() manually in blueprint, I had to set project settings variable LoadAllSampleData=False. After setting it to false everything is working correctly out of the box.
We are using UE 4.22 and FMod 1.10.14.
What’s happening there? Why can’t I load sample data if I am using streamed sound? Why is streamed sound never played if I load sample data?