Delay one event but not another?

I am trying to delay an OSC message that I am sending to SuperCollider everytime I receive a char over Serial from Arduino so that it is only sent to SuperCollider every 3200ms instead of 60 times per second as in draw(). I am also using the char from Arduino to trigger a video to play in Processing. The videos are triggered on char conditions in if statements inside of draw().

The problem is that in delaying the OSC message, I am also delaying the video playback. I tried placing the OSC message in its own if statement, and then in a function named soundEvent() that I called inside of draw.

Anyone have any ideas?

Answers

  • Answer ✓
    • I guess Serial library provides a callback which triggers whenever it gets an input.
    • If you rely on that, that will be independent from draw() and you won't need any delay().
  • So I should try putting my sound event if statement inside of serialEvent() rather than draw()?

  • Well I did that and it worked! I'm not sure how many times per second serialEvent is running so I kept the delay. I assume it is 60, too. But with the delay, it's smooth sailing. Thanks!

Sign In or Register to comment.