Decay and Increment Value Over Time

This is a technique for decaying & increasing a value over time.

My goal was to increase a value by a set amount each time a user interacted with a button. I needed that same value to also consistently decrease at a set rate (10 per frame).

Initially I attempted to use the beat chop & a chop exec to decrease a the value at a set rate.
However the chop exec was proving computationally expensive for a seemingly simple operation (decreasing the value of a number)

Instead I found a solution (with help from the Derivative team) using a speed chop. You connect a constant chop with a negative value as the speed chop’s input 0 (rate). This will ensure that the value is consistently decreasing over time.

There are two different ways to increase the value.

  1. Increase at a set rate (value ramps): Instead of connecting the negative value constant chop directly to the speed chop, connect it to a switch chop. Also connect a positive value constant chop to the switch. Connect the switch to the speed chop then change between the switch inputs in whichever way you see fit. [Code contained in ‘Decrease.toe’]

  2. Increase by a set amount in a single frame (value jumps): Connect a panel exec to the user interaction. When the behavior you are looking for occurs, increment the speed chop’s reset value by the amount you wish to increment your value. Then pulse the speed chop. This will make the speed chop’s value jump and then continue decreasing over time. [Code contained in ‘Speedbump.toe’]

code for changing speed chop with jump method:

        sbop = op('speedChop1')
        sbop.par.resetvalue = sbop[0] + 1.2

I have attached two files with the content for how to do both methods.

speedBump1.tox (1.8 KB)
decrease.tox (1.26 KB)

5 years late but thank you! This is exactly what I needed for a visual!

The Count CHOP is also useful for this. See the examples in OP Snippets.