How to use Sound Channels Properly and How to Stop Sounds Being Played Off Screen!

Hello everyone!

Heres a guide on how to use sound channels properly, avoiding most, if not all sound issues! …also, how to make it, so that sounds only play, when the sound source is on screen.

Down below theres a video for the people who perfer that format.

…and also! Credits to @Silver-Streak for giving me the idea about the channels!

The simple text version of using sound channels is:

  • Step 1: Create a global number variable, i.e. called “PlayerSounds”, this variable will be responsible for assigning the channels to the sounds being played.

  • Step 2: On the event where you play your sound, before playing the sound, add the action, "Change global number variable “PlayerSounds” “add” “1”.

  • Step 3: Change the “regular” “Play a sound” for “Play a Sound on a Channel” and on “Channel Identifier”, put our global variable “PlayerSounds”.

And your kinda done! This means that every time you play that sound, the variable “PlayerSounds” will add 1, making a new “Channel”, and then finally when the sound is played, its played on that “new Channel”.

Now all you need is to assign it a range and a way to reset the Global Number Vairable “PlayerSounds”.

For example, you can say that Player Sounds, use the channels 20 to 40.

In that case, under “Global Variables” youd change the initial value of “PlayerSounds” to 20.

Now youd go on your event sheet and create the event:
Condition: Global Number Variable “PlayerSounds” is >= 40.
Action: Change Global Number Vairbale “PlayerSounds” “Set to” 20.

That way, every time the channel “ID” goes over 40 it gets reset back to 20.

To apply this to the rest of your project, simply make different global variables for each group of sound and then assign it a range.

For example:
var “EnemySounds” channels 10 - 50
var “PlayerSounds” channels 51 - 70
var “MenuSounds” channels 71 - 80
var “GameMusic” channels 1 - 2

and so on…

Now for how to stop sounds from being played when they are off screen!

Thats easy, on the event where you play the sound, add the Condition, “Distance Between Two Objects”.

Now check for the distance between the “Player” and the “Source of the sound”, like and enemy, or explosion.

As for the “Distance”, set it to the highest number of your resolution devided by 2.

Meaning… if your using 1280x720, use the 1280 and devide it by 2, so… 640.

This is because usually your character is somewhere in the middle of the screen, and this way you kinda check if the source is on screen or not.

You can always adjust this value to taste, making it slightly bigger or smaller.

Heres the video explanation!