You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 5, 2022. It is now read-only.
byte getAverageSample(byte samples[], unsigned int num, unsigned int pos, unsigned int step)
{
unsigned int ret;
/* This is the number of samples that will be used to create each
* average sample; i.e. all the skipped samples before and after
* the current sample */
unsigned int size = step * 2;
/* Don't do any averaging, if we are at the beginning or end
* of the sample window */
if (pos < (step * 3) || pos > (num * 3) - (step * 3)) {
ret = samples[pos];
} else {
ret = 0;
pos -= (step * 3);
/* Calculate the sum of 'step' samples before, and after,
* the current sample */
for (unsigned int i = 0; i < size; ++i) {
ret += samples[pos - (3 * i)]; **// ERROR: I think this should be pos + (3*i) since you already decremented pos right before this.**
}
ret /= size;
}
return (byte)ret;
}
The text was updated successfully, but these errors were encountered:
byte getAverageSample(byte samples[], unsigned int num, unsigned int pos, unsigned int step)
{
unsigned int ret;
}
The text was updated successfully, but these errors were encountered: