Thundermagnet
Member
So I have been trying to avoid having to ask for help, but this is so frustrating. Allow me to set the scene. In my game, I have a collection of audio files.
1) The sound effects, which are all assigned to the audio group "ag_Sfx", are all .wav files. I have verified this is correct.
2) The music, which are all assigned to the audio group "ag_music", are all .ogg files. I have verified this is correct.
2.5) (edit) The audio groups are loaded at the start of the game.
3) I have implemented volume adjustment sliders, and have verified that these correctly change the variables global.volumeMusic and global.volumeSfx. See the code for scr_playSound below, I have it output to the console whenever something plays.
4) The sliders work by looking at the volume level in the begin step and setting their x to where they should be, setting themselves to the mouse_x in the main step, and recalculating the volume in the end step.
5) In the slider's end step, they also set the audio group gain. The music one reads as such:
and the Sfx one reads as such:
So here is where it gets interesting.
6) There are two scripts for playing audio. The music one functions correctly, and sets the audio gain for the group correctly. (Yes I know I am setting audio gain twice, both in the slider and when something is played. It has no effect.) scr_music reads as follows:
and scr_playSound reads as follows:
Here is what I don't get. The music works as intended. The digging sound in my game, "snd_dig", is the only one that follows the volume of the slider, but only after a few times playing it. Adding that line about audio_sound_gain made a few others work some, but they too do not reflect the slider the vast majority of the time, even when console says it is playing at the slider volume. I have searched the whole project, these are the only things adjusting sound gain, and this is after I refactored the entire way audio works in the game. This isn't a matter of sound not playing, all files actually play. They just don't reflect the correct volume.
So is there something obvious about how audio groups work that I just do not know? Can they not handle small sound files well? Is there a better way to implement this?
EDIT/WORKAROUND:
After essentially giving up on audio groups, I am forcing it just to set the gain of whatever sound is playing, and not even bothering with the group. It works now. Music runs as a group, Sfx runs individually.
1) The sound effects, which are all assigned to the audio group "ag_Sfx", are all .wav files. I have verified this is correct.
2) The music, which are all assigned to the audio group "ag_music", are all .ogg files. I have verified this is correct.
2.5) (edit) The audio groups are loaded at the start of the game.
3) I have implemented volume adjustment sliders, and have verified that these correctly change the variables global.volumeMusic and global.volumeSfx. See the code for scr_playSound below, I have it output to the console whenever something plays.
4) The sliders work by looking at the volume level in the begin step and setting their x to where they should be, setting themselves to the mouse_x in the main step, and recalculating the volume in the end step.
5) In the slider's end step, they also set the audio group gain. The music one reads as such:
GML:
audio_group_set_gain(ag_music,global.volumeMusic,0);
GML:
audio_group_set_gain(ag_Sfx,global.volumeSfx,0);
6) There are two scripts for playing audio. The music one functions correctly, and sets the audio gain for the group correctly. (Yes I know I am setting audio gain twice, both in the slider and when something is played. It has no effect.) scr_music reads as follows:
GML:
song = argument0;
audio_stop_sound(snd_music_dillpickles); //Main levels
audio_stop_sound(snd_music_musicBoxRag); //Main Menu
audio_stop_sound(snd_music_minigameopener); //Hidden Minigame Opener
audio_stop_sound(snd_music_minigamemain); //Hidden Minigame Main Loop
if (global.isMuted)
{
audio_group_set_gain(ag_music,0,0);
}
else
{
audio_group_set_gain(ag_music,global.volumeMusic,0);
}
if (song = 0)
{
audio_play_sound(snd_music_dillpickles,1,true);
}
if (song = 1)
{
audio_play_sound(snd_music_musicBoxRag,1,true);
}
if (song = 2)
{
audio_play_sound(snd_music_minigameopener,1,false);
}
if (song = 3)
{
audio_play_sound(snd_music_minigamemain,1,true);
}
GML:
soundX = argument0;
if (global.isMuted)
{
audio_group_set_gain(ag_Sfx,0,0);
}
else
{
audio_group_set_gain(ag_Sfx,global.volumeSfx,0);
audio_sound_gain(soundX,global.volumeSfx,0); //This was here to test my theory of audio groups just not working right. It made it work more often, but that meant about 20% of the time, and only for specific sounds.
}
show_debug_message("Playing sound " + string(soundX) + " at the volume of " + string(global.volumeSfx)); //Just outputs to the console. When I set the slider to 50% for example, this reflects that, but the sound plays at full volume anyways.
audio_play_sound(soundX,2,false);
So is there something obvious about how audio groups work that I just do not know? Can they not handle small sound files well? Is there a better way to implement this?
EDIT/WORKAROUND:
After essentially giving up on audio groups, I am forcing it just to set the gain of whatever sound is playing, and not even bothering with the group. It works now. Music runs as a group, Sfx runs individually.
Last edited: