• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GML Master sound volume conversion: logarithmic <-> linear

2xd

Member
Hello.

In my old game made with Game Maker 8 I use the sound_global_volume to set the master sound volume (uses logarithmic scale for volume). I need a way to convert an entered (logarithmic/linear) sound value between the logarithmic scale and a linear scale (same scale as the one used in audio_master_gain), where in [0;1] a 0.5 value is 50% of maximum volume.

Thank you.
 

renex

Member
oh hello there! i've ran into this problem before.

GML:
#define logvol
///logvol(linvol)
//returns a log corrected volume value for legacy audio

return 1+0.3333*log10(max(0.001,argument0))

#define linvol
///linvol(logvol)
//returns a log corrected volume value for modern audio

return power(10,argument0*3-1)/100
 
Top