Forums > MaxMSP

Logarithmic Conversion


Mar 30 2013 | 8:07 pm

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!

Mar 30 2013 | 10:15 pm

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:
http://www.cycling74.com/forums/topic.php?id=36275


-- Pasted Max Patch, click to expand. --


ak
Mar 30 2013 | 10:29 pm

yet another way:
[ftom] -> [scale 0. 127. 0. 50.]

Mar 31 2013 | 8:23 am

or to be more precise:
[ftom] -> [scale 15.486821 174.939407 0. 50.]

Apr 01 2013 | 5:56 am

[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

Apr 01 2013 | 11:48 pm

Thank you all!

Apr 01 2013 | 11:55 pm

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.

Apr 02 2013 | 3:26 am

eh –but hey it is the right midi note for 200,000 hz…. :-)

Apr 02 2013 | 4:47 am

Ultrasonic MIDI for your next bat-only concert…

Viewing 9 posts - 1 through 9 (of 9 total)

Forums > MaxMSP