Making all audio lower its volume except for one

Kyon

Member
Hi all,
I want to make a sort of "audio zoom-in"-system. In which I can "zoom in" on certain audio sources.
How I want this is that basically all other sounds, except the one I'm on now fade a bit in volume, so the one I'm on stands out.
But I just can't wrap my head around how I would go and make something like that..
Anyone can push me in the right direction?


thanks!!
kyon
 

DaveInDev

Member
in the manual, search for "audio groups" and "audio_group_set_gain", that's probably what you're looking for, except if these zoomed-in sounds are always changing... (then you'll have to handle this manually, browsing every sound and setting the gain individually).
 

Alice

Toolmaker of Bucuresti
Forum Staff
Moderator
Keep in mind that audio_sound_play return the ID of the sound instance, and then you can operate on that individual sound being played.

So if you have audio source creating the sound instance like that:
GML:
played_sound = audio_sound_play(snd_some_sound, 0, false);
audio_sound_gain(played_sound, 0.5, 0); // make the played sound more silent immediately, until zoomed in
Then you can do the following when audio source is zoomed in on:
GML:
audio_sound_gain(played_sound, 1, 500);
And make it silent again when it's zoomed out of:
GML:
audio_sound_gain(played_sound, 0.5, 500);
I hope you can figure out the rest from that. ^^
 
Top