Skip to content
This repository has been archived by the owner on Aug 5, 2022. It is now read-only.

Error in example #40

Open
pmpeter1 opened this issue Mar 22, 2017 · 3 comments
Open

Error in example #40

pmpeter1 opened this issue Mar 22, 2017 · 3 comments
Labels
Milestone

Comments

@pmpeter1
Copy link

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;

}

@eriknyquist eriknyquist self-assigned this Mar 22, 2017
@eriknyquist eriknyquist added this to the Beta milestone Mar 22, 2017
@eriknyquist
Copy link
Contributor

Yeah, I think you're right. Thanks

@eriknyquist
Copy link
Contributor

Sorry, haven't had a chance to test/work on this yet, should do in the next week or two

eriknyquist added a commit to eriknyquist/Intel-Pattern-Matching-Technology that referenced this issue May 25, 2017
@eriknyquist
Copy link
Contributor

You're right, this was an error. Tested out the application with the fix and it still works fine

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants