Logarithmic Conversion
Hi,
I'm trying to convert the frequency range 20-20000Hz to 0-50 logarithmically, for frequency based panning but I am struggling to do so.
Can any maths gurus out there give me a hand? I am just new to Max!
Thanks!
not a maths guru but here is a little abstraction i made a while ago. You can initialise the base value of your mapping with an argument.
Just be sure to stay in the 0. to 1. range at the input and the output will also be in that range.
Roman thilenius also posted a (didnt try it but believe so) great collection of number mapping stuff in this thread:
https://cycling74.com/forums/re-mapping-a-range-of-numbers-add-your-tricks-here
yet another way:
[ftom] -> [scale 0. 127. 0. 50.]
or to be more precise:
[ftom] -> [scale 15.486821 174.939407 0. 50.]
[expr ((((log10($f1/8.175798)/log10(1.0594633))-$f2)/($f3-$f2))*($f5-$f4))+$f4]
[expr ((((log10($f1/8.175798)/log10(1.0594633))-20)/(20000-20))*(50-0))+0]
[expr ((((log10($f1/8.175798)/log10(1.0594633))-20)/19980)*50)]
-110
Thank you all!
Terry, I don't mean to be rude but 20000 Hz converted to MIDI is 135 not 174.939.
Going to give Roman's solution a try. I imagine it will be correct.
eh --but hey it is the right midi note for 200,000 hz.... :-)
Ultrasonic MIDI for your next bat-only concert...