CHOP gradually add samples together

Hello, I have quite simple question but can’t seem to come up with an elegant solution. Lets say I have multiple width values in CHOP (either multiple channels, or multiple samples in single channel) and would like to modify them to represent something like distance.
That means each value should be sum of all previous values + its value. Please what would be a preferred way of doing so? :slight_smile: I thought of Script CHOP which is certainly capable of solving such problem with a simple for loop in python, but maybe there is some more elegant way?

I would use math chop with “Combine Channel - Add” and Scope to add some channels.

Do you need that for every channel or do you just want to add al channels together?
I think the speedCHOP might be the right thing for you. This will add the input value to itself over 1 second continiusly. TO get it every frame just multiply it by the framRate of your project.

If I understand your question, you can obtain partial sum with chop execute as that.
Capture d’écran 2020-07-15 à 11.27.53

def onValueChange(channel, sampleIndex, val, prev):
c = op(str(me.par.chop))
op('constant2').par.value0= c['chan1'] + c['chan2']
op('constant2').par.value1= c['chan1'] + c['chan2'] + c['chan3']
op('constant2').par.value2= c['chan1'] + c['chan2'] + c['chan3'] + c['chan4']
return

Thanks for answers, I should have attached sample scene to better illustrate what I am after - sorry. I did that now, with the use of Script CHOP. Please feel free to take a look at it here:

CHOP_add_up_samples.2.toe (3.8 KB)

Even though this approach is fine, I thought there might be more elegant way of doing it. But maybe there isn’t and python for loop is best way to do it, I don’t know. :slight_smile:

@alphamoonbase It might be that Speed CHOP could solve it, however I am not sure how should that work. I will try to experiment with it to see if I could see the solution, thanks.

Hello,
Another solution with chopexec.
CHOP_add_up_samples.3.toe (4.0 KB)

Thanks, this works nicely for fixed channel count, but I would ideally like to run it on arbitrary number of values. That is why I am a bit worried about python for loop as it might get heavy with large number of values.

Hello,

Another version working on arbitrary number of values. Unfortunately its necessary to pass through DAT because its not possible to recursively activate channels on chop OP. You have to test it with a very large number of channels, but I think its perfect until 100. In your proposition, script chop is not changing the number of samples.
CHOP_add_up_samples.4.toe (4.2 KB)

Oh, I didn’t notice Script CHOP won’t update when channel count changes, thank you very much for info. It seems it can’t even be force-cooked in such case, hmm.

Thanks for taking the time to create system with DATs, it works nicely and updates as expected. However I have tried to measure its performance and it seems to be quite heavy when using many channels. This is a trail of its cook_time compared to the Script CHOP (both running on 50 channels). Nevertheless it is a good solution, but it is still tempting me to look for some super-lightweight solution :slight_smile:

Capture

1 Like

@alphamoonbase is right, a speed chop will do this for ya. Very useful trick I didn’t know about until recently -

turn off time slice, then put a math chop after and multiply the results by your project’s fps (60 in most cases)

1 Like

Wow, this is very nice solution. Thank you all very much for help. I have been experimenting with Speed CHOP as @alphamoonbase suggested, but I didn’t realize I had to disable time slice. :slight_smile: Thanks once again!

I made a test with speed but its not so useful, because you have a null result for the first and you dont have the last sum…
testChop.toe (3.7 KB)

I believe that is not a problem as you can just add Trim CHOP before Speed CHOP in order to add one sample at the end of channel (that way you will get last sum) :slight_smile:.