So I’m developing a game that’s very heavy in concurrent sounds and I get to a couple of problems that I honestly don’t know how to handle.
First, when the gameplay gets super crazy the sounds start to lag a bit and at some point one sound that I have on loop, a vehicle engine with a simple float parameter for the pitch that I send every frame gets stuck in some random pitch position and no matter what I send to it with SetFloatParameter, it stays the same until I unplay.
The second thing (also when the game gets crazy) is that some sounds just stop working at all, they never play again. I think it’s related to the first one, that somehow they get stuck in a state where they never come back again, or something similar.
The way I’m spawning the metasounds is basically through a combination of SpawnSound2D, SpawnSoundAtLocation, PlaySound2D and PlaySoundAtLocation. For the engine, I use the Spawn and I update the component with the speed. For most of the rest is just playing them at some location.
Any ideas of what could be going on? I’ve tried playing around with concurrency settings, but I always get the same results.
I may not have a direct answer to this as I have not experienced it before but you should probably check “Max Channels” under engine audio settings. This may be dated or completely off, but I believe 32 sounds is the maximum at once before “weird” things happen.
Check out some videos about “audio concurrency”. I have watched a few of these but it has not come up for me personally to get hands on with it.
Sorry if my information wasn’t helpful (or accurate) but I hope it gives you a good start!
Best of luck!
Hello! Thank you so much for the answer. So I’ve been playing around with concurrency (I have 32 channels indeed), but now I’ve been able to reproduce the issue with only 4 different sounds at the same time (and only one reproduction for each, so 4 in total).
I’ve kinda pinpointed the issue, this is only happening when I use SpawnSound2D and if I change it for PlaySound2D it never happens. The thing is, I’m caching correctly the audio component in a UPROPERTY, stopping it and playing it all the time (this ones are never duplicated, there is only one instance of each type), so I don’t have a single clue on why it would stop playing at all, or the opposite, freeze up in some state and never stop… I’m still digging, if I ever find the issue I’ll post it here.
And of course if someone has any other tips, I’ll gladly hear them all!
Hmm, Would love a bit more information to see if I may be able to provide more help… Will share a couple ideas worth testing in order to debug the issue or find a potential workaround!:
1.- You mentioned testing a clean scene with only 4 sounds and experiences dropouts. What you’re describing appears to be sounds getting culled/purged due to reaching an active voice cap. This will depend on the behavior you’ve set up on each sound within its “Voice Management” settings:
Try setting your engine loop to “Play when Silent” and bumping up its priority. If “Play when Silent” is not on, the sound will stop until it is called again (potentially OK depending on the type of
2.- Particularly for this four (4) sound object test, remove any concurrency rules and settings from all sound assets and triggers (and ensure the engine’s cap is out of the way by setting its value to 32 - default). Perhaps only test with the problematic sound and expand your test from there!
3.- You mentioned the issue goes away when using “PlaySound2D” instead of “SpawnSound2D”. I wonder if this may have anything to do with the “Auto-destroy” portion of the SpawnSound2D? If sending a stop command while the auto-destroy boolean is on will cause the spawned audio component to be cleaned up. Possibly try checking if the bool is true/false and test with both settings!:
4.- Run audio debug commands while testing! Might help reveal if there are lingering sounds not being cleaned up (possible leak), and will also show you which sounds are active as you test. Experiment with these commands:
au.3dVisualize.ActiveSounds 1
au.3dVisualize.Enabled
au.3dVisualize.VirtualLoops
(many more worth testing to help find the culprit)
5.- If all else fails, perhaps try adding an audio component to the appropriate game objects and handling sound playback using start/stop component commands to see if some solutions arise by restructuring the audio logic.
Hope some of this helps!
Please feel free to share any additional updates/information and I’d be happy to dig deeper.