# How increasing value can triggers a bang?

It is more like a general discussion, but it looks like a basic operation for me and this is why I am posting it here… I tried some things but doesn’t work as I need it.

I need a chop chain where I have increasing and decreasing value where +1 (any time it increase) gives a bang to a Trigger and -1 (any time it decrease) don’t do nothing so the Trigger stays 0. Tried with Logic, Count, Trigger… Logic Chop has a par On when value changed, but in this case I want On when value increase which would work perfect but it is missing.

There is a tox attached with not-working-as-I-need-it example.

Looks like a basic operation, is it possible with chops, am I missing something obvious? Or I need to put some python script for this and if yes, what would be this script?
bangChain.tox (1.34 KB)

There is definitely a way to do this with a CHOP Execute DAT and python scripting.

There is a callback in the CHOP execute DAT that runs every time there is a value change with the arguments ‘val’ and ‘prev’ being passed in. These are the current value and previous of the CHOP. You can set up an “If” statement to check the current value against the previous and if it’s higher hit the trigger pulse.

However, this will eat cycles if your count increases quickly.

Hey,

you can use a Slope Chop, it will give you a positive value when the input increases and a negative value when it decreases. Append a Limit CHOP to clamp the negative valus and then use a Logic CHOP to feed your Count.

Cheers
Markus

1 Like

thanks marcus, i knew there was a way to do this with chops! slope/derivative chop is great, and this chain that you recommended works fine in the case. There was also a work around with some script for this, as the method suggested by Giovanni Sgambato also worked:
bangChain_gio_version.tox (3.14 KB)

Thanks for giving credits
gio