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


    Apr 30 2011 | 10:55 pm
    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

    • May 01 2011 | 12:43 am
      there might be a simpler way-- but I dont think [pipe] works in this context, hence using [delay]
    • May 01 2011 | 1:07 am
      Here's a slightly different approach.
    • May 01 2011 | 1:28 am
      Just because I don't like the [if] object, a slight modification to bkshepard's patch ;)
    • May 01 2011 | 1:34 am
      Nice! Out of curiosity, is the [if] object that much less efficient?
    • May 01 2011 | 1:39 am
      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.
    • May 01 2011 | 1:48 am
      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 ;-)
    • May 01 2011 | 8:47 am
      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. :)
    • May 01 2011 | 2:41 pm
      hi !
      just for reminding the "stop" message for delay :)
    • May 01 2011 | 3:41 pm
      maybe make use of the skeptic object?