Make a bang if 0 appears for 1-2 seconds.

Apr 30, 2011 at 10:55pm

Make a bang if 0 appears for 1-2 seconds.

Hey there,
I’m working on a color tracking patch and ran into a rather basic problem.
I would like for my patch to produce a bang when it identifies an int 0 from both the X and Y axis.
The trick is I want this to happen only after one second of a constant 0 (from the X and Y).
the result would be that if I am tracking a color and it disappears from the screen for more than one second I would get a bang.

I’m thinking this should be done with some sort of delay but I couldn’t figure it out yet so I thought I should ask the good people of this forum.
Cheers,
UV

#56747
May 1, 2011 at 12:43am

there might be a simpler way– but I dont think [pipe] works in this context, hence using [delay]

– Pasted Max Patch, click to expand. –
#203362
May 1, 2011 at 1:07am

Here’s a slightly different approach.

– Pasted Max Patch, click to expand. –
#203363
May 1, 2011 at 1:28am

Just because I don’t like the [if] object, a slight modification to bkshepard’s patch ;)

– Pasted Max Patch, click to expand. –
#203364
May 1, 2011 at 1:34am

Nice! Out of curiosity, is the [if] object that much less efficient?

#203365
May 1, 2011 at 1:39am

not a huge difference, but on my machine when I benchmark the two patches with 10000 iterations, yours clocks in between 8.7-9.2 ms, whereas the other does between 7.2 and 7.5

your not gonna feel a difference between the two unless you are really , really starved for CPU cycles – or have 10000 of them running at the same time ;) -, but I was taught that the [if] statement is incredibly slow, so I avoid it when possible.

I will use it for instantiation (a one shot deal), but rarely in the inner workings of a patch.

#203366
May 1, 2011 at 1:48am

Thanks for the explanation. I, too, had always heard that it was better to avoid the [if] object when possible, but hadn’t ever noticed a problem. Probably because I usually only use one of them rather than 1000 ;-)

#203367
May 1, 2011 at 8:47am

Guys thanks so much for the simple and elegant patches. This will serve my project very well. This is why I love this community.
I’ll probably use the modified one without the [if].

Thanks a lot.
I have another burning question but I will post it later.
:)

#203368
May 1, 2011 at 2:41pm

hi !

just for reminding the “stop” message for delay :)

– Pasted Max Patch, click to expand. –
#203369
May 1, 2011 at 3:41pm

maybe make use of the skeptic object?

http://www.greyfade.com/joe/maxmsp.html

#203370

You must be logged in to reply to this topic.