Forums > MaxMSP

Time based if statements

August 31, 2013 | 8:20 am

Is there a simple way to do something this: [if $f1 is < x after y milsecs then bang]?

I feel like this shouldn't be hard but brain is a bit fried today.
Thanks


August 31, 2013 | 9:10 am

Hi
an element of the logic is missing: which condition starts the calculation of elapsed time? You might want to look at [clocker] and [==] or [&&], and perhaps post an example patch demonstrating the source of values and conditions to test for.

Brendan


August 31, 2013 | 9:13 am

maybe not what you are after but it works…

– Pasted Max Patch, click to expand. –

edit: actually it doesn’t really work but I’ll leave it up rather than a blank post.


August 31, 2013 | 9:22 am

<code>

– Pasted Max Patch, click to expand. –

</code>


August 31, 2013 | 9:24 am

The question’s not quite clear.

If what you’re trying to ask is "if $f1 is < x now, and remains less than x for the next 100 msec, then do something" the basic way to go about it is to start a [del 100] at now, and if, at any time in the next 100 msecs the condition breaks, then send a ‘stop’ message to the [del] object, cancelling the scheduled event.

This is the standard technique from the "Time-Based Event Handling 101" lecture notes. Useful one to have up your sleeve, even if it’s not what you’re after right now.


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