13
\$\begingroup\$

I am developing an RTS game with boats, the boats can shoot very frequently and I am having a hard time dealing with the explosion sounds. I am using three.js and the audio API it has that uses the web audio API behind the scenes. The thing is I can't simply tell three.js to play each sound individually because the final sound stutters a lot.

What I am doing currently is grouping the sounds for each Xms and then making an average of the position of all explosions and setting the volume with K*N, where K is just some constant and N is the number of explosions.

The results are not very good. And I was wondering if there are other techniques I could use to handle that many equal sounds being played at the same time.

The game can be seen here: https://archpelagus.glmachado.com/

\$\endgroup\$
2
  • 1
    \$\begingroup\$ You may be interested in How can I make explosions sound more harmonious? which also deals with the problem of many overlapping explosion effects sounding bad. \$\endgroup\$
    – DMGregory
    Commented Oct 22 at 4:11
  • 1
    \$\begingroup\$ Side note: when playing many sounds at once, the typical problem is extreme volume spikes (having sounds that are some multiple louder than everything else is a bad player experience and could damage people's hearing). You should absolutely do audio balancing to prevent that (or opt for other solutions like limiting the number of sounds that can play at once). I can't tell you how to do that in three.js though. There are quite a few indie games that very clearly haven't done audio balancing despite playing many sounds at once (so it ends up being excessively loud). \$\endgroup\$
    – NotThatGuy
    Commented Oct 24 at 17:46

1 Answer 1

18
\$\begingroup\$

There are several standard solutions for this type of situation:

  • Limit how many sound effects can play. You can do this temporally (don't allow more than X effects to play per second, or have a short cooldown between effects), locally (don't play an effect if there are already at least X effects playing within Y distance), or both. This means some visual effects won't have corresponding SFX, but this isn't very noticeable when many units are firing at once (provided you've tuned the numbers well).
  • When units fire in bursts, make the burst a single clip. So for example, if a unit fires a burst of 4 shots, use one clip with four shots in it, rather than playing 4 separate clips.
  • Rather than playing individual sound effects for each unit, combine sound effects when there's a lot of action going on. So for example, if 25 boats are shooting at each other, rather than playing 25 separate sound effects, you might have 5 clips that each contain 5 explosions. This means audio is less positional, and SFX won't be perfectly synchronized with graphics, but that's usually not noticeable when many units are firing at once.
  • When the action gets very intense, switch to a looping ambient track of battle noises (sort of like this but obviously tailored to the type of action in your game).

In any case where multiple sound effects are combined into one clip - this is something that is done ahead of time and shipped with the game; you don't dynamically generate new sound effects on the fly, because that would cause its own performance issues.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .