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