8.5) Realtime Monitoring
Now that you have made some adjustments for both memory and processor considerations, it is time to verify that things are working as they should. You can confirm this using the Profiler to monitor live gameplay, just as you’ve used the Profiler in earlier lessons. For any of the changes to work however, you need to generate your SoundBanks.
In the SoundBanks Layout, click Generate to create the SoundBanks with the changes you have made.
Launch the Platformer Game.
In Wwise, connect with the Platformer Game running on your computer and start a new Capture.
When the game starts, right after the intro cinematic, you immediately hear the background ambience for the traffic. Now, the number of Voices for car horns is limited, so you’ll probably hear a fewer number of car horns than before.
Go to the Profiler Layout. (Pic01 Performance Monitor)
Once the connection is established, you see multiple Graphs in the lower part of the screen. For a more detailed review, the area to the right shows all sorts of information, like the CPU usage. You see it move as the audio action gets more intense. Below you can see information indicating the total Number of Streams and the amount of Streaming Bandwidth being used when pulling the Data from the stored file. This represents your music when it’s played back, as soon as the player starts running. (Pic02 Streaming Data)
At the bottom of the area it shows Memory Usage, which is very low, and should be fairly consistent as the bulk of your sounds are loaded into memory when the game starts.
It’s always a good idea to capture gameplay and review these Graphs. Look for spikes that do not seem like they correlate appropriately with gameplay. In some cases, there may be things happening in the background that you may not be able to discover without having these Profiler Views.
The information in the Performance Monitor can be customized so that you can quickly view the Parameters you are interested in. Click on the gear wheel icon to open the Performance Monitor Settings to view a list of items such as Number of Voices and Total Plug-in CPU usage, that can be added to the display. (Pic03 Performance Monitor Settings)
In the Performance Monitor Settings, change the Graph Max value for the Number of Voices (Physical) and Number of Voices (Total) to 60, because this is your total Voice Count. The default value of 16 Voices is not enough to give you a sufficient Graph to work with. (Pic04 Graph Max Value)
Press OK to view the Graph with updated Graph Max values. After completing one run and getting through the finish line, you can stop the Capture. The Graph in the Capture should look similar to this. (Pic05 Number of Voices Physical)
As you can see, there is a small Voice Spike every 2,5 seconds with a short increase of about 20 additional Voices. Move the white cursor over to one of these moments in the Capture timeline and look closer at the list of Voices that are being played back. You can see that there are quite a handful of Fx Objects playing simultaneously. These Fx Objects are used for Setdressing, like sparks, water for the hydrants and fire for burning vehicles. (Pic06 Voice Spike)
Go to the Designer Layout and look at one of the Sound SFX Objects within the Fire or Water Random Containers of the Setdressing Actor-Mixer. You’ll discover that they have a file length of 5 seconds. (Pic07 Setdressing Objects)
Select one of the parent Objects and look at the Play Mode.
The Play Mode is set to Continuous Loop Infinite, with a logarithmic Xfade(power) Transition of 3 seconds. (Pic08 Transition Length) Think about this for a moment. Wwise has to perform a Transition every 3 seconds. There is the first Transition into the new sound file in the beginning of a file, and a second Transition into the next new sound file being randomly selected at the end of a file, which means that one file would have to be 6 seconds long in order for this Transition to follow through correctly. Because of your file lengths being 5 seconds, Wwise automatically adjusts the Transition internally to 2,5 seconds. So there is a correlation between the Transitions for the Setdressing Objects and the Voice Spike in the Number of Voices (physical), which both happens every 2,5 seconds. So what is causing this Spike?
The answer to this is simple. Every time a sound file transitions into another, there are actually two Voices needed to make that happen, because two sound files have to play back simultaneously. You can’t do anything about the Transition. You need the Transition for the sound to not be interrupted every time a new sound is being selected. But you can further optimize the Voice Count by lowering the Playback Priority for the Setdressing Objects depending on their distance to the Audio Listener. These sounds are not essential to gameplay and can be cut off completely every time the max. Distance to the Player Character, as defined by the Attenuations ShareSet, is exceeded.
Select the Fire, Sparks and Water Random Containers, right-click and Show in Multi Editor. Scroll all the way down to the Advanced Settings of the View.
Check the Ignore Parent Playback Limit and Limit Sound Instances check boxes, set a Sound Instance Limit of 3 instances with a global Scope. (Pic09 Playback Limit)
This means that 3 instances for the Fire, Sparks and Water Random Containers are allowed globally. Other Properties dictate, that whenever a new instance of these Objects is played back, the Voice for the oldest instance is killed. For this game this is not a good idea, because all Game Objects emitting these sounds start playback right in the beginning of the game, as soon as the level is loaded. There is only one Event with a play Action, so killing the oldest instance will ultimately kill Voices for most of the Game Objects, which will then never be heard. The better solution is, to use Virtual Voice Settings for Voices that exceed the Playback Limit, and Resume Voices On return to physical voice.
First select Use Virtual voice settings, then in the Virtual Voice Settings area check the Override Virtual Voice check box and pick Send to virtual voice for the Virtual voice behavior and Resume Voices On return to physical voice. (Pic10 Virtual Voice Behavior)
Now check the Override Priority and Use Priority Distance Factor check boxes, set the Priority to 30 and for the Offset at max distance Property set a value of -30 to reduce the Priority to zero for Setdressing Objects as the max. Distance is exceeded. (Pic11 Playback Priority)
This means, that whenever the player is near a Game Object emitting fire, sparks or water sounds, its Voice is played back, but as soon as the player moves further away again, the Voice is lowered in its Priority and sent to a Virtual Voice.
Now, start the game and a new Capture to see if the ocurring Voice Spike is resolved. After completing a run, you can indeed see that the number of physical Voices has dropped significantly, while the number of total Voices stays the same. You can notice the Virtual Property for the fire, sparks and water sounds checked in the Advanced Profiler. Perfect, now you have optimized your Platformer Game, resulting in an ultimately lower CPU usage. (Pic12 Optimizing Performance)