• Hey! Guest! The 39th GMC Jam will take place between November 26th, 12:00 UTC and November 30th, 12:00 UTC. Why not join in! Click here to find out more!

GMS 2 Question about audio_play_sound volume stacking



My question is in regard of high volume when you play an audio repeatedly...
In my game you can kill lots of monsters, and the cut sound effect, hit sound effect and dying sound effect all get on eachother making a really big mess with the volume...

My solution was to make global variables to count how many times the sound has played over a short period, so it can only play, let's say like 3 times if they go out instantaneously. Then the counter goes down. All of this is to get myself not hearing the same sound 15 times if I kill 15 monsters at the same exact moment.

But is there another way to achieve this without using global variables?

Thank you!


Have you looked into audio_channel_num? That sets a cap on the total number of sounds that can play at once. Just make sure you set the priorities of all of the sounds so you don't cut out the music or really important effects.


I see, thanks for the answers! Sadly the audio_channel_num is not the thing that I need. I will make my own way through code


Forum Staff
To avoid "ghosting" of sounds, I keep my own lists of active sound instances (which are removed once they stop playing), and each list (one per sound) has its own limit of how many instances can be active at a time. If a new one is to be played and the maximum has already been reached, the oldest one is stopped and removed, then the new one is played. This way, there will be, say, at most three explosions audible at the same time, but each new one will definitely be audible and not just randomly remain silent.