Forums > MaxMSP

Receive OSC Dataflow each id identify and logic question,please help me!

December 2, 2009 | 4:26 pm

Hello every one , I am new guy here, and really like the Forums:)!
(my english is not good , say sorry first..)

here I meet a small problem but make me really headache………

About Multi Touch work

I have computed to recognize multi points,and give each point unique ID,then use osc protocol to transit dataflow,but I have each id identify question in MAX logic thingking…><

the question is in the below MAX code, please help me, I already confused every night and day……

Really Thankyou!!

{
	"boxes" : [ 		{
			"box" : 			{
				"maxclass" : "comment",
				"text" : "4",
				"textcolor" : [ 0.87451, 0.25098, 0.717647, 1.0 ],
				"numinlets" : 1,
				"fontface" : 1,
				"frgb" : [ 0.87451, 0.25098, 0.717647, 1.0 ],
				"fontsize" : 24.0,
				"patching_rect" : [ 28.0, 637.0, 66.0, 34.0 ],
				"numoutlets" : 0,
				"id" : "obj-218",
				"fontname" : "Arial"
			}

		}
, 		{
			"box" : 			{
				"maxclass" : "comment",
				"text" : "Use the X values and Y values mapping Real object position",
				"numinlets" : 1,
				"fontsize" : 12.0,
				"patching_rect" : [ 26.0, 675.0, 482.0, 20.0 ],
				"numoutlets" : 0,
				"id" : "obj-217",
				"fontname" : "Arial"
			}

		}
, 		{
			"box" : 			{
				"maxclass" : "comment",
				"text" : "Question:nnIf there are id1 and id2,that mean I can get id1 x and y,if id1's x=99 y=120,id2's x=11 y=110nNext time if id1 suddenly is disappear only id2 bang,nnow id1 x value still stay 99,y value still stay 120,that make mapping image position still stay (99,120)nbut in fact, id1's x=none y=none!nBecause no any bang through the id1 in route object.....,the id1 x and y value are still old valuesnnSo this is my question,how I let MAX know when  ID1 is dispear ,  the ID1 position I want to give x=0,y=0,and always bang the id1 position(x=0,y=0) to let mapping image position can back to  x=0 y=0nnand next time if ID1 is appear again ,the id1's position will be gave right x and y valuennnon the other hand,is it possible make a switch(toggle) for each id state?nif it's possible,that is easy to know which id is exist or unexsit.nnplease help me!Thankyou very much!! ",
				"linecount" : 18,
				"numinlets" : 1,
				"fontsize" : 12.0,
				"patching_rect" : [ 637.0, 467.0, 647.0, 255.0 ],
				"numoutlets" : 0,
				"id" : "obj-215",
				"fontname" : "Arial"
			}

		}
, 		{
			"box" : 			{
				"maxclass" : "number",
				"numinlets" : 1,
				"fontsize" : 12.0,
				"patching_rect" : [ 531.0, 591.0, 50.0, 20.0 ],
				"numoutlets" : 2,
				"outlettype" : [ "int", "bang" ],
				"id" : "obj-209",
				"fontname" : "Arial"
			}

		}
, 		{
			"box" : 			{
				"maxclass" : "number",
				"numinlets" : 1,
				"fontsize" : 12.0,
				"patching_rect" : [ 471.0, 587.0, 50.0, 20.0 ],
				"numoutlets" : 2,
				"outlettype" : [ "int", "bang" ],
				"id" : "obj-210",
				"fontname" : "Arial"
			}

		}
, 		{
			"box" : 			{
				"maxclass" : "newobj",
				"text" : "unpack 0 0",
				"numinlets" : 1,
				"fontsize" : 9.0,
				"patching_rect" : [ 470.0, 546.0, 55.0, 17.0 ],
				"numoutlets" : 2,
				"outlettype" : [ "int", "int" ],
				"id" : "obj-211",
				"fontname" : "Arial"
			}

		}
, 		{
			"box" : 			{
				"maxclass" : "comment",
				"text" : "Yval",
				"numinlets" : 1,
				"fontsize" : 9.0,
				"patching_rect" : [ 540.0, 614.0, 37.0, 17.0 ],
				"numoutlets" : 0,
				"id" : "obj-212",
				"fontname" : "Arial"
			}

		}
, 		{
			"box" : 			{
				"maxclass" : "comment",
				"text" : "Xval",
				"numinlets" : 1,
				"fontsize" : 9.0,
				"patching_rect" : [ 473.0, 612.0, 37.0, 17.0 ],
				"numoutlets" : 0,
				"id" : "obj-213",
				"fontname" : "Arial"
			}

		}
, 		{
			"box" : 			{
				"maxclass" : "number",
				"numinlets" : 1,
				"fontsize" : 12.0,
				"patching_rect" : [ 381.0, 591.0, 50.0, 20.0 ],
				"numoutlets" : 2,
				"outlettype" : [ "int", "bang" ],
				"id" : "obj-199",
				"fontname" : "Arial"
			}

		}
, 		{
			"box" : 			{
				"maxclass" : "number",
				"numinlets" : 1,
				"fontsize" : 12.0,
				"patching_rect" : [ 321.0, 587.0, 50.0, 20.0 ],
				"numoutlets" : 2,
				"outlettype" : [ "int", "bang" ],
				"id" : "obj-200",
				"fontname" : "Arial"
			}

		}
, 		{
			"box" : 			{
				"maxclass" : "newobj",
				"text" : "unpack 0 0",
				"numinlets" : 1,
				"fontsize" : 9.0,
				"patching_rect" : [ 320.0, 546.0, 55.0, 17.0 ],
				"numoutlets" : 2,
				"outlettype" : [ "int", "int" ],
				"id" : "obj-201",
				"fontname" : "Arial"
			}

		}
, 		{
			"box" : 			{
				"maxclass" : "comment",
				"text" : "Yval",
				"numinlets" : 1,
				"fontsize" : 9.0,
				"patching_rect" : [ 390.0, 614.0, 37.0, 17.0 ],
				"numoutlets" : 0,
				"id" : "obj-202",
				"fontname" : "Arial"
			}

		}
, 		{
			"box" : 			{
				"maxclass" : "comment",
				"text" : "Xval",
				"numinlets" : 1,
				"fontsize" : 9.0,
				"patching_rect" : [ 323.0, 612.0, 37.0, 17.0 ],
				"numoutlets" : 0,
				"id" : "obj-203",
				"fontname" : "Arial"
			}

		}
, 		{
			"box" : 			{
				"maxclass" : "number",
				"numinlets" : 1,
				"fontsize" : 12.0,
				"patching_rect" : [ 211.0, 583.0, 50.0, 20.0 ],
				"numoutlets" : 2,
				"outlettype" : [ "int", "bang" ],
				"id" : "obj-194",
				"fontname" : "Arial"
			}

		}
, 		{
			"box" : 			{
				"maxclass" : "number",
				"numinlets" : 1,
				"fontsize" : 12.0,
				"patching_rect" : [ 151.0, 579.0, 50.0, 20.0 ],
				"numoutlets" : 2,
				"outlettype" : [ "int", "bang" ],
				"id" : "obj-195",
				"fontname" : "Arial"
			}

		}
, 		{
			"box" : 			{
				"maxclass" : "newobj",
				"text" : "unpack 0 0",
				"numinlets" : 1,
				"fontsize" : 9.0,
				"patching_rect" : [ 150.0, 538.0, 55.0, 17.0 ],
				"numoutlets" : 2,
				"outlettype" : [ "int", "int" ],
				"id" : "obj-196",
				"fontname" : "Arial"
			}

		}
, 		{
			"box" : 			{
				"maxclass" : "comment",
				"text" : "Yval",
				"numinlets" : 1,
				"fontsize" : 9.0,
				"patching_rect" : [ 220.0, 606.0, 37.0, 17.0 ],
				"numoutlets" : 0,
				"id" : "obj-197",
				"fontname" : "Arial"
			}

		}
, 		{
			"box" : 			{
				"maxclass" : "comment",
				"text" : "Xval",
				"numinlets" : 1,
				"fontsize" : 9.0,
				"patching_rect" : [ 153.0, 604.0, 37.0, 17.0 ],
				"numoutlets" : 0,
				"id" : "obj-198",
				"fontname" : "Arial"
			}

		}
, 		{
			"box" : 			{
				"maxclass" : "comment",
				"text" : "check which ID bang",
				"numinlets" : 1,
				"fontsize" : 12.0,
				"patching_rect" : [ 243.0, 448.0, 150.0, 20.0 ],
				"numoutlets" : 0,
				"id" : "obj-192",
				"fontname" : "Arial"
			}

		}
, 		{
			"box" : 			{
				"maxclass" : "comment",
				"text" : "2",
				"textcolor" : [ 0.87451, 0.25098, 0.717647, 1.0 ],
				"numinlets" : 1,
				"fontface" : 1,
				"frgb" : [ 0.87451, 0.25098, 0.717647, 1.0 ],
				"fontsize" : 24.0,
				"patching_rect" : [ 170.0, 441.0, 66.0, 34.0 ],
				"numoutlets" : 0,
				"id" : "obj-193",
				"fontname" : "Arial"
			}

		}
, 		{
			"box" : 			{
				"maxclass" : "comment",
				"text" : "and so on...",
				"numinlets" : 1,
				"fontsize" : 12.0,
				"patching_rect" : [ 1081.0, 85.0, 150.0, 20.0 ],
				"numoutlets" : 0,
				"id" : "obj-191",
				"fontname" : "Arial"
			}

		}
, 		{
			"box" : 			{
				"maxclass" : "comment",
				"text" : "the other  osc message is like:nn/slice/2 1 99 100 (A case)nnsometimes will be like:nn/slice/2 3 34 66 (B case)nnso...below  each element meaningnn1:ID (A case)    or   3:ID(B case)nn99:X(A case)   or  34:X(B case)  nn100:Y(A case)   or   66:Y(B case)nn/slice/2:just mean slice 2nnso I use route object..",
				"linecount" : 19,
				"numinlets" : 1,
				"fontsize" : 12.0,
				"patching_rect" : [ 710.0, 80.0, 345.0, 269.0 ],
				"numoutlets" : 0,
				"id" : "obj-189",
				"fontname" : "Arial"
			}

		}
, 		{
			"box" : 			{
				"maxclass" : "number",
				"numinlets" : 1,
				"fontsize" : 12.0,
				"patching_rect" : [ 74.0, 578.0, 50.0, 20.0 ],
				"numoutlets" : 2,
				"outlettype" : [ "int", "bang" ],
				"id" : "obj-188",
				"fontname" : "Arial"
			}

		}
, 		{
			"box" : 			{
				"maxclass" : "number",
				"numinlets" : 1,
				"fontsize" : 12.0,
				"patching_rect" : [ 14.0, 574.0, 50.0, 20.0 ],
				"numoutlets" : 2,
				"outlettype" : [ "int", "bang" ],
				"id" : "obj-187",
				"fontname" : "Arial"
			}

		}
, 		{
			"box" : 			{
				"maxclass" : "comment",
				"text" : "I use unpack object to know X and Y",
				"linecount" : 2,
				"numinlets" : 1,
				"fontsize" : 12.0,
				"patching_rect" : [ 162.0, 487.0, 150.0, 34.0 ],
				"numoutlets" : 0,
				"id" : "obj-185",
				"fontname" : "Arial"
			}

		}
, 		{
			"box" : 			{
				"maxclass" : "comment",
				"text" : "3",
				"textcolor" : [ 0.87451, 0.25098, 0.717647, 1.0 ],
				"numinlets" : 1,
				"fontface" : 1,
				"frgb" : [ 0.87451, 0.25098, 0.717647, 1.0 ],
				"fontsize" : 24.0,
				"patching_rect" : [ 89.0, 487.0, 66.0, 34.0 ],
				"numoutlets" : 0,
				"id" : "obj-183",
				"fontname" : "Arial"
			}

		}
, 		{
			"box" : 			{
				"maxclass" : "comment",
				"text" : "1",
				"textcolor" : [ 0.87451, 0.25098, 0.717647, 1.0 ],
				"numinlets" : 1,
				"fontface" : 1,
				"frgb" : [ 0.87451, 0.25098, 0.717647, 1.0 ],
				"fontsize" : 24.0,
				"patching_rect" : [ 264.0, 147.0, 66.0, 34.0 ],
				"numoutlets" : 0,
				"id" : "obj-182",
				"fontname" : "Arial"
			}

		}
, 		{
			"box" : 			{
				"maxclass" : "comment",
				"text" : "the osc message is like:nn/slice/1 1 125 200 (A case)nnsometimes will be like:nn/slice/1 2 12 77 (B case)nnso...below  each element meaningnn1:ID (A case)    or   2:ID(B case)nn125:X(A case)   or 12:X(B case)nn200:Y(A case)    or    77:Y(B case)nn/slice/1:just mean slice 1nnso I use route object..",
				"linecount" : 19,
				"numinlets" : 1,
				"fontsize" : 12.0,
				"patching_rect" : [ 345.0, 80.0, 345.0, 269.0 ],
				"numoutlets" : 0,
				"id" : "obj-180",
				"fontname" : "Arial"
			}

		}
, 		{
			"box" : 			{
				"maxclass" : "newobj",
				"text" : "unpack 0 0",
				"numinlets" : 1,
				"fontsize" : 9.0,
				"patching_rect" : [ 13.0, 533.0, 55.0, 17.0 ],
				"numoutlets" : 2,
				"outlettype" : [ "int", "int" ],
				"id" : "obj-7",
				"fontname" : "Arial"
			}

		}
, 		{
			"box" : 			{
				"maxclass" : "comment",
				"text" : "Yval",
				"numinlets" : 1,
				"fontsize" : 9.0,
				"patching_rect" : [ 83.0, 601.0, 37.0, 17.0 ],
				"numoutlets" : 0,
				"id" : "obj-9",
				"fontname" : "Arial"
			}

		}
, 		{
			"box" : 			{
				"maxclass" : "comment",
				"text" : "Xval",
				"numinlets" : 1,
				"fontsize" : 9.0,
				"patching_rect" : [ 16.0, 599.0, 37.0, 17.0 ],
				"numoutlets" : 0,
				"id" : "obj-10",
				"fontname" : "Arial"
			}

		}
, 		{
			"box" : 			{
				"maxclass" : "newobj",
				"text" : "route 1 2 3 4",
				"numinlets" : 1,
				"fontsize" : 9.0,
				"patching_rect" : [ 78.0, 444.0, 66.0, 17.0 ],
				"numoutlets" : 5,
				"outlettype" : [ "", "", "", "", "" ],
				"id" : "obj-57",
				"fontname" : "Arial"
			}

		}
, 		{
			"box" : 			{
				"maxclass" : "newobj",
				"text" : "mxj net.udp.recv @port 2250",
				"numinlets" : 1,
				"fontsize" : 9.0,
				"patching_rect" : [ 76.0, 329.0, 126.0, 17.0 ],
				"numoutlets" : 2,
				"outlettype" : [ "", "" ],
				"id" : "obj-58",
				"fontname" : "Arial"
			}

		}
, 		{
			"box" : 			{
				"maxclass" : "button",
				"numinlets" : 1,
				"patching_rect" : [ 74.0, 397.0, 15.0, 15.0 ],
				"numoutlets" : 1,
				"outlettype" : [ "bang" ],
				"id" : "obj-156"
			}

		}
, 		{
			"box" : 			{
				"maxclass" : "newobj",
				"text" : "opensoundcontrol",
				"numinlets" : 1,
				"fontsize" : 9.0,
				"patching_rect" : [ 74.0, 365.0, 87.0, 17.0 ],
				"numoutlets" : 3,
				"outlettype" : [ "", "", "OSCTimeTag" ],
				"id" : "obj-157",
				"fontname" : "Arial"
			}

		}
, 		{
			"box" : 			{
				"maxclass" : "newobj",
				"text" : "route /slice/1 /slice/2 /slice/3 /slice/4 /slice/5 /slice/6 /slice/7 /slice/8 /slice/9 /slice/10",
				"numinlets" : 1,
				"fontsize" : 9.0,
				"patching_rect" : [ 113.0, 399.0, 775.0, 17.0 ],
				"numoutlets" : 11,
				"outlettype" : [ "", "", "", "", "", "", "", "", "", "", "" ],
				"id" : "obj-158",
				"fontname" : "Arial"
			}

		}
 ],
	"lines" : [ 		{
			"patchline" : 			{
				"source" : [ "obj-57", 3 ],
				"destination" : [ "obj-211", 0 ],
				"hidden" : 0,
				"midpoints" : [  ]
			}

		}
, 		{
			"patchline" : 			{
				"source" : [ "obj-211", 0 ],
				"destination" : [ "obj-210", 0 ],
				"hidden" : 0,
				"midpoints" : [  ]
			}

		}
, 		{
			"patchline" : 			{
				"source" : [ "obj-211", 1 ],
				"destination" : [ "obj-209", 0 ],
				"hidden" : 0,
				"midpoints" : [  ]
			}

		}
, 		{
			"patchline" : 			{
				"source" : [ "obj-57", 2 ],
				"destination" : [ "obj-201", 0 ],
				"hidden" : 0,
				"midpoints" : [  ]
			}

		}
, 		{
			"patchline" : 			{
				"source" : [ "obj-201", 1 ],
				"destination" : [ "obj-199", 0 ],
				"hidden" : 0,
				"midpoints" : [  ]
			}

		}
, 		{
			"patchline" : 			{
				"source" : [ "obj-201", 0 ],
				"destination" : [ "obj-200", 0 ],
				"hidden" : 0,
				"midpoints" : [  ]
			}

		}
, 		{
			"patchline" : 			{
				"source" : [ "obj-57", 1 ],
				"destination" : [ "obj-196", 0 ],
				"hidden" : 0,
				"midpoints" : [  ]
			}

		}
, 		{
			"patchline" : 			{
				"source" : [ "obj-196", 0 ],
				"destination" : [ "obj-195", 0 ],
				"hidden" : 0,
				"midpoints" : [  ]
			}

		}
, 		{
			"patchline" : 			{
				"source" : [ "obj-196", 1 ],
				"destination" : [ "obj-194", 0 ],
				"hidden" : 0,
				"midpoints" : [  ]
			}

		}
, 		{
			"patchline" : 			{
				"source" : [ "obj-57", 0 ],
				"destination" : [ "obj-7", 0 ],
				"hidden" : 0,
				"midpoints" : [  ]
			}

		}
, 		{
			"patchline" : 			{
				"source" : [ "obj-7", 1 ],
				"destination" : [ "obj-188", 0 ],
				"hidden" : 0,
				"midpoints" : [  ]
			}

		}
, 		{
			"patchline" : 			{
				"source" : [ "obj-7", 0 ],
				"destination" : [ "obj-187", 0 ],
				"hidden" : 0,
				"midpoints" : [  ]
			}

		}
, 		{
			"patchline" : 			{
				"source" : [ "obj-58", 0 ],
				"destination" : [ "obj-157", 0 ],
				"hidden" : 0,
				"midpoints" : [  ]
			}

		}
, 		{
			"patchline" : 			{
				"source" : [ "obj-158", 3 ],
				"destination" : [ "obj-57", 0 ],
				"hidden" : 0,
				"midpoints" : [  ]
			}

		}
, 		{
			"patchline" : 			{
				"source" : [ "obj-158", 2 ],
				"destination" : [ "obj-57", 0 ],
				"hidden" : 0,
				"midpoints" : [  ]
			}

		}
, 		{
			"patchline" : 			{
				"source" : [ "obj-158", 1 ],
				"destination" : [ "obj-57", 0 ],
				"hidden" : 0,
				"midpoints" : [  ]
			}

		}
, 		{
			"patchline" : 			{
				"source" : [ "obj-158", 0 ],
				"destination" : [ "obj-57", 0 ],
				"hidden" : 0,
				"midpoints" : [  ]
			}

		}
, 		{
			"patchline" : 			{
				"source" : [ "obj-157", 0 ],
				"destination" : [ "obj-156", 0 ],
				"hidden" : 0,
				"midpoints" : [  ]
			}

		}
, 		{
			"patchline" : 			{
				"source" : [ "obj-157", 1 ],
				"destination" : [ "obj-158", 0 ],
				"hidden" : 0,
				"midpoints" : [  ]
			}

		}
 ]
}

