Logarithmic to linear

Giuseppe's icon

Good evening,
how can I convert a serie of logarithmic values in linear values? I guess I need to use an expression.

Thank you in advance for your help.

Roman Thilenius's icon

you can with something like [expr exp*a / epx*b ... ] ... or with pow -n and scaling ... but you will have to find the log "argument" by trial and error.

i sometimes run into this when modulating VST plug-ins ... in audio software people mostly use log 10, 20, 90 or 100 to create curves, so look for these four numbers first.

Roman Thilenius's icon

expr (exp($f1*log($f2))-1)/($f2-1) will get you a log n scale in the range of 0. - 1. to linear 0. - 1.; it is the opposite of expr log(($f1)* ($f2-1)+1)/log($f2).

Giuseppe's icon

Thank you. I need to scale the values of an external potentiometer, whose range goes from 196 to 3990.
May you please help me and tell which one should be the argument of the second inlet? My studies in maths are quite faraway.

Roman Thilenius's icon

$f1 is the value to be processed, $f2 is the base of the log function.

if you dont know what your device is sending, you have to _guess this base value.

so you would first map the range to 0.-1.:

zmap 196. to 3990. 0. 1.

and then "remove" the exponential scaling from the range:

expr (exp($f1*log($f2))-1)/($f2-1)

now you can scale or distort it again to whatever you need.

i hope it is right so, i usually answer posts without looking at maxmsp ;)

Giuseppe's icon

Thank you, I've find out. The base value was something less than 1.
Thanks again.