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 3x3 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
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 3x3 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
>
At 9:34 PM -0700 12/4/06, pan_sonic_000 wrote:
>Using pictslider, I've constructed a 3x3 grid that will generate nine combonations of integer values (one for the left outlet and one for the right outlet):
Something like:
--
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
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.
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 3x3 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
----------------------------------------------------
i was a little too fast in reading your email and oversaw you needed sequential numbers as output, here is a revised example :
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"
>
>
> 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
>
> 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
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