Skip to content

Conversation

@phevosccp
Copy link
Collaborator

@phevosccp phevosccp commented Jan 16, 2025

Description

This PR introduces the ability to force a re-cluster of all audio objects when the distance threshold RTPC is changed in real-time.
Previously for a new threshold value to take effect, either the game-scene would have to change completely, or the plugin should be manually re-initialized to the bus. This means that the user would have to wait for all existing clusters to die so new ones are formed with the new assigned threshold value. Of course this is not optimal and can create the impression that the UI slider is not functional.

To solve this, we clear existing structures that hold cluster information and mark them as non-clustered, so they are forced to be re-clustered in the next frame. Keep in mind though, that the existing output objects will not be deleted with a slider change, as this would introduce potential crashes or sounds to disappear.

Technical Details

  • Introduced a reset method that resets the internal state of the KMeans algorithm.
  • In the ObjectClusterFX we are checking for changes in the threshold RTPC, we force re-clustering.
  • Introduced the method ForceReclustering() which clears the member variable m_clusters the AkMixerInputMap structure (which is the most important for the re-clustering to happen) and finally reset() the internal state of KMeans.

Testing:

To test these changes, I recommend the following steps:

  • Remove the plugin from everywhere instantiated so it doesn't interfere.
  • Attach the plugin only on the Master bus with the minimum threshold of 1.
  • Create a fight scene with multiple spatial audio objects
  • As you Monitor the system audio object consumption, increase the slider to its max value.

You should see the audio object consumption being reduced drastically.

The GIF below shows a scene with 40 spawned enemies, initially the audio object consumption is 70-80 objects, when the threshold increases it drops to 38-40 depending on the events, which is the expected value.

Wwise_sEAtbhhtJC

and on another example with 20 enemies:

slider.change.mp4

@phevosccp phevosccp marked this pull request as ready for review January 16, 2025 11:42
Copy link
Collaborator

@ccp-zoetrope ccp-zoetrope left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very useful and looks good! Free free to merge into main.

@phevosccp phevosccp merged commit bcb1f98 into main Jan 17, 2025
@phevosccp phevosccp deleted the force-reclustering branch January 17, 2025 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants