Simple max puzzle...

dhiatensor's icon

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.

Thanks for your help!

-dh

Max Patch
Copy patch and select New From Clipboard in Max.

--

Peter McCulloch's icon

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

Max Patch
Copy patch and select New From Clipboard in Max.

ericsays's icon

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

Max Patch
Copy patch and select New From Clipboard in Max.

/****** 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 = [];
}
}
}