Table of Contents
-
Lessons
Optimizations are most often applied in the later stages of a game production, but it is nevertheless important as a game with a stuttering framerate can make quite a difference to the overall experience. Any game will have numerous processing tasks running during gameplay, and, likewise, the decompression of Vorbis encoded media will be added as a task on that list. To reduce the processing used on decompressing Vorbis encoded media, you can use the Decode compressed data feature offered in the AkBank component.
This will decode all Vorbis encoded media upon loading the SoundBanks, so no additional resources will be needed the next time the same Events will be posted by the game. Compared to not having this option selected, this option will increase the size of the SoundBank in memory, resulting in the equivalent size to using PCM encoding in the first place. Then why not just encode the PCM to begin with? For example with downloadable games, you might want to keep a low SoundBank size for distribution, and then let the SoundBanks be decoded once the game loads. An estimate of the SoundBank's decoded size, can be found in the SoundBank Manager after conversion.
The Dungeon SoundBank is the Region SoundBank with the most proportional change in data size after decompression, and so you will set this SoundBank to decompress and monitor the difference. In the following steps, you will start by monitoring the data size in memory before decompression, then enable the Decode compressed data option and then monitor the change in data size.
-
In the Unity menu, go to Audiokinetic > Certification > 301 > Lesson 3 and select Decompressing SoundBanks.
Before setting the SoundBank to decode the compressed data, let's profile the current memory usage.
-
In Wwise, click Remote.
-
In the Remote Connections window, highlight Wwise Adventure Game (Editor) and click Connect.
-
In Unity, click Play.
Once the game has initialized you can exit Play mode again.
-
Press ESC to open the WAG menu and click Play again to exit Play mode.
-
In the Wwise menu, click Layouts and select Profiler.
-
In the Advanced Profiler, select the SoundBanks tab.
-
In the Performance Monitor, drag the Time Cursor backwards a few seconds.
Notice that the Dungeon SoundBank is using approximately 2.4 MB of memory.
Next, let's decode the SoundBank when loaded. The Dungeon SoundBank can be found on the Wwise game object in the L3_2 - Dungeon Audio Environment Scene.
-
In Unity's Hierarchy, go to the L3_2 - Dungeon Audio Environment Scene and select the Wwise game object.
-
In the Inspector's AkBank component, select Decode compressed data.
The Decode compressed data option will now be enabled. Below it you will see a 'Save decoded bank' parameter, which should stay disabled. When decoding a SoundBank, the decoded data will be moved into memory.
The Decode compressed data option will only be able to decode the Audio Sources in the SoundBank that are set to Vorbis or Opus. The option has no effect on SoundBanks without any Vorbis encoded media. For more information, see Using AkBank from the Inspector.
-
Click Play.
-
In Wwise, make sure you are still connected. If you are not, click Reconnect.
Look in the Advanced Profiler's Memory tab and notice that there is no longer a Dungeon SoundBank in the Name column.
This is due to decompression. The SoundBank uses more memory but avoids using CPU resources to decode the Vorbis and Opus encoded media during gameplay, ensuring a smoother game experience.