Forums > MaxMSP

How to scale a list in Max?

August 23, 2009 | 9:31 pm

How to scale a list in Max?

I know there is ej.lscale:
http://www.maxobjects.com/index.php?v=objects&id_objet=3084&PHPSESSID=d7fa2b548e842525ec85e8588a77dfe4
but I don’t want to use external objects…

Thank you Smile


August 23, 2009 | 9:58 pm
Quote:
How to scale a list in Max?

Well, you could unpack the list, scale the bit, then pack it back up. Or you could convert your list into a matrix using the jit.fill object, run it through jit.scalebias, then use jit.spill to dump it back out, or you could….

As is usually the case in Max, there’s always another way to do it. Since we don’t know anything specific, those are as good a pair of guesses as any. Smile


August 23, 2009 | 11:19 pm
Gregory Taylor wrote on Sun, 23 August 2009 14:58
Quote:
How to scale a list in Max?

Well, you could unpack the list, scale the bit, then pack it back up. Or you could convert your list into a matrix using the jit.fill object, run it through jit.scalebias, then use jit.spill to dump it back out, or you could….

As is usually the case in Max, there’s always another way to do it. Since we don’t know anything specific, those are as good a pair of guesses as any. Smile

There’s also vexpr.


August 24, 2009 | 12:36 am

The [vexpr] object would be my choice too. Try [vexpr (($f1-$f2)/($f3-$f2))*($f5-$f4)+$f4 @scalarmode 1] with your list in the first inlet and scaling numbers in the remaining four to work much like [scale] does.

lh


August 24, 2009 | 8:50 am

FYI, in the next incremental scale and zmap will accept lists in their left inlet. Fancy, isn’t it?


August 25, 2009 | 6:42 am
Emmanuel Jourdan wrote on Mon, 24 August 2009 03:50
FYI, in the next incremental scale and zmap will accept lists in their left inlet. Fancy, isn’t it?

Wow, that’s a great addition to what you can do with vexpr, since with scale and zmap you can specify the range and scaling exactly, plus decide whether you want out-of-bounds values (scale) or cap the values (zmap). Great to hear!


August 25, 2009 | 11:33 am
Emmanuel Jourdan wrote on Mon, 24 August 2009 10:50
FYI, in the next incremental scale and zmap will accept lists in their left inlet. Fancy, isn’t it?

yes, but who wants to use those?

-110


August 26, 2009 | 4:50 am
Roman Thilenius wrote on Tue, 25 August 2009 05:33
Emmanuel Jourdan wrote on Mon, 24 August 2009 10:50
FYI, in the next incremental scale and zmap will accept lists in their left inlet. Fancy, isn’t it?

yes, but who wants to use those?

-110

Those of us who hate math. JK.


August 26, 2009 | 4:52 am

No, my vote goes for vexpr as well. I still have to check out those jitter objects for list processing though.


August 26, 2009 | 7:30 pm

the most basic structure for processing list elements should be that:

max v2;
#N vpatcher 334 568 734 868;
#P flonum 41 185 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 183 152 48 196617 cos 2;
#P newex 183 121 48 196617 + 5;
#P number 41 87 46 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 41 136 108 196617 110.list_processor;
#P connect 1 0 0 0;
#P connect 0 0 4 0;
#P connect 3 0 0 1;
#P connect 0 1 2 0;
#P connect 2 0 3 0;
#P pop;

using vexpr can get difficult when you have operands/arguments.


August 26, 2009 | 8:15 pm

That’s just what the object does internal… it just does it way faster…


August 26, 2009 | 8:46 pm

sure, but in max4 i can not do + 1 to list 1 2 3 4 5 6 7 8 9 i have to do + list 1 1 1 1 1 1 1 1 1, right?
(i´d love to be wrong here…)

that would involve a uzi at some point which is not nice when
the operand changes often under metro conditions.

last but not least one might want to perform things to lists
which are not possible or less efficient in vexpr.

say, like [clip], which reads

((max($f1,$f2))*($f1< =$f2)) + (((min($f1,$f3))*($f1>=$f3))) + ($f1*($f1>=$f2 && $f1< =$f3))

in a [vexpr].

also, in OS 9 i think i saw that [vexpr] wasnt able to take
ints as floats (like [expr] does), but again, maybe i am just
wrong about it.
if i am not wrong, that´d mean that you need to make 2 different
patches for a vectral mtof and a vectral "mtof 0." – using the
zl len zl group method just lets you use arguments to patcher
for int/float mode of the embedded mtof object.

-110

.


August 26, 2009 | 9:52 pm

The [vexpr] object works with floats and ints just as [expr] does and if you set the @scalarmode 1 attribute then you only have to send single numbers to the other inlets, there’s no need to duplicate them into a list.

lh

– Pasted Max Patch, click to expand. –

August 27, 2009 | 7:09 am
Roman Thilenius wrote on Wed, 26 August 2009 22:46
sure, but in max4 i can not do + 1 to list 1 2 3 4 5 6 7 8 9 i have to do + list 1 1 1 1 1 1 1 1 1, right?
(i´d love to be wrong here…)

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P message 76 178 159 196617 3 4 5 6 7 8 9 10 11;
#P newex 76 153 62 196617 prepend set;
#P message 105 99 88 196617 1 2 3 4 5 6 7 8 9;
#P number 213 100 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 76 43 114 196617 loadmess scalarmode 1;
#P newex 76 129 147 196617 vexpr $i1 + $i2;
#P connect 1 0 0 0;
#P connect 2 0 0 1;
#P connect 3 0 0 0;
#P connect 0 0 4 0;
#P connect 4 0 5 0;
#P window clipboard copycount 6;


August 30, 2009 | 3:27 pm

ah, you are right,it works – but only in 4.6.

i would love it to work in 4.1 and 4.5 too.

if it is not downwards compatible it is currently not very useful
for me, at least not in "abstractions" or "methods".


September 1, 2009 | 4:23 pm

I’m not familiar with vexpr

can someone share a simple example?

This is what I would like to do:
to convert 512 sliders with the range of 255 to 512 sliders with the rande of 0. to 1.

– Pasted Max Patch, click to expand. –

by the way, how can one convert a 512 list to a 1024 one, where the first slider of the 521 list corresponds to the first two sliders of the 1024 list, the second slider of the 521 list correspond to sliders 3 and 4 of the 1024 list, and so on…?

Thank you so much, and enjoy the summer sun (since I cannot)



FP
September 1, 2009 | 4:44 pm

like this… no ?

[vexpr $f1/ 255. @scalarmode 1]


September 1, 2009 | 4:53 pm

whell…

[vexpr $i1/255.]

never thought it was so simple…

Still need help with the 512 list conversion to a 1024 list..
Thanks!



FP
September 1, 2009 | 4:54 pm

and this for your second question :

– Pasted Max Patch, click to expand. –

September 1, 2009 | 4:55 pm

Do you want to duplicate everything in the 512 list so that "1 2 3" would be "1 1 2 2 3 3" etc? If so have a look at the [zl lace] object.

lh


September 2, 2009 | 3:22 pm

Thank you so much for your wiseness, fp and thereishopeforus!!

What I love about Max is that we’re always learning while we’re patching!

Thanks again Wink


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