December 2, 2009 | 4:58 pm

Any body can help??tks!


December 3, 2009 | 3:26 am

my problem is..
If there are id1 and id2,that mean I can get id1 x and y,if id1′s x=99 y=120,id2′s x=11 y=110
Next time if id1 suddenly is disappear only id2 bang,
now id1 x value still stay 99,y value still stay 120,that make mapping image position still stay (99,120)
but in fact, id1′s x=none y=none!
Because no any bang through the id1 in route object…..,the id1 x and y value are still old values
So this is my question,how I let MAX know when ID1 is dispear , the ID1 position I want to give x=0,y=0,and always bang the id1 position(x=0,y=0) to let mapping image position can back to x=0 y=0
and next time if ID1 is appear again ,the id1′s position will be gave right x and y value
On the other hand,is it possible make a switch(toggle) for each id state?if it’s possible,that is easy to know which id is exist or unexsit.
please help me!Thankyou very much!! ",


December 3, 2009 | 3:55 am

I’m not totally sure I understand what you mean, but in case it is of any use here is something that I think might be what you are trying to do:

It has two inputs, Y and X (Y is inlet 1, X is inlet 2). These values are both from 0-127 (it’s part of a bigger patch I’m developing)

If a value is received on either X or Y it generates an OSC output which packs them together as an xy pair. If only one input receives a value then it uses the last seen value from the other input.

Hopefully it’s of some help. I put some comments in.

Eddy

– Pasted Max Patch, click to expand. –

December 3, 2009 | 1:32 pm

Thanks Eddy’s reply!That make me learn more about connect MAX patch.:)

Your concept help me to know about how I combine two values however which one first reached.

but my problem is….. after received dataflow from OSC,
I used route object to decide which ID xy value reached.
already used route unpack the list,it has 4 ways to choose,

if id1 reached this time, next time id1 is suddenly disappear(be taken),
route object won’t send any id1 new xy value(because no any id1 osc list)
the id1 xy value is still old value,that make later mapping image position stay old positions,I want to let the mapping image disappear as id1,but it still stay in the screen…..

My idea is if any posibble to make a toggle for each id,present each id statement(on/off),that ‘s easy to control ,and i can use the toggle to make mapping image visible or invisible.

I am sorry about past unclear MAX code,,,,

Now I post a new compressed max patch

Please anyone can help me,Thank you!:)

– Pasted Max Patch, click to expand. –

December 3, 2009 | 5:45 pm

any body help?I think it is not too hard,,,,just my brain is *(*&*((*^…..:S


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