comparing two int values

Dec 5, 2006 at 4:34am

comparing two int values

Hi there.

I’m a Max MSP newbie and am trying to do something rather basic.

Using pictslider, I’ve constructed a 3×3 grid that will generate nine combonations of integer values (one for the left outlet and one for the right outlet), depending on where the mouse is located in said grid:

x1,y1
x2,y1
x3,y1

x1,y2
x2,y2
x3,y2

x1,y3
x2,y3
x3,y3

What object would allow me to evaluate the different pairs and generate a unique output for each one?

Example:
for pair 1,1 – output the value “1″
for pair 2,1 – output the value “2″
for pair 3,1 – output the value “3″

and so on…

I attempted it with the select, match and split objects but was unable to create the intended result. Is there some kind of IF/THEN comparator?

Many thanks!

-Pan Sonic

#29044
Dec 5, 2006 at 4:45am

You could make a really simple javascript to do this. for example:

var keys = { {0, 1, 2},
{3, 4, 5},
{6, 7, 8}};

function list(vals)
{
var args = arrayfromargs(arguments);
outlet(0, keys[ args[0] ][ args[1] ]);
}

I haven’t tested the code above, but you get the idea. Use your poair
to index into a 2D array holding unique pair IDs.

Alternatively, you can use the zl object or Lobjects for list
processing. I’m sure there are a bajillion other ways as well. If
you’re unfamiliar with javascript, have a look at the zl help file.

wes

On 12/4/06, pan_sonic_000

wrote:
>
> Hi there.
>
> I’m a Max MSP newbie and am trying to do something rather basic.
>
> Using pictslider, I’ve constructed a 3×3 grid that will generate nine combonations of integer values (one for the left outlet and one for the right outlet):
>
> 1,1
> 2,1
> 3,1
>
> 1,2
> 2,2
> 3,2
>
> 1,3
> 2,3
> 3,3
>
>
> What object would allow me to evaluate the different pairs and generate a unique output for each one?
>
> Example:
> for pair 1,1 – output the value “1″
> for pair 2,1 – output the value “2″
> for pair 3,1 – output the value “3″
>
> and so on…
>
> I attempted it with the select, match and split objects but was unable to create the intended result.
>
>
> Many thanks!
>
> -Pan Sonic
>

#89850
Dec 5, 2006 at 5:04am

At 9:34 PM -0700 12/4/06, pan_sonic_000 wrote:
>Using pictslider, I’ve constructed a 3×3 grid that will generate nine combonations of integer values (one for the left outlet and one for the right outlet):

Something like:

#P window setfont “Sans Serif” 9.;
#P number 25 287 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#P newex 25 263 27 196617 +;
#P newex 88 221 27 196617 * 3;
#P newex 88 184 27 196617 – 1;
#P number 88 147 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 25 147 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P user pictslider 25 43 100 100 4 4 4 4 SliderDefaultKnob.pct 0 SliderDefaultBkgnd.pct 0 2163 0 196609 65539 1. 1.;
#P window linecount 2;
#P comment 116 181 172 196617 Could skip this if you were willing to make column range 0-2;
#P connect 3 0 4 0;
#P connect 4 0 5 0;
#P connect 6 0 7 0;
#P connect 2 0 6 0;
#P connect 5 0 6 1;
#P connect 1 1 3 0;
#P connect 1 0 2 0;
#P window clipboard copycount 8;


Chris Muir | “There are many futures and only one status quo.
cbm@well.com | This is why conservatives mostly agree,
http://www.xfade.com | and radicals always argue.” – Brian Eno

#89851
Dec 5, 2006 at 5:45am

if you have jitter you could use a 3 by 3 matrix that is loaded with desired values. PictCtrl would read the content of each cell.
the advantage here is that you can have a matrix of N planes which means that each cell can hold N values…
in this example the matrix is loaded with random values.

#P window setfont “Sans Serif” 9.;
#P message 151 460 50 196617;
#P message 200 366 50 196617;
#P button 1 39 15 0;
#P window linecount 1;
#P newex 150 438 62 196617 prepend set;
#P newex 149 409 51 196617 zl slice 4;
#P user jit.pwindow 34 293 82 62 0 1 0 0 1 0;
#P newex 0 225 116 196617 jit.noise 16 float32 3 3;
#P newex 35 263 124 196617 jit.matrix 16 float32 3 3;
#P newex 200 343 62 196617 prepend set;
#P newex 196 312 51 196617 zl slice 4;
#P newex 269 222 20 196617 t b;
#P newex 293 222 114 196617 sprintf getcell %ld %ld;
#P number 383 174 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 293 175 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P user pictslider 293 65 100 100 4 4 4 4 SliderDefaultKnob.pct 1 SliderDefaultBkgnd.pct 1 2163 0 0 131074 1. 1.;
#P user jit.pwindow 87 143 82 62 0 1 0 0 1 0;
#P newex 53 75 110 196617 jit.noise 1 float32 3 3;
#P newex 88 113 118 196617 jit.matrix 1 float32 3 3;
#P comment 20 40 187 196617 load matrices with random values;
#P window linecount 2;
#P comment 396 65 100 196617 range of pictCtrl has been set to (0 , 2);
#P connect 16 0 19 0;
#P connect 11 0 18 0;
#P connect 17 0 13 0;
#P connect 17 0 3 0;
#P fasten 13 0 12 0 5 253 40 253;
#P fasten 8 0 12 0 298 269 174 269 174 248 40 248;
#P lcolor 9;
#P fasten 8 0 2 0 298 258 218 258 218 102 93 102;
#P lcolor 9;
#P connect 12 0 14 0;
#P connect 12 1 15 0;
#P fasten 15 1 16 0 195 431 155 431;
#P fasten 3 0 2 0 58 103 93 103;
#P connect 2 1 10 0;
#P connect 2 0 4 0;
#P fasten 10 1 11 0 242 335 205 335;
#P fasten 7 0 9 0 388 205 274 205;
#P connect 7 0 8 1;
#P connect 6 0 8 0;
#P connect 9 0 8 0;
#P connect 5 1 7 0;
#P connect 5 0 6 0;
#P window clipboard copycount 20;

