|
Post by polygryph on Mar 16, 2023 19:12:52 GMT
In my project, I've got 6 playlist controllers with stems that allows me to fade out and fade in parts of the track to control the intensity of the music on a per-scene basis. I've also got an unlooped version of each stem with gapless audio switching that switches into a looped version of the stem, to prevent the blurt of the end of the looped audio from being the first thing that plays. Each area of my game has different music. Here is where I am experiencing problems:
If I'm using AudioClips (with preload audio data turned off), the audio memory starts off fine. But over time the amount of audio memory being taken up is too much. After just three areas the amount of audio memory being used is anywhere from .5 to .7 gigs. There will be over 20 areas when the game is finished, so this wont work.
So I opted to use resource files to reduce the memory load, which it has. However when I do this I get two huge framerate pauses. The first being a second or so after the scene has loaded, and another when the unlooped version switches to the looped version. This framerate pause usually lasts somewhere between 1200ms and 1800ms according to the profiler, where there are 5-6 instances of PlaylistController.Update() taking around 300ms apiece steming from Loading.ReadObject(). The transition between looped and unlooped versions typically happens during gameplay so it's a huge problem. I didn't get these huge framerate pauses with Audioclips.
Is there any way to load the audio in advance so that I don't encounter the framerate pause?
|
|
|
Post by DarkTonic Dev on Mar 16, 2023 21:07:40 GMT
When using "Preload Audio Data" turned off, and you switch to a different song, the old song will be unloaded from memory when it's no longer used (played). So it shouldn't be accumulating any memory unless you have more and more audio playing at the same time.
Resource loading is a Unity thing, there's not really anything we can do to make it work better.
Loading the audio in advanced basically means not using Resource files and/or leaving "Preload Audio Data" checked. Which means the memory from every single song in all your Playlists would be occupying memory at all times. I doubt that would help things.
If you are saying that there's a bug in unloading the preload audio data stuff when changing songs, let me know how to reproduce it. It worked when I tested it.
You may send me a small scene that reproduces the problem.
Thanks, Brian
|
|