Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not play too many sounds at once #749

Open
Indy2222 opened this issue Sep 26, 2023 · 3 comments
Open

Do not play too many sounds at once #749

Indy2222 opened this issue Sep 26, 2023 · 3 comments

Comments

@Indy2222
Copy link
Collaborator

For example during destruction of a large number of entities, a big number of sounds may be played at parallel. Limit the number of sounds started during a single tick (and ignore the rest).

@Indy2222 Indy2222 added this to the PoC (version 0.1) milestone Sep 26, 2023
@Zakru
Copy link
Contributor

Zakru commented Sep 30, 2023

The obvious approach is to aggregate the sound events over a tick instead of starting playback for each event. The ambiguous part is how to play it back. A naive way would be to average the positions and play the sound once at that point, but that would begin to present problems when there's fighting all around the map, so that wouldn't work. But I think there are some things you could do to avoid the issues.

One way would be to only count the sounds that are currently audible in the player's view. That way the sound would definitely play in a logical area, but it would mean when you pan to another area, no sounds would be playing. Optionally we could keep track of the positions that every aggregated playback instance came from, and adjust the playback based on the average in view every frame, instead of ignoring everything out of view at the time of the event.

An improvement regardless could be to scoop up bunches of the event based on a radius for example, to reduce the density so we have less information to deal with.

@JackCrumpLeys
Copy link
Contributor

How about the closer the sound the higher the priority and we play the top 25 sounds. Maybe also decrease priority for duplicate sounds.

@Indy2222
Copy link
Collaborator Author

How about the closer the sound the higher the priority and we play the top 25 sounds. Maybe also decrease priority for duplicate sounds.

Prioritizing based on camera distance at the time of the sound start makes sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants