Convert linear Hz frequency float to logarithmic Hz frequency float
Hellooo :)
I'm trying to convert a single linear Hz frequency float output with a range of 0 to 22500 Hz into logarithmic Hz frequency float values.
Does anyone perhaps have an expr formula at the ready that could do the trick? Or any other tips to efficiently perform this calculation?
Cheers & thanks!
Someone asked something similar on FB recently... https://www.facebook.com/groups/maxforliveusers/permalink/2458533887619496/
In your case instead of starting with 10 and 2000 in the top right you probably want 0.001 and 22500.
This just shows different ways of converting values. Not sure if "logarithmic Hz frequency float values" means scaled in a range of 0. to 1. for output, but maybe you can glean enough tricks here to get going.

Thanks! But these don't seem directly helpful; just tried plugging in a couple of the expression formulae in the screenshot, but no dice.
Keep in mind, I don't need a range to convert, or an automation float to anchor anything. All I need is to translate the linear float frequency to a logarithmic float frequency.
One float in, one float out - that's it!
it is always a range you are distorting, because if there is no range defined, there is no anchor point for an arithmetic operation. and, even more problematic, a number system on the computer has a maximum range itself, which may not bee exceeded. :)
if you really want to convert hertz to hertz, the scaling factor for the min and max of the input range is 1 and so it does not matter that it is hertz, it could be apples.
performing a "log" or "exp" distortion for the range of 0 .- 1. (never sure about the correct terminology) can be done by
expr log(($f1)* ($f2-1)+1)/log($f2)
and if you need that for another range you can convert the range before and after the distortion
expr ($f1-$f2)/($f3-$f2) input, min, max
expr log(($f1)*($f2-1)+1)/log($f2) input, magic number
expr $f1*($f3-$f2)+$f2 input, min, max
of course for scaling 0. - n to 0. - m, a single multiplication is enough
expr (log((($f1/22050))*($f2-1)+1)/log($f2))*22050 input, magic number, max
Many thanks for this helpful clarification Roman.
I will give this a try tomorrow: expr log(($f1)* ($f2-1)+1)/log($f2)
But if $f1 is the linear Hertz input frequency in my case, just to be abundantly clear, what should I use for $f2? Should it be the minimum float value, ie. 0.00001, or the maximum float value, ie. 22500?
btw, if you use dspstate~ to find the nyquist, the chance is lower that you misspell and type 22500 instead of 22050. ;)
Okay, this got me most of the way there, thanks Roman! The last hurdle was to invert the decelerating curve for a slowly accelerating curve to provide more attention to lower frequency ranges than higher ones, whereas these without the inversion, your expr functions resulted in a decelerating curve (zipping past the musically crucial lower Hertz values only to linger above 15 kHz, which is not so useful a range). To remedy this, I had to place a pair of scale inversions on either side of the expr, using an $f2 value of 90, though that can be adjusted to taste. For anyone seeking a similar solution, I've pasted it here.