Forums > MaxMSP

scaling maths help

October 11, 2013 | 7:39 am

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?


October 11, 2013 | 10:38 am

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>


October 11, 2013 | 12:05 pm

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


October 11, 2013 | 3:34 pm

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>


October 11, 2013 | 8:20 pm

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.


October 11, 2013 | 8:27 pm

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.


October 11, 2013 | 8:31 pm

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


October 11, 2013 | 8:50 pm

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

<code>

– Pasted Max Patch, click to expand. –

</code>


October 12, 2013 | 1:08 am

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.


October 12, 2013 | 2:49 am

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 !


October 12, 2013 | 7:54 am

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.


October 12, 2013 | 3:28 pm

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. –

October 13, 2013 | 12:54 am

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


October 16, 2013 | 5:52 am

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


October 16, 2013 | 6:02 am

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


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