• 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 Issues with Sound Gain not Displaying in GUI

I've added a volume adjustment to a game, and all is working. The BGM and SFX gain is lowered. But, with the BGM sounds I have in the default group "audiogroup_default" and I set the gain by choosing a percent using "audio_group_set_gain(audiogroup_default, 0.50, 0);" and so on. and I get the gain levelI with "current_volume_ = string(audio_sound_get_gain(audiogroup_default));" and draw it to the GUI with "draw_text_ext_transformed(320, 70, "BGM Volume " + current_volume_ + "%", 10, 1000, text_scale_, text_scale_, 0);"

This all works fine. But when I do the exact method with the SFX group that I made "SFX_Group". The gain is changed, but it doesn't display the gain level on the GUI. It just shows "0.50".

Is it because the "audio_sound_get_gain(audiogroup_default)" doesn't in fact work for sound groups? and thinks the "audiogroup_default" is not a real group but just sounds?
 
Is it because the "audio_sound_get_gain(audiogroup_default)" doesn't in fact work for sound groups? and thinks the "audiogroup_default" is not a real group but just sounds?
Most likely as the function audio_sound_get_gain does not take an audio group as the parameter, it takes the index of an actual sound. It is probably just a coincidence that the index id of the group also corresponds to a sound index id too. There does not appear to be a function to get the gain of an audio group, even though there is one to set the gain of the audio group.
 
Most likely as the function audio_sound_get_gain does not take an audio group as the parameter, it takes the index of an actual sound. It is probably just a coincidence that the index id of the group also corresponds to a sound index id too. There does not appear to be a function to get the gain of an audio group, even though there is one to set the gain of the audio group.
What would be the best way to display the gain of the SFX_Group then? Could I store the sounds in a variable and put in into the audio_sound_get_gain(SFX_Sounds);
 

FoxyOfJungle

Kazan Games
What would be the best way to display the gain of the SFX_Group then? Could I store the sounds in a variable and put in into the audio_sound_get_gain(SFX_Sounds);
You can use global variables.
When changing the volume of a group, you leave the variable equal to the volume of the group. And to show the volume, just draw this variable.
If you want to save the game, you save this variable in the file, and when loading, load the variable and from the loaded variable, you use audio_group_set_gain().

I think there should be an audio_group_get_gain() function
 
You can use global variables.
When changing the volume of a group, you leave the variable equal to the volume of the group. And to show the volume, just draw this variable.
If you want to save the game, you save this variable in the file, and when loading, load the variable and from the loaded variable, you use audio_group_set_gain().

I think there should be an audio_group_get_gain() function
Well, I have the volume setting working, it's just that I can't seem to find a way to draw it to the GUI like I can with the audio_sound_get_gain(audiogroup_default);

I've decided to use just a custom string with a switch statement based on the gain of the group since I can use audio_group_set_gain(SFX_Group); like current_volume_ = 100% and draw_text(x, y, current_volume_);

But this could have problems since I'm telling it what percent to display. So, if there was a glitch, it could show 100% but, it could be 50% or something.
 
Last edited:
Top