i doubt you can create this in dnd
but in gml i would create a 'Listener' object that listens
- whether a background music is playing, and if it is
- whether any other sounds are playing ("for" loop through an array of all possible sound indexes., and if any sound is
SIMPLE WAY: (instant drop in volume)
-------------------------------------------------------------
If those checks are true, set the volume of background music using
audio_sound_gain(sound_name, new_gain_value(0-1), time_in_ms_to_apply_gain);
If those checks are false, set the volume of background music to default value
LONGER WAY: (smoother fade of volume drop, for this you'd have declared two extra variables at the start, "duck" and "min_gain_value")
-------------------------------------------------------------
If those checks are true, trigger 'duck' flag variable to TRUE
- check if gain of background music is equal to min_gain_value
- if it is do nothing
- if it's not decrease it by a certain amount each step
If those checks are false, restore 'duck' variable to FALSE
- check if gain of background music is equal to original value
- if it is do nothing
- if it's not increase it by a certain amount each step
///////////////////////////////////////////////////////////////////
Some tips:
- Use linear interpolation(lerp) or anything similar to achieve a smooth fade-in out effect
- Gain in gamemaker is measured from 0 to 1, 0 = silence. 1 = full volume. Use logarithmic functions to achieve required volume in float value.
0.5 is not half the volume
~ -6dB is half the volume