Summing a Series of Numbers Cumulatively

James Thomer's icon

Hi, very simple question here that I can't seem to find the answer for. I want to set up a series of bangs that send out individual numbers when triggered that add up with each other. I'm using the accum function and have a basic example attached. Wondering if there is a better way of doing this? Also, I ideally would only want the bang to be triggerable once, to prevent a number from being hit twice in a row. Thank you!

accum test.maxpat
Max Patch

Source Audio's icon

next time upload copy- compressed patch.

you can insert onebang 1 between bang and number ...

TFL's icon

Basically you want to make a simple addition with [+] and feed its result back into its right, cold inlet:

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

James Thomer's icon

Thank you! Both examples are very helpful.

James Thomer's icon

Ok, now I'm trying to add two sets of numbers together to see their summed result, but getting some weird results. How do I create a summed number object for the two sets of addition? For example in my screenshot 24 + 16 should equal 40, but I'm getting 56, etc.

counter test.maxpat.zip
zip

Wil's icon

addition and accumulated are different

order in which they are banged gives different final accumulation

if you just click 10 and 14 the first accumulate add them together = 24

but the second accum is adding the first 10 + the new 24 = 34


Source Audio's icon

Could you explain what you want to achieve finally,

maybe there are better ways to collect and sum incoming numbers.

Including conditions, like if repetitions from any source are allowed or not,

or anything else that counts.