Quote: pan_sonic_000@yahoo.com wrote on Mon, 04 December 2006 20:34
—————————————————-
> Hi there.
>
> I’m a Max MSP newbie and am trying to do something rather basic.
>
> Using pictslider, I’ve constructed a 3×3 grid that will generate nine combonations of integer values (one for the left outlet and one for the right outlet), depending on where the mouse is located in said grid:
>
> x1,y1
> x2,y1
> x3,y1
>
> x1,y2
> x2,y2
> x3,y2
>
> x1,y3
> x2,y3
> x3,y3
>
>
> What object would allow me to evaluate the different pairs and generate a unique output for each one?
>
> Example:
> for pair 1,1 – output the value “1″
> for pair 2,1 – output the value “2″
> for pair 3,1 – output the value “3″
>
> and so on…
>
> I attempted it with the select, match and split objects but was unable to create the intended result. Is there some kind of IF/THEN comparator?
>
>
> Many thanks!
>
> -Pan Sonic
—————————————————-

#89852
Dec 5, 2006 at 5:55am

i was a little too fast in reading your email and oversaw you needed sequential numbers as output, here is a revised example :

#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P message 651 318 50 196617 0;
#P newex 651 295 62 196617 prepend set;
#P newex 647 264 51 196617 zl slice 4;
#P newex 671 207 20 196617 t b;
#P newex 695 207 114 196617 sprintf getcell %ld %ld;
#P number 785 159 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 695 160 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P user pictslider 695 50 100 100 4 4 4 4 SliderDefaultKnob.pct 1 SliderDefaultBkgnd.pct 1 2163 0 0 131074 1. 1.;
#P newex 534 241 123 196617 jit.matrix bob 1 char 3 3;
#P message 533 162 88 196617 0 1 2 3 4 5 6 7 8;
#P newex 534 183 55 196617 jit.fill bob;
#P connect 1 0 0 0;
#P connect 0 0 2 0;
#P connect 2 1 8 0;
#P fasten 8 1 9 0 693 287 656 287;
#P connect 9 0 10 0;
#P fasten 6 0 2 0 700 234 539 234;
#P fasten 5 0 7 0 790 190 676 190;
#P connect 5 0 6 1;
#P connect 3 0 4 0;
#P connect 3 1 5 0;
#P connect 7 0 6 0;
#P connect 4 0 6 0;
#P window clipboard copycount 11;

Quote: pan_sonic_000@yahoo.com wrote on Mon, 04 December 2006 20:34
> Example:
> for pair 1,1 – output the value “1″
> for pair 2,1 – output the value “2″
> for pair 3,1 – output the value “3″
>

#89853
Dec 5, 2006 at 3:40pm

>
> What object would allow me to evaluate the different pairs and generate a unique output for each one?
>
> Example:
> for pair 1,1 – output the value “1″
> for pair 2,1 – output the value “2″
> for pair 3,1 – output the value “3″
>
> and so on…
>
> I attempted it with the select, match and split objects but was unable to create the intended result. Is there some kind of IF/THEN comparator?

if/then stuff can be done with the [expr] object, but i dont
think you want to convert your 9 numbers one by one, but
rather do some kind of mapping.

for only 9 coordinates i would eventually:

– multiply the horizontal values with 100,
– and add them to the vertical values,
– them map the results via [select 101 102 103 201 202 203 301 302 303]
– to messageboxes (1), (2), (3), (4), …

such an “addition” of the 2 elements in a list of integers
(v1/h1 = “101″) stops giving you headache about list and
lets you use simple math instead. in addition it might be
faster to calculate, route, and sort.

-110

#89854
Dec 5, 2006 at 3:41pm

>
> What object would allow me to evaluate the different pairs and generate a unique output for each one?
>
> Example:
> for pair 1,1 – output the value “1″
> for pair 2,1 – output the value “2″
> for pair 3,1 – output the value “3″
>
> and so on…
>
> I attempted it with the select, match and split objects but was unable to create the intended result. Is there some kind of IF/THEN comparator?

if/then stuff can be done with the [expr] object, but i dont
think you want to convert your 9 numbers one by one, but
rather do some kind of mapping.

for only 9 coordinates i would eventually:

– multiply the horizontal values with 100,
– and add them to the vertical values,
– them map the results via [select 101 102 103 201 202 203 301 302 303]
– to messageboxes (1), (2), (3), (4), …

such an “addition” of the 2 elements in a list of integers
(v1/h1 = “101″) stops giving you headache about list and
lets you use simple math instead. in addition it might be
faster to calculate, route, and sort.

-110

#89855
Dec 5, 2006 at 7:22pm

Thanks to all for the prompt, clear replies!

I’ll probably try all of these suggestions just for the sake of learning and let you know how it goes…and probably ask more questions too. ;)

Thanks again!

-Pan Sonic

#89856

You must be logged in to reply to this topic.