scaling maths help

Oct 11, 2013 at 7:39am

scaling maths help

Help! I’m looking for a way of scaling values to make a better/different feeling volume control. (in this case from lemur values 0. – 1. into [live.gain~], but also potentially between other controllers & objects).

[scale] doesn’t help – I don’t want exponential, but something more like log without the sudden drop at the end, however my maths & skills with [expr] are lacking, and [atodb] not quite what I want. Surely there’s a way of creating a log-like curve with control over the slope?

#267757
Oct 11, 2013 at 10:38am

You can try with this exp scale :
change the value of exponent to get the curve you like !
However these are exponential curves…

<code>

– Pasted Max Patch, click to expand. –

</code>

#267773
Oct 11, 2013 at 12:05pm

your idea is right to use some extra bits on the lower end of a GUI control, and not only a linear to log conversion.

thats what most commercial audio apps do.

to do so, i would split the control data somewhere at 5-10% and then apply a different curve onto the lower part. just try out different methodss until you like the result.

you can also use a slower interpolation time (of say 150 ms, as opposed to the rest of the slider, where you would use 30-40 ms) on the low end part, so that you do not get those “drops” between “slider at -90″ and “slider at one pixel above “-90″.

-110

#267781
Oct 11, 2013 at 3:34pm

try this– uses quadratic remapping i think (been a while since i patched it) but works well for me when using a midi controller (0-127)

<code>

– Pasted Max Patch, click to expand. –

</code>

#267793
Oct 11, 2013 at 8:20pm

In simple descriptive terms, what kind of curve do you want? In other words, in relation to the linear tracking of a given slider input, what kind of output motion do you want? If it’s not linear, then it will be slower or faster than the input at different points from 0 to 1. Do you want more of a gradual start with a faster finish? A quicker start with a slower finish? Or a maybe a mixture.. more of a slow start with a faster middle that slows down again at the end? etc. For other applications you can also make more complex motions like bouncing, snapping, stepping, etc.

Check out Robert Penner’s easing algorithms. It’s a great sampling of many basic forms of linear interpolation. Examples here:

http://www.timotheegroleau.com/Flash/experiments/easing_function_generator.htm

http://sol.gfxile.net/interpolation/

http://www.gizma.com/easing/

If you are interested in any of them, I ported all of his easing equations into Max. They work great and offer many options.

Roman also has a pretty kick ass collection of abstractions available on this thread: http://cycling74.com/forums/topic/re-mapping-a-range-of-numbers-add-your-tricks-here/.. with several options for mapping and scaling the range of the output.

#267811
Oct 11, 2013 at 8:27pm

This is what I used as the basis for porting his equations into Max..

https://github.com/warrenm/AHEasing/blob/master/AHEasing/easing.c

It’s pretty straightforward using expr & if.

#267812
Oct 11, 2013 at 8:31pm

floating point, your abstraction contains a non-standard object named QuadMapper… post it so that we may absorb it.

#267813
Oct 11, 2013 at 8:50pm

whoops, didn’t realise I was so organised and actually made an abstraction–

<code>

– Pasted Max Patch, click to expand. –

</code>

#267817
Oct 12, 2013 at 1:08am

Thanks to everyone for your input – there is lots for me to explore but it will be a day or two before I can get back to max and to absorb this. I think I might want something like an ‘s-curve’ – flatter at top and bottom and steeper in the middle, but I’ll just have to try options to see what they sound like. I like Roman’s idea of splitting the data & applying different interpolation.

#267828
Oct 12, 2013 at 2:49am

Hi, i’m having similar problems, so i reckon it’s ok if i post here. (please tell me if you think i should open another topic)
i am observing a live track’s output meter and i want to display the level on a meter~ so i can have it on the mira.frame. i tried several thing to match the meter~ and the live.meter~ without success. Any help would be awesome !

#267832
Oct 12, 2013 at 7:54am

I think I might want something like an ‘s-curve’

Sounds like a job for half-cosine-man.

Something like the following, assuming input and output in the unit range: [expr 0.5*(1-cos($f1*1.570796))].

Caveat: off the cuff, untested. If you grok what’s going on, you can fix any mistakes I’ve made. If you don’t grok, ask and someone (possibly yours truly) will explain.

RECTO: the factor inside the cos() should be 3.141596, of course.

#267852
Oct 12, 2013 at 3:28pm

I think I might want something like an ‘s-curve’ – flatter at top and bottom and steeper in the middle, but I’ll just have to try options to see what they sound like.

Here ya go…

– Pasted Max Patch, click to expand. –
#267878
Oct 13, 2013 at 12:54am

Thanks metamax – beautiful implementation & very clear to see the results. Looking forward to getting into the studio to listen to all of these solutions.

#267898
Oct 16, 2013 at 5:52am

i’d like to thank you as well, metamax. It seems to be very useful maths expressions !

#268197
Oct 16, 2013 at 6:02am

Cool.. glad it helped.

You guys should really check out Roman’s collection… His explanation is in the thread link I posted above. His kung fu is strong.

110.mapWIN.zip

110.defarg.mxb.zip

kneestuffwin.zip

110.isolate.mxb_.zip

#268198

You must be logged in to reply to this topic.