I suspect there are efficient algorithms for sliding window auto-correlation (which is often the core of fundamental frequency estimation).
Yeah I have a browser full of it at the moment. They kinda all work on the idea of 'how similar am I to myself when shifted X samples left/right?' My gist of it is that if the signal is very similar to itself 1 second ago, its a 1hz signal. Etc.
At least the harmonics of a guitar are multiples of each other. I'll be doing some experiments tomorrow with low-brow zero-crossing stuff (thanks for reminding me about the sliding window). I just hope that the arduino can handle 3khz sampling on multiple analogue pins.
I plan on doing a high-cut filter by using:
lowfreq(t) = ( y(t-1)+y(t) ) / 2 ; //half frequency by blurring with neighbour
smooth(t) = y(t) - lowfreq(t); // only high frequency remains by subtracting low frequency component.
Hopefully this will mean that all my zero-crossing stuff will be high-frequency only. I also realized that I don't need to DC bias the signal - the Arduino merely treating negative volts as 0 will actually be okay. Because if I'm counting zero crossings, I can just count 0.001 crossings and have practically the same result. Will even be above the noise floor.
Averaging two samples gives a low pass filter, with a cutoff of 1/2 the sample rate. If you have correctly filtered the input to not include any frequencies over half the sample rate, as they will alias back down and confuse things.
Also the way you are processing will cause phase shift as the subtraction isn't symmetrical.
Maybe try
lowfreq(t-1) = ( y(t-2)+y(t-1)+y(t) ) / 3
highfreq(t-1) = y(t-1)- lowfreq(t-1);
which is a (shabby) high pass at 1/3rd the sample rate. At a rough approximation that should leave all frequencies between 0.33 and 0.66 of the sample rate relatively untouched (and those greater than 0.5 shouldn't be there in the first place).
Also, be weary that some filters look to have no gain, but because of ripple and phase delays you can end up with positive gain under some unlikely inputs - so allow yourself a little headroom.