A clean and simple collection of scripts to simplify implementing background music, sound effects, and ambient loops in any project. Includes scripts for both playback and gain changes.
Benefits Now changing the background music or ambient loop can be accomplished with a single line of code!
//this will stop the currently playing bgm and start playing the next one
// and it will use the global gain setting for bgm!
//you can also just play the next bgm in the master list
Add variety to your one-shot sound effects with random pitch shifting!
//this will play the sound effect with a pitch between 2 semi-tones above and 2 semi-tones below with priority 100
//12 semi-tones is an octave which is the same as doubling the pitch
audio_sfx_play(sfx_explosion, 100, 2);
Integrated Gain Scaling
Have you ever made a volume control in GameMaker: Studio and noticed how the volume changes near zero sound huge and everything after 0.5 is basically imperciptible. This is because GameMaker: Studio's sound engine uses linear gain settings, but our ears perceive loudness as logarithmic. You could read up on psycho-acoustics, but basically scaling gain exponentially will produce better results.
While an exponential curve is ideal for gain scaling, it is somewhat overkill for what most games require. For a volume control that changes by 10% each step, cubic (power of 3) scaling is sufficient, You may want to try quartic (power of 4) scaling if the change is smaller.