Forums > MaxMSP

stupid list processing problem


Mar 09 2013 | 7:23 pm

ok, this is embarrasing because i’m quite sure this is dead drop simple but somehow the solution keeps hiding from me…:

i have a stream of single numbers coming in, ranging from 0 to 50.000.
now i want to simply filter out any number where the difference to the last one is bigger than 100.
i get it almost to work with a bucket and a gate if there is only one false number but not if there are consecutive false ones because then the bucket fills up with false numbers…

the output should be like the following:
input — output
20 — 20
80 — 80
10 — 10
1000 — 10 (blocked because difference > 100)
500 — 10 (blocked because difference > 100)
300 — 10 (blocked because difference > 100)
109 — 109
60 — 60
150 — 150
10 — 150 (blocked because difference > 100)
etc.

how would i do that?
thanks for helping out…
k

Mar 09 2013 | 10:30 pm

Something like this?


-- Pasted Max Patch, click to expand. --

Mar 10 2013 | 1:03 am

or this?
(basically the same concept)


-- Pasted Max Patch, click to expand. --

Mar 10 2013 | 1:55 pm

yes, precisely like this. i was stuck with the idea of needing a bucket but this is much more elegant – comfys patch does exactly what i was trying to do!
once again, thank you so much for the help!
k

Mar 10 2013 | 2:56 pm

A compact 3 object version:


-- Pasted Max Patch, click to expand. --

Mar 10 2013 | 3:26 pm

Nice one Nicolas! I had no idea about zl’s stream mode or that you could put the code I had in expr into ‘if’ – super useful.


ak
Mar 10 2013 | 4:28 pm

@leafcutter: almost… ;-)

-- Pasted Max Patch, click to expand. --

Personally I’m disappointed that nobody posted GEN solution…

Mar 12 2013 | 5:25 pm

Here’s one that checks against last input and another that checks against last output.

cheers


-- Pasted Max Patch, click to expand. --

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

Forums > MaxMSP