Sum Values in an Array

I’m sure someone can help me here, this must be REALLY simple, but I just don’t have the logic to do it…

Every time px is greater than 1, I want to store this value, and sum with all the others that are also greater than 1.
In this case, if px is always 2, after the 800 instances of i, PeakBufferLeft1 is going to be 1600, but it is never 1600, cause there some math code missing that I don’t know…

for (int i = 0; i < bufferSize; i++) //bufferSize is 800

if (px[i] > 1) {
PeakBufferLeft1 = px[i];
}

What am I missing?

I assume you initialize PeakBufferLeft1 somewhere before as:

int PeakBufferLeft1 = 0;

Then use should be able to use += like:

PeakBufferLeft1 += px[i];

?

Oh my good, this was even simpler than I though!

Thanks a lot skyl

Then I’ll need to delete all that summed values after i is back to 0, but this I think I know how to do it.

Thanks again!