I am working in a Space Shooter game. Recently I added music and sound effects. When I added the sound effect for shooting, I made it play at a lower volume so that it doesn’t interfere with other sound effects.
When I have an enemy on the screen everything works fine. The problem is when enemies spawn on waves and their shooting becomes synchronized. The shooting sound effects are played together, and their volume add up to each other. As the number of enemies increase, the volume of the shooting becomes too loud and overshadows anything else.
Is there anything I can do to prevent the sound from adding up and going beyond the sound of a single effect?
No single correct fix, just a matter of being clever.
Could divide the volume by the number of enemies (and change as they die.) Could remember the last time “zap” was played, and not play it again for 0.1 seconds (make a playZap() function to handle this.) Or play them all, but reduce the volume if another was played recently. Could keep a weighted average of “zaps being played” and reduce new zap volume based on that.
Could also make several similar zap sounds, and randomize which is played, so overlapping zaps don’t sound as much like feedback.
When multiple copies of exactly the same sound are played at the same time, their amplitude will add up. You can greatly reduce this effect and also enhance your game’s sound in two simple ways:
- Make them not play at the exact same time. For each enemy, adding a small random amount to their weapon cooldown will spread out the sounds over time.
- Vary the sounds slightly. Randomizing the pitch of each sound just a little will reduce the sum volume and make it sound more interesting. Don’t overdo though, will sound stupid.
Hope that helps.