scaling maths help

alistair macdonald's icon

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?

Etienne's icon
Max Patch
Copy patch and select New From Clipboard in Max.

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

Roman Thilenius's icon

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

Floating Point's icon
Max Patch
Copy patch and select New From Clipboard in Max.

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)

metamax's icon

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:

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: https://cycling74.com/forums/re-mapping-a-range-of-numbers-add-your-tricks-here/.. with several options for mapping and scaling the range of the output.

metamax's icon

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

It's pretty straightforward using expr & if.

metamax's icon

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

Floating Point's icon
Max Patch
Copy patch and select New From Clipboard in Max.

whoops, didn't realise I was so organised and actually made an abstraction--

alistair macdonald's icon

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.

chapelier fou's icon

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 !

Peter Castine's icon

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.

metamax's icon

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

Max Patch
Copy patch and select New From Clipboard in Max.

alistair macdonald's icon

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

chapelier fou's icon

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

metamax's icon

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.