How do I make the trigger (smile) not work for a few seconds after it was detected?

I’m creating a filter with a text random selector.

My problem is - I can’t find a way to use the trigger once and then make sure that the trigger doesn’t affect anything for a few seconds before it starts working again.

In my case, the trigger is a smile, and I want to achieve the following effect:

  1. When the user smiles, the text becomes visible.
  2. The random selection process starts and stops after 2 seconds.
  3. A repeated smile should not affect anything for 5 seconds after the user smiled for the first time.
  4. After 5 seconds, the text will smoothly become invisible, and now the user can smile again to repeat everything again.

Here’s what I made.
My patch editor: Screenshot-2023-02-14-at-18-55-52 hosted at ImgBB — ImgBB
Here is a test link to try the effect: Instagram

As you can see, the problem is that a smile always works as a trigger, so if I smile often, I will generate text again and again, and the animation that makes the text invisible is out of sync with its generation and everything turns into chaos.

How do I make the trigger (smile) not work for a few seconds after it was detected?

You can keep track of a “ready” state and use that to control the flow of events. Here, I’m making a delay value for that state, and setting the initial value with a pulse merge (the initial value in the delay value doesn’t actually work here). Then you can follow the flow of events from the “ready” receiver and you’ll see that the ready state gets reset after 5 seconds. The if/else patch will block the pulse event if ready is false. The animation patch on the bottom is just an example of something you might trigger with a pulse.

spark-wait-until-ready.arexport (19.9 KB)


This is really an amazing and elegant solution, thank you so much!
I noticed that the 5-second animation only plays once, but if I connect the if/else output to the reset input of the 5-second animation, it will play again every time I click, and this cycle continues. Thank you again!

Oh! Yes, good catch :slight_smile:

Adding some more info… this technique is called input debouncing. It’s a common technique in programming. Maybe I’ll pack it up and put it in the asset library.


I guess debouncing doesn’t usually have a leading / blocking strategy, so I named this one Pulse Gate.

Pulse Gate in the Spark Library

Pulse Gate.arp (6.5 KB)

1 Like