Autocorrelation algorithm fails in high frequencies
<p>i have a problem in my guitar tuner. I'm using autocorrelation algorithm to find the sound frequency. It works almost. Problem starts in high frequencies over 300hz. Sometimes it's not sure is it 329hz or 109hz when i'm playing E4(329hz) string, subharmonic problem i think. Now i'm asking how i can eliminate those subharmonics? Any tricks?</p>

<p>here's my autocorrelation code:</p>

<pre><code>for (int i = 0; i &lt; length; i++) {
    double diff = 0;
    for (int j = 0; j &lt; length; j++) {
        diff += Mathf.Abs (buffer [j] - buffer [i + j]);
    }

    double dx = prevDiff - diff;

    if (dx &lt; 0 &amp;&amp; prevDx &gt; 0) {

        if (diff &lt; (0.3 * maxDiff)) {

            if (sampleLen == 0) 
            {
                sampleLen = i - 1;
            }
        }
    }

    prevDx = dx;
    prevDiff = diff;
    maxDiff = Mathf.Max ((float)diff, (float)maxDiff);
}
</code></pre>