do things only when number / value is changing more than x

franzkafka's icon

hi.

last question :)
i have a values / numbers that change every 200 ms. if the number reaches a specific value something happens.
but i want to start that "happening" only if the number changes more than 3. how could i do this?

for the moment i try to reach this status when nothing is happening by two if-statements (if number is higher then do that, if number is lower then do that). but it is not very elegant for what i am really looking for.

i need a way to compare the last signal with the current signal and if the number is higher than 3 then start my function.
help would be great!

brendan mccloskey's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Hi
this is what I would do; but you don't specify exactly what the range of incoming numbers is, so the example below uses [random] for that part:

Brendan

franzkafka's icon

Hi Brendan!

thank you for this helpful response.
i attached an image… this is my current solution.

your example is great! i will use this instead… but do you have an idea how i can get the values to "makenote" after this "filter of changing more than 3". it is hard to explain… i have to connect the values after checking if the value has changed more than 3… you know what i mean? i don't have a clue.

can i save it in a variable?

Bildschirmfoto-2014-01-28-um-22.28.52.png
png
metamax's icon

You can use the [> 3] to gate the values.

Max Patch
Copy patch and select New From Clipboard in Max.

franzkafka's icon

perfect. thank you.

LSka's icon

also, the [lbyl] external could be interesting for you:
http://cnmat.berkeley.edu/patch/4067