Dibidoolandas
Member
I'll try to describe this as simply as possibly because there are a lot of moving parts. I want to control music and sound at separate volumes in my game, and I use a global variable and script to do that, vol_music and vol_sound. Every time I call a sound, I run the script scr_sound(snd_example); which runs this:
Same thing for music. Pretty simple.
Anyways I'm working on my menu where you can adjust the music/sound volume levels, and I've noticed a weird thing that's tough to describe. The sound is adjusting, but not adjusting by the amount I want. Here's the code I'm running when you hit the button to adjust it up one notch (out of ten):
The goal of this is to change that global variable, vol_music, by 1/10th of its max value, and then set the gain for the menu background music to that new volume level as an indicator to the player of how loud the music is. Like I said though, if I run the game at, say, 0.2 starting vol_music (so 2/10s of its max volume), and then I go into adjust it 1 notch to the right, it adjusts the volume and actually makes it quieter than it was before. Then it builds up from there. If I max it out at this point it's not as loud as it would be if I played the sound fresh at vol_music = 1. So what seems to be happening to me is audio_sound_gain is only adjusting it to a fraction of whatever it was already playing at.
I did a test using a debug message for vol_music and audio_sound_get_gain for the background music. vol_music traced correctly at 0.2 (or whatever I set it to in the init), but audio_sound_get_gain for the music file playing traced itself as 1. I know for a fact it's not playing at full volume, so what is the deal here? When I run the music with that script, and the script immediately sets the gain, shouldn't I be able to accurately trace that?
I know this is a lot and probably no one knows what I'm talking about, but I'm just scratching my head at this point. Any help is greatly appreciated.
GML:
sound = argument0;
var playsound = audio_play_sound(sound, 1, false);
audio_sound_gain(playsound, vol_sound, 0);
Anyways I'm working on my menu where you can adjust the music/sound volume levels, and I've noticed a weird thing that's tough to describe. The sound is adjusting, but not adjusting by the amount I want. Here's the code I'm running when you hit the button to adjust it up one notch (out of ten):
GML:
vol_music += 0.1;
vol_music = clamp(vol_music, 0, 1);
if (audio_is_playing(snd_mus_title_1))
{
audio_sound_gain(snd_mus_title_1, vol_music, 0);
}
I did a test using a debug message for vol_music and audio_sound_get_gain for the background music. vol_music traced correctly at 0.2 (or whatever I set it to in the init), but audio_sound_get_gain for the music file playing traced itself as 1. I know for a fact it's not playing at full volume, so what is the deal here? When I run the music with that script, and the script immediately sets the gain, shouldn't I be able to accurately trace that?
I know this is a lot and probably no one knows what I'm talking about, but I'm just scratching my head at this point. Any help is greatly appreciated.