Re-mapping a range of numbers – add your tricks here….

Often the most useful things are the simplest building blocks. One of the most fundamental must be ways of converting a range of numbers to create more interesting and useful curves etc. I thought a nice post would be to collect everyone’s thoughts and tricks on this idea. See the included patch and all will become clear. Please add anything you find useful and re-post.

– Pasted Max Patch, click to expand. –

Copy all of the following text. Then, in Max, select New From Clipboard.

i have a bigger set of abstractions which can distort a range of numbers,
as i found that you simply need that to build GUI stuff.

the most basic version uses different functions such as pow, exp, log,
tanh and so on, and the input and output ranges are always 0. – 1.

then there are abstractions which work with a user-given range. they
accept arguments like "107 250" and perform the above functions on the
chosen input range – as well as output a curve of that range.

further abstractions work bipolar – the input range is split in the middle,
and calculations like exp or log are done to both halves individually, in opposite
direction.

last but not least you could take a range of 0-20 and perform such a distortion
only to 0-12 and leave the rest of the range as it is: linear.

and where mathematical stuff wont work anymore, there is always table or coll
to translate n to m.

some of them do now need 3 times more CPU than before, but this way the stuff is easier to
extend or change.

the MAP objects distort a range of n-m and map it to another range, the MAKE objects
take a range of n-m and created distorted output of the same range, the DO objects
work on a range of 0. – 1.

110.map just maps linear, 110.map-down maps from n-m to 0.-1. and 110.map-up the
other way round.

the log, exp, pow, and trunc distortions require an argument, the other functions dont.
this argument always has to follow the range arguments.
example: in [110.map-log 0 127 1 50 90] the 90 belongs to the "log".

Attachments:

Attachments:

I just finished an external that re-maps numbers (or lists) using several different interpolation methods. Currently Bézier, piecewise linear, polinomial and spline interpolations are supported, and I plan to extend it with more complex things as well, like Hermite-interpolation or exponential fit.

Roman, there appears to be a missing external in your bundled goodies. Something called 110.isolate… the absence of which is causing many of the other externals and many of your examples to brick. You don’t by any chance have that handy do you? Can you post it?

oh my goodness. yes, that is because "isolate" is a new abstraction from 2011, i was using something else before.

[110.isolate] is a bit like [split] but has three outputs: the center value of the range, greater than that, and smaller like that. this is required for _some of the possible operations you can do when distorting a range of numbers bipolar. the idea is to leave the center value untouched while distorting the rest.

the reason why it is required is, last but not least, the fact that [expr] has that fascistic size limit for the input string, so somewhere there has to be an interface between parts of the code.

Attachments:

What I would love to see is an upgrade of [line] that incorporates all of Robert Penner’s easing algorithm. I think I’ve seen javascript or expr-based abstractions based on them but a fast, native object would be awesome. Every animation package I know, from ActionScript to hundreds of javascript frameworks, use this same set. http://www.robertpenner.com/easing/

I’d love that, too. It’s one of the few remaining bits I miss from vvvv. jit.anim.drive does good easing, but sometimes you just want a single number being all rubbery and nice.

I’ve been messing about with [expr sin($f1*6.28318531*[number of oscillations]] for a couple of weeks now, really loving it.
We have a player in our group, who plays the wacom tablet for some granular stuff, and we’re doing some data visualisation. Well, turns out his single XYZ point wasn’t too jazzy, so we spruced it up with some sin(x) there, and it really helped.

just catching up this interested topic. i already posted something in an another topic, and Brendan kindly answer it… but i don’t get it work

I am willing to re mapped incoming data let say from a range of – 50 to 50, to an output with a ‘curve’ that gives more importance to data as it gets closer to 0 (from both sides). I tried to adapt the sadam.split, but i don’t get 0 for 0. I am missing something