routing repeating values

WPPK's icon

Hi all, I was wondering if anyone could point me in the right direction here. Sorry if there is a simple solution i am overlooking but my brain is hurting right about now.

I am looking for an object or objects from which I can build an abstraction that will analyze an incoming stream of numbers and route any repeating numbers in that stream to a different location than the others.

If a 1 is followed by a 1 then both 1s go left, and then if three 2's follow those 1s they also go left.
single digits go the opposite way.

Any help would be greatly appreciated. just point me in the right direction.

Thanks

WPPK's icon

Oh yeah, It only needs to re route values that are the same one right after the other. If a 1 is followed by a zero and then a 1, it would not need to be re routed.

WPPK

Chris Muir's icon

Well, as with most things in Max, there are many ways to accomplish this.

You'll need to delay output by one number, so int, float or maybe bucket would work here.

Next you'll need to compare the latest number to the previous number. sel or == would work here.

Finally, something like [gate 2] could steer the output to different places.

-C

Luke Hall's icon

This abstraction will do what you want. It is a little bit more complicated than Chris tried to explain as you need to check the value before and after to see whether they are the same or different. However this does mean that the output is one step behind the input.

lh

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

WPPK's icon

Thanks a lot for your help guys.

No problem about the I/O latency, because I'm just storing the data.

I've got another question, I'm assuming that the || symbol in the if statement is C language syntax. What exactly does it mean?

Thanks again!

~WPPK

Luke Hall's icon

It means "or", you can also use && which means "and" they're useful for setting conditions in [if] statements.

lh