## Simple max puzzle…

Jun 1, 2006 at 3:13am

# Simple max puzzle…

So I’m trying to determine something that seems at first glance very
simple — the order of two paired events. The problem is, I want the
recognition of the pairs to start over each time a pair is
recognized. So if I click:

left right left right

I want it to see: left-to-right left-to-right

right now it sees: left-to-right right-to-left left-to-right

Not sure how to Max this… If togedge accepted a set or clear
message I could see how to do it… A starting place is below.

-dh

#P button 317 346 15 0;
#P button 86 346 15 0;
#P window setfont “Fixedwidth Serif” 20.;
#P window linecount 1;
#P newex 136 224 94 1441812 togedge;
#P message 210 179 20 1441812 1;
#P message 84 171 20 1441812 0;
#P message 102 346 214 1441812 left-to-right;
#P hidden message 285 297 214 1441812 set right-to-left;
#P hidden message 70 297 214 1441812 set left-to-right;
#P button 210 110 53 0;
#P button 85 110 53 0;
#P hidden connect 7 1 3 0;
#P connect 7 1 9 0;
#P hidden connect 7 0 2 0;
#P connect 7 0 8 0;
#P connect 5 0 7 0;
#P connect 6 0 7 0;
#P connect 0 0 5 0;
#P connect 1 0 6 0;
#P hidden connect 3 0 4 0;
#P hidden connect 2 0 4 0;
#P window clipboard copycount 10;

#26240
Jun 1, 2006 at 4:53am

Here’s an example of doing it with buddy. Buddy is a really useful
object for syncing things. (note that buddy does not accept bangs,
however.) The advantage of using buddy is that it always waits for the
second button to be pressed.

Peter McCulloch

#P window setfont “Sans Serif” 12.;
#P window linecount 1;
#P newex 261 209 25 196620 t b;
#P button 203 302 15 0;
#P number 203 277 35 12 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window setfont “Fixedwidth Serif” 18.;
#P message 261 418 153 1441810 left-to-right;
#P window setfont “Sans Serif” 12.;
#P newex 261 290 51 196620 sel 1 2;
#P window setfont “Fixedwidth Serif” 18.;
#P message 281 339 197 1441810 set left-to-right;
#P message 261 374 197 1441810 set right-to-left;
#P window setfont “Sans Serif” 12.;
#P newex 231 129 40 196620 t 1 0;
#P newex 105 132 40 196620 t 2 0;
#P newex 261 260 38 196620 int 1;
#P newex 135 171 136 196620 buddy;
#P button 231 67 53 0;
#P button 105 70 53 0;
#P comment 297 249 229 196620 This tells you which one fired first…;
#P connect 4 0 11 0;
#P connect 4 0 9 0;
#P connect 13 0 4 0;
#P connect 3 1 13 0;
#P fasten 6 0 4 1 236 163 294 163;
#P fasten 5 0 4 1 110 163 294 163;
#P connect 6 1 3 1;
#P connect 2 0 6 0;
#P connect 5 1 3 0;
#P connect 1 0 5 0;
#P connect 11 0 12 0;
#P connect 9 1 8 0;
#P connect 9 0 7 0;
#P connect 8 0 10 0;
#P connect 7 0 10 0;
#P window clipboard copycount 14;

#78042
Jun 1, 2006 at 7:47pm

Here’s a js version that takes any input including bangs and lists.

max v2;
#N vpatcher 338 133 938 533;
#P window setfont “Sans Serif” 9.;
#P newex 144 250 50 9109513 print order;
#P message 177 217 54 9109513 right to left;
#P message 111 217 54 9109513 left to right;
#P newex 144 183 40 9109513 sel 0 1;
#P message 205 121 37 9109513 0 1. 4;
#P message 153 121 24 9109513 fish;
#P button 195 84 31 0;
#P button 144 84 31 0;
#P newex 144 147 61 9109513 js inlet_order;
#P connect 5 0 6 0;
#P connect 3 0 0 0;
#P connect 1 0 0 0;
#P connect 0 0 5 0;
#P connect 7 0 8 0;
#P connect 6 0 8 0;
#P connect 5 1 7 0;
#P connect 4 0 0 1;
#P connect 2 0 0 1;
#P pop;

/****** save as inlet_order.js ******/
autowatch = 1;
inlets = 2;
var tracker = new Array();
function anything ()
{
switch (inlet)
{
case 0 :
tracker[tracker.length] = 0;
break;
case 1 :
tracker[tracker.length] = 1;
}
if (tracker.length==2)
{
if (tracker[0]==tracker[1]) tracker.length = 1; // same inlet 2x in a row
else
{
if (tracker[0]

else outlet(0, 1); // right to left
tracker = [];
}
}
}

#78043

You must be logged in to reply to this topic.