GameMaker Adjust Sound Effect and Music Volume Independently

Almost all video games allow the player to adjust sound effect volume and music volume independently. However, I haven't been able to find a good way to go about programming this, and I'd like to sort it out before diving too deep into importing sound assets. Turning off sound effects or music entirely is pretty easy by loading/unloading audio groups. However, changing audio group gain completely ruins any careful mixing that was done in the sound editor. Setting master gain doesn't really help here either.

Has anyone else figured out a good way to go about this, or should I just resort to the on/off option for sound and music rather than a slider?
Thanks
 
You just need to sort your audio files in audio groups.
One audio group is SFX and the other one is the music.
You can add more as you need.
I think this only works for completely muting an audio group or turning it back on, because the only function available for changing audio group volume is audio_group_set_gain, which removes any manual mixing done in the sound editor ("[volume] will be overridden by any change to the gain using the audio functions").
 

kburkhart84

Firehammer Games
My Firehammer Audio system handles exactly that(among several other things). If you don't need the other things it does you can at the least look and see how I handled the things you are looking for. That said, I wouldn't be surprised if you find good use with the other things it offers as well.

The idea is that you have a separate function for playing sounds. That function would change the volume of a sound based on if it is music/GUI/effect/etc... upon playing it each time. My system supports multiple sound groups as well so you can have GUI be one volume and sound effects be another, and something like voice sounds be yet another, or whatever grouping you need.
 
I think this only works for completely muting an audio group or turning it back on, because the only function available for changing audio group volume is audio_group_set_gain, which removes any manual mixing done in the sound editor ("[volume] will be overridden by any change to the gain using the audio functions").
You can think whatever you want without a problem, but it still won't make me wrong and make you right. These are the joys of computer science. ;)
If your basic gain is mixed all over the place and doesn't fit together at unity, that's a whole other problem that sources when you mixed and bounced your sound files.
 
You can think whatever you want without a problem, but it still won't make me wrong and make you right. These are the joys of computer science. ;)
If your basic gain is mixed all over the place and doesn't fit together at unity, that's a whole other problem that sources when you mixed and bounced your sound files.
I understand that I can make a slider using audio_group_set_gain. My issue is that I am using Game Maker's built in mixing capabilities in the sound editor (which I think is reasonable, you can't know how loud things should be till you see them in action). But there seems to be no way to adjust the gain of a group of sounds that would retain the relative volume between sounds as defined in the sound editor/sound group mixer. In theory I could make an audio group for every level loudness of sound effect (quiet sfx, medium sfx, loud sfx) and then use audio_group_set_gain to adjust those groups. That wouldn't be a crazy amount of work, it's just slightly annoying that there's no way to group them and retain the mix (unless I'm missing something).
 

Slyddar

Member
That wouldn't be a crazy amount of work, it's just slightly annoying that there's no way to group them and retain the mix (unless I'm missing something).
In theory you could use tags to group sound assets together and then retrieve the array of those sounds, looping through it and setting the gain when you need to control the audio. You could have tags for rough percentiles, so 50%, 55%, etc. When setting the master gain, you also retrieve the tag array for each group, and set each sound in the group to the master gain * the tag value, e.g. gain * .5 for the 50% tag group.

Another option is you store the sound asset id and the gain for each sound, and when you set the master gain, you loop through each sound and multiply the master gain and the stored gain in order to set the sound accordingly.
 
Last edited:
Top