|
Post by artaka on Jun 25, 2019 16:21:34 GMT
Hey Brian,
I'm asynchronously loading an additive scene which contains a DynamicSoundGroupCreator with over 50 sound groups. This causes a hiccup in the playback since it has to add all the sound groups to MasterAudio. Is there a way to load all those sounds async (perhaps in a coroutine) to avoid loading them all on a single frame?
|
|
|
Post by DarkTonic Dev on Jun 25, 2019 20:34:01 GMT
If you put some of the Audio Clips into Resource files or turn off "Preload Audio Data" for those Audio Clips, they will not need to be "loaded" until they are played. It will introduce a latency as they are loaded when they need to play, so use it only on those sounds where that's acceptable.
|
|
|
Post by artaka on Jun 26, 2019 23:23:57 GMT
Thanks for the help. Unfortunately, that didn't fix it. What is causing the spike is the process of duplicating the sound groups from DynamicSoundGroupCreator to MasterAudio when DSGC is enabled. I'm going to try to take apart DynamicSoundGroupCreator.CreateItems and put it in a coroutine to spread the duplication process to a few frames. Hopefully that should do it.
|
|
|
Post by DarkTonic Dev on Jun 26, 2019 23:36:58 GMT
I would think it would be loading the actual Audio Clips which would contribute most of the load time, and they are initially stored in the DSGC. Did you try totally disabling the CreateItems functionality and watching for spikes?
Coroutines are bad and also cause Garbage Collection to my knowledge. Let me know if you make any progress though.
|
|
|
Post by artaka on Jun 27, 2019 0:46:15 GMT
Since I have "Load In Background" checked for the audio files, they don't seem to be the cause. I disabled auto-create items and triggered it manually at a later time and triggering it what caused the spike (AddComponent taking the most time).
You are right, coroutines do generate small garbage but since I'm doing it once, it should be insignificant.
I'll let you know how it goes.
|
|
|
Post by DarkTonic Dev on Jun 27, 2019 3:41:17 GMT
Ok, how many Sound Groups are in your DSGC and what platform are having the issue on?
I could consider taking a "move X Sound Groups over per frame" approach as I do on some other features. The side effect would be that sounds which haven't moved yet aren't available to play. This would basically be doing similar work to a CoRoutine but without using them.
Let me know what you discover.
|
|
|
Post by artaka on Jun 27, 2019 14:25:24 GMT
Having the option to doing a "move X per frame" would be great! There is close to 50 sounds in my DSGC and I'm running this on PC.
I understand that the sounds would not be available right away. But in my case, I would simply listen to the "Items Created" event to know when they are ready before proceeding to use them.
Thanks for looking into it!
|
|
|
Post by DarkTonic Dev on Jun 27, 2019 15:44:46 GMT
Cool. I will put it on the roadmap.
|
|
|
Post by artaka on Jun 27, 2019 21:35:05 GMT
Great! Thanks!
|
|
|
Post by DarkTonic Dev on Jun 27, 2019 23:40:29 GMT
Yep.
|
|
|
Post by wrexialmt on Apr 14, 2021 21:29:37 GMT
Hey, sorry for the Necro, but it's probably better to add to this thread rather than start a similar one
Originally, we had most of our sounds setup in MasterAudio but in an effort to reduce the ram useage of players, we swapped over to a `DynamicAudioGroupCreators` approach. Over time, this lead to a similar issue to the guy above, during loading screen, we were loading multiple DynamicAudioGroupCreators (typically 2) with ~90 DynamicSoundGroup each, each with multiple (3-20+) DynamicGroupVariations. At worst case by loading them all sync using the built in DynamicAudioGroupCreator we were look at around 1100ms (https://cdn.discordapp.com/attachments/480345368056561664/831917188595449926/unknown.png). We've tried doing a load them async over multiple frames, but the sheer number of assets that ended up having to be loading like this, easily took 5-10 second which was quite ugly.
Narrowing this down, we found the main culprit to be the "mirroring" of DynamicSoundGroup->MasterAudioGroup and DynamicGroupVariation->SoundGroupVariation conversions. As such we ended up retooling MasterAudio a bit which might be helpful to other's, and maybe it could be implemented into base MasterAudio.
What worked for us was the following: Pre-generation/editor - We wrote a simple editor tool extension which creates the `MasterAudioGroups` in the `MasterAudio` that is central in our game (similar to the DynamicAudioGroupCreator) - We moved these MasterAudioGroups to a different asset location which we could load back in at runtime from somewhere else (in our case, we have a per-voice actor scene and async load this) - We pre-generated and stored the `AudioInfo` and `playedStatuses list` so we don't have to generate these everytime we need them at runtime
Runtime - Load these presets somehow - We reparented them under the MasterAudio prefab - We extracted the last part of `MasterAudio.CreateSoundGroup` which is being used by the `DynamicAudioGroupCreator` to load these `MasterAudioGroups` to MasterAudio, specifically the RuntimeGroupInfo, Randomizer and Leftovers sections. - To unload we found the `MasterAudio.DeleteSoundGroup(name)` method which worked right out of the box.
Hope its clear enough and it might help someone else;
|
|
|
Post by DarkTonic Dev on Apr 14, 2021 21:33:05 GMT
Thanks for the tip. This is not something we plan on doing in the core product.
|
|