What algorithms could I use for audio volume level? [closed]

human perception in general is logarithmic, also when it comes to things as luminosity, etc. … this enables us to register small changes to small “input signals” of our environement, or to put it another way: to always percieve a change of a perceivable physical quantity in relation to its value …

thus, you should modify the volume to grow exponentially, like this:

y = (Math.exp(x)-1)/(Math.E-1)

you can try other bases as well:

y = (Math.pow(base,x)-1)/(base-1)

the bigger the value of base is, the stronger the effect, the slower volume starts growing in the beginning and the faster it grows in the end …

a slighty simpler approach, giving you similar results (you are only in the interval between 0 and 1, so approximations are quite simple, actually), is to exponantiate the original value, as

y = Math.pow(x, exp);

for exp bigger than 1, the effect is, that the output (i.e. the volume in you case) first goes up slower, and then faster towards the end … this is very similar to exponential functions … the bigger exp, the stronger the effect …

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)