Best way to manage sounds on channels? [Solved]

Hi guys

I decided to split the sounds of my game into channels cause I wanted to give the player the option to mute either the sound effects or the music. Or both.

The thing is… my game is a space shooter. So you will be listening to the same sound effect a lot (Etc.player bullet, explosions on collision etc)

I wanted to keep all of the sound effects into 1-3 channels but then I realized that if another sound is playing on the same channel the sound that is currently playing will stop absurdly.

Is there a way to properly handle this without creating a lot of channels?

Or if there isn’t, how do I handle a PEW PEW sound effect once it starts going PEWPEPWEPEW? (Shooting rapidly)

Instead of using channels to control sound volume, how about you use a variable and, before making a sound, check if that variable was true. If it is true, then make a sound.

So I saw this post Having issues playing sounds in succession or at the same time - #2 by Silver-Streak from @Silver-Streak and did something similar.

image

Based on a really quick test it seems to work, somehow.
Only that now I have no idea how to mute everything without doing something stupid like this.

Hi guys,

If someone could help me with this I would really appreciate it

You can use a variable and a repeat event to make it set the volume for the selected channels (1/2/3/4…etc)
Example:

i have 2 sounds, one playing on channel 0 and one playing on channel 1
rather than using 2 change volume actions, we use a repeat event set to 2 (since i have 2 sounds) and then we set the change volume at channel (ChannelsCounter) variable, and then we add 1 to that variable.

Basically: this event will set the volume on channel 0 and 1, to 0

in your case, you do the same, but you replace the repeat number 2 with 21 (since you have 21 channels),
and for the condition

  • If the variable SOUND_SETTINGS.SoundEffects is false
  • Trigger once
2 Likes

Thank you!

Knew @VegeTato could help :")

Not sure why but trigger once wasn’t working for my case, so I did this.

Also for some weird reason, some of my sounds are not muting completely, especially the Pew sound effect. You can hear them for a slight moment before they turn silent, so I ended up creating a variable to control their sound volume…

image

Anytime <3
Well, the trigger once is to trigger the repeat event 1 time only when called (when your variable is false), am not sure how you set up this variable, but if the default value is false, then as soon as your game starts, this event will get triggered even though the sounds didn’t play yet, so make sure to trigger this event one time, at the correct time.

Its weird why the sound effect pew volume didn’t change to 0 as you mentioned, make sure that sound channel is actually counted in the variable (21 or below), if its channel is higher than 21, then you need to adjust your repeat event number.

In the final event you’re showing, you are playing the sound effect Pew in every single frame, that will cause so many problems, add trigger once, or a condition that trigger the sound effect every time its called, not in every single frame.

also, you are playing the sound effect on the variable channel, that’s incorrect.

your play sound actions, must look like this:

  • Play the sound Pew on the channel 0, vol:100 (or the volume you want), loop: no
  • Play the sound AAA on the channel 1, vol:100 (or the volume you want), loop: no
  • Play the sound ZZZ on the channel 2, vol:100 (or the volume you want), loop: no
    and so on…
    Do not set the channel to the variable, that variable is used only in the repeat event, you play the sounds normally on normal channel numbers.
2 Likes

Coming to this after one month cause I noticed that only the sounds made in Gdvelop are not muting properly. (Made with JFXR)

Wondering if anyone else is facing the same issue.

Genuinely curious.

Does anybody face the same issue?

Here you have save/load tutorial which plays both sound and music based on value of variables
Which are controlled by sliders
Maybe it will also fix your JFXR issue

Basically you use play sound on channel to play music
And play sound to play sounds
Where you can have different variables for different sounds
For example for game sounds you could have Save.Settings.GameSound
And for UI sounds Save.Settings.UISound

And now you would have 2 separate vars to control volume of each

1 Like

Thank you. I saw your post a while ago and was planning to use some of the events.

Finally, for my sound issue, since I have a lot of channels and I like to modify the volume of each sound in Gdevelop (Not sure if it’s the right way)

I did the below

And each sound effect has this as a volume control.

image

Finally, inner peace. Now there is perfect silence :relieved:

Sound volume cannot go beyond 100 cause its like 100%

Same as opacity can only go from 0 to 255

And idea for sound vs music
When you play sound using PLAY SOUND action
You are playing that sound WITHOUT ability to modify it on the fly
Think of it like setting a bullet with permanent force and you have NO WAY of stopping it or modifying the speed itself

Where PLAY SOUND ON CAHNNEL action
Allows you to play with whatever volume BUT now you can adjust volume of that channel

So imagine this you throw a ball and play sound is
Throw a ball with speed of SOME NUMBER

Where play sound on channel to play music is like
Throw a ball inside this room BUT now you can control air flow in that room

Well more or less