Nonlinear scaling of parameter values?
My dabblings in Max have improved greatly, and I am almost starting to feel comfortable about using Max, and a big thanks for that goes out to all of you! Without this forum I’d still be stuck with trying to get my head around the environment :)
But yeah, have another question to ask y’all (tried searching but no help) – I need to scale a parameter value (using 0. – 1. range for the input) to the range of 0.4 – 10.0, which itself is easy enough.. but the thing is, I want the value of 1. to be exactly at 50% of the parameter range (ie. 0.5 in the controlling input param)!!
Is there an easy way of getting such a range, or do I have to resort to building some kind of param eval logic to the knob? Something like "if value less than 1 -> scale like this / else scale like this"? Sounds like a hack to me.. there has to be a more elegant solution?
TIA & Cheers
Thanks for this!
EDIT: Alas, your kneepatches went over my head.. I’ll get a mate who’s a C programming whiz to explain a bit about expr stuff.. ATM I am using a function object with interpolation to do the scaling for me (as found in one of the patches in that brilliant thread) :p
depends on how you want the function to ‘look’. For a smooth function you could try something of the form
y = a + b*x^c
we get a and b from the constraints directly, a = 0.4, b = 9.6, then solving for the case when y=1, x=0.5, we get
1 = 0.4 + 9.6*0.5^c
0.6/9.8 = 0.5^c
c = ln(0.6/9.6)/ln(0.5)
which just happens to be c = 4
so your mapping is y = 0.4 + 9.6*x^4
which you can patch directly.
Here’s a little sample patch for you
----------begin_max5_patcher---------- 416.3ocyUFsaBCBEF95ZhuCDtbqqoTa00c2dNLKFZKprTglVZzMyd2GPG0pN i3Vmtafjy4G3+7A4v1gCbfI7MjJH3IvTfiyVYDGcLUDGS.G3J7lzbbkVHbdN mUuB59Ut4blfgWQz4dtjhyaSIkQY4DgdcHSTZlVJO40GPAc0xqEFwAc28J56 5cGE34ah2nU7VAow7JWgEPW.LAyV.AuXDVfEoKorEyJIohFsAiijaDXDBolh 7UiAxwtKpTVQBR4LBCmjqOCectOFNPMKmbsFXLxZYw1VoBxFsQf2C78BuXNF 7cbDcBNh9gbzF9ELYhFiOtie8NhtCD6MtePj+s.QQ5mXih9CQTAeMHzqWXT7 s.QH8qnvw8.h5wNS2jFSnIW2FSU4zLR4EzttUZakuqvOwSli3gUHHJ1T6t.T 34QP6shB1xirnVruKJoDl.Knbl9V7.j0r6vbJ6nOC0dTk3.PVwqKSM0joGLn iOyHUBJq8Hmt6GutpVRyxHr8pgLZkptxNycq8Fy2Jigt5FK1Je4e8AlM9J9+ os9cOuT8dkSeBzm357E -----------end_max5_patcher-----------
Or in one object: [expr pow($f1,4)*9.6+0.4]
You’ve got me there Luke :)
Wow! Much obliged for your assistance. You guys are the best!
Forums > MaxMSP