I've implemented a simple autocorrelation routine against some audio samples at a rate of 44100.0 with a block size of 2048.

The general formula I am following looks like this:

```
r[k] = a[k] * b[k] = ∑ a[n] • b[n + k]

```

and I've implemented it in a brute-force nested loop as follows:

```
for k = 0 to N-1 do 
    for n = 0 to N-1 do
        if (n+k) < N 
            then r[k] := r[k] + a(n)a(n+k)
    else
        break;
    end for n; 
end for k;

```

I look for the max magnitude in r and determine how many samples away it is and calculate the frequency.

To help temper the tuner's results, I am using a circular buffer and returning the median each time. 

The brute force calculations are a bit slow - is there a well-known, faster way to do them?

Sometimes, the tuner just isn't quite as accurate as is needed. What type of heuristics can I apply here to help refine the results?

Sometimes the OCTAVE is incorrect - is there a way to hone in on the correct octave a bit more accurately?