How to scale a list in Max?

Aug 23, 2009 at 9:31pm

How to scale a list in Max?

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

#45203
Aug 23, 2009 at 9:58pm
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

#162870
Aug 23, 2009 at 11:19pm
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.

#162871
Aug 24, 2009 at 12:36am

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

#162872
Aug 24, 2009 at 8:50am

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

#162873
Aug 25, 2009 at 6:42am
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!

#162874
Aug 25, 2009 at 11:33am
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

#162875
Aug 26, 2009 at 4:50am
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.

#162876
Aug 26, 2009 at 4:52am

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

#162877
Aug 26, 2009 at 7:30pm

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.

#162878
Aug 26, 2009 at 8:15pm

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

#162879
Aug 26, 2009 at 8:46pm

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

.

#162880
Aug 26, 2009 at 9:52pm

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. –
#162881
Aug 27, 2009 at 7:09am
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;

#162882
Aug 30, 2009 at 3:27pm

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

#162883
Sep 1, 2009 at 4:23pm

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)

#162884
Sep 1, 2009 at 4:44pm

like this… no ?

[vexpr $f1/ 255. @scalarmode 1]

#162885
Sep 1, 2009 at 4:53pm

whell…

[vexpr $i1/255.]

never thought it was so simple…

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

#162886
Sep 1, 2009 at 4:54pm

and this for your second question :

– Pasted Max Patch, click to expand. –
#162887
Sep 1, 2009 at 4:55pm

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

#162888
Sep 2, 2009 at 3:22pm

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

#162889

You must be logged in to reply to this topic.