[switch] help

Feb 28, 2010 at 9:00am

[switch] help

I have the following patch.I am trying to click on the left bang, open position 1 in the switch and pass message 11 at the same bang. I do not understand why I have to trigger the bang twice to achieve this.
The same thing happened, when I trigger the right bang. I have to trigger twice to pass the message 12.

{
“boxes” : [ {
"box" : {
"maxclass" : "button",
"numinlets" : 1,
"patching_rect" : [ 540.0, 156.0, 20.0, 20.0 ],
“numoutlets” : 1,
“outlettype” : [ "bang" ],
“id” : “obj-2″
}

}
, {
“box” : {
“maxclass” : “button”,
“numinlets” : 1,
“patching_rect” : [ 466.0, 139.0, 20.0, 20.0 ],
“numoutlets” : 1,
“outlettype” : [ "bang" ],
“id” : “obj-1″
}

}
, {
“box” : {
“maxclass” : “message”,
“text” : “12″,
“fontsize” : 12.0,
“numinlets” : 2,
“patching_rect” : [ 421.0, 342.0, 32.5, 18.0 ],
“numoutlets” : 1,
“outlettype” : [ "" ],
“id” : “obj-46″,
“fontname” : “Arial”
}

}
, {
“box” : {
“maxclass” : “message”,
“text” : “12″,
“fontsize” : 12.0,
“numinlets” : 2,
“patching_rect” : [ 563.0, 239.0, 32.5, 18.0 ],
“numoutlets” : 1,
“outlettype” : [ "" ],
“id” : “obj-38″,
“fontname” : “Arial”
}

}
, {
“box” : {
“maxclass” : “message”,
“text” : “11″,
“fontsize” : 12.0,
“numinlets” : 2,
“patching_rect” : [ 497.0, 235.0, 32.5, 18.0 ],
“numoutlets” : 1,
“outlettype” : [ "" ],
“id” : “obj-21″,
“fontname” : “Arial”
}

}
, {
“box” : {
“maxclass” : “message”,
“text” : “2″,
“fontsize” : 12.0,
“numinlets” : 2,
“patching_rect” : [ 442.0, 219.0, 32.5, 18.0 ],
“numoutlets” : 1,
“outlettype” : [ "" ],
“id” : “obj-79″,
“fontname” : “Arial”
}

}
, {
“box” : {
“maxclass” : “message”,
“text” : “1″,
“fontsize” : 12.0,
“numinlets” : 2,
“patching_rect” : [ 401.0, 225.0, 32.5, 18.0 ],
“numoutlets” : 1,
“outlettype” : [ "" ],
“id” : “obj-78″,
“fontname” : “Arial”
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “switch 2″,
“fontsize” : 12.0,
“numinlets” : 3,
“patching_rect” : [ 443.0, 293.0, 54.0, 20.0 ],
“numoutlets” : 1,
“outlettype” : [ "" ],
“id” : “obj-23″,
“fontname” : “Arial”
}

}
],
“lines” : [ {
"patchline" : {
"source" : [ "obj-2", 0 ],
“destination” : [ "obj-38", 0 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-2", 0 ],
“destination” : [ "obj-79", 0 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-1", 0 ],
“destination” : [ "obj-21", 0 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-1", 0 ],
“destination” : [ "obj-78", 0 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-78", 0 ],
“destination” : [ "obj-23", 0 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-79", 0 ],
“destination” : [ "obj-23", 0 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-21", 0 ],
“destination” : [ "obj-23", 1 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-38", 0 ],
“destination” : [ "obj-23", 2 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-23", 0 ],
“destination” : [ "obj-46", 1 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
]
}

[attachment=125921,138]

Attachments:
  1. switch.png
#48819
Feb 28, 2010 at 10:05am

Always remember that Max evaluates objects from right to left. In your case that means when you’re sending a bang to (1) and (11), the message (11) is sent to the switch before the message (1), since (11) is more to the right. This means that the right input of the switch will only be selected -after- you have already tried to send the message (11) through it. Likewise with the other pair.

So the solution is simple: Move the (11) to the left of (1) and move the (12) to the left of (2).

Any of the following will work as expected:

– Pasted Max Patch, click to expand. –
#175444
Feb 28, 2010 at 6:27pm

Thank you sooo much. That is the last straw I needed for my project to work. Very simple indeed :P

#175445
Feb 28, 2010 at 7:13pm

You also might want to have a look at the helpfile for trigger. it’s a very handy object!!

and when you post patches use “Copy Compressed” from the edit menu…

#175446

You must be logged in to reply to this topic.