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

Mark Durham's icon

Hi all,

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

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.

brendan mccloskey's icon

Excellent idea Mark; pre-empting many future posts too. I'll have a HD clear out and see what I can find.

MIB's icon

nice. never occurred to me to use function in this way! new trick learned, thanks!!

Roman Thilenius's icon

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.

-110

2892.mlogbipolar.jpg
jpg
EMV's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Nice idea. Here's some more.

dtr's icon

good stuff! keep m coming :)

i'll add mine when i bump into them...

Mark Durham's icon

Yes, thanks for all your additions.

Roman, are your abstractions available online? or can you add some here? I really like the idea of splitting the range across different equations, will give this a try when I've got time.

$Adam's icon

Hi,

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

another solution for splitted-range mapping: a combo with [sadam.split] and cascaded [zmap] objects:

(You need The sadam Library for this, available at http://www.sadam.hu/en/software ).

Cheers,
Ádám

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

Here's a way to get a circular mapping, though I still don't really understand polar and cartesian co-ordinates!

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

Have added the new additions to the main collection:

Next thing is to do an MSP version.... any takers?

brendan mccloskey's icon

just want to bump this,

for clotilda's non sequitur excellentia (what's Latin for "spam"?) .

Like digital monkeys hacking away in cyber-space, they throw up a rare gem of unadulterated beauty

Oíche mhaith

Roman Thilenius's icon
Roman Thilenius's icon

so, i have modularized my mapping abstractions now.

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

look into [110-map-overview] and [110-map build yourself].

-110

3121.110mapWIN.zip
zip
Roman Thilenius's icon

oops.

3126.110.defarg.mxb.zip
zip
Roman Thilenius's icon

lalala.

3141.kneestuffwin.zip
zip
$Adam's icon

Hi remappers,

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.

The object is called [sadam.interpol] and is part of The sadam Library: https://cycling74.com/forums/announce-the-sadam-library-version-2012-10-08 .

Let me know your comments!

Cheers,
Ádám

metamax's icon

This thread is full of awesome. Thank you everyone for the input!

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?

Thanks!

Wetterberg's icon

troll abstraction 110.isolate: Isolates the rest of your patch. Classic Roman.

Roman Thilenius's icon

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.

110.isolate.mxb_.zip
zip
metamax's icon

Hey that did the trick. Everything is working now. Very cool. Thank you!

madbutter's icon

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/

Wetterberg's icon

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.

metamax's icon

Oh man.. I am absolutely reeling over Penner's easing equations...

Check this out this applet:

And how can something like this be implemented in Max?:

Roman Thilenius's icon

most of them are simple, for the bounce and bend stuff i´d use the pmpd 2d external.

for GUI stuff and other small ranges of low resolution one should precalculate complex curves and then use translations tables IMHO.

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

What a wonderful find (probably been around for ages though!!); my love affair with the interwebs is re-ignited:

Brendan

fraction's icon

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

any help is welcome!
thx!
eric

Wetterberg's icon

I think it's more helpful if we keep the discussion in one thread instead.

Roman Thilenius's icon

define "importance", and explain why exponential or log won´t do.

(and someone tell me if the comma is right between the imperatives)

Aaron Wharton's icon

So this is admittedly a bit above my head, but I'm looking to convert a bipolar signal starting at 64 and maxing out at 0 and 127 to a unipolar signal starting at 0 and maxing out at 127.

I'm currently using the table object, but I'm not sure how to be as precise as I'd like.

ch's icon

[!- 127] should do the trick?
edit: I'm not sure what you mean by bipolar/unipolar here, perhaps I did not understand what you're trying to achieve

Aaron Wharton's icon

I just meant it starts at the mean and goes equal parts above and below that value as you increase the depth — whereas, it would be more useful to have it start at 0 and only go above that value as you increase that depth.

Gonna give your suggestion a whirl here in a bit tho. I appreciate the response.

Roman Thilenius's icon

in case it still doesnt work with the latest [scale] or [zmap] - which i dont know offhand - [110.map-inv -77 77] will do it, as well as [ 110.map -77 77 77 -77], where the latter which show you the basic expression for range conversion.


Roman Thilenius's icon

ok, now that i finally read your question ^^ ... if a range is _not centered around 0, i would not call it bipolar.

and note that 64 is _not the middle between 0-127 anyway.

exeterdown's icon

Fantastic collection, thank you! Though I'm still trying to use the native max objects where possible.

I've attached a couple of [function] objects achieving an outcome I want, but I've been looking for a more elegant, non-gui way to create this shape. Most of the math is way over my head so I cant write my own [expr]. The problem is I need expo on one side of the centre and logo on the other, and vice versa.

I've tried using if statements to flip switches and route between different objects depending on whether the values are above or below 0.5 but the final output jumps around too much. I don't know what I'm doing.

I wish there was an object that did this that even had an argument or input for setting how extreme the curve is.

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

Roman Thilenius's icon


you can shape the curve by the argument to any form of log/exponential or pow/sqrt algorithm.

if you want to use my lego bricks, start the "build yourself" patcher, it should have an example how to use two different curves for upper and lower half of the input range. you can then still simplify it - or move it all into a single expr.

Roman Thilenius's icon


while we are on it, here are the signal versions.

be warned, there is at least one unfinished/wrong patch among these (i cant tell on windows now)

this is how you use "bipolar-insert" util to split the range into two (same for non-signal)


110-map~.zip
application/x-zip-compressed 31.04 KB
range mapping zmap scale