Guitar pitch detection with autocorrelation
Cons: Not as accurate


This is just compared to the other methods.  I was measuring frequency very accurately to look for clock drift, etc: 1000.000004 Hz for 1000 Hz, for instance.  For guitar pitch detection it will be fine.


  doesn't work for inharmonic things like musical instruments


I should have said "it can't find an accurate fundamental if there is inharmonicity".  It will be shifted up because the plucked string partials are slightly sharp.

In your case, you don't want to find the fundamental, though, you want to find the perceived pitch, which is what autocorrelation is good at.  (though I don't know how accurate, and if it needs weighting, etc.)

http://www.utdallas.edu/~assmann/hcs6367/yost09.pdf

https://ccrma.stanford.edu/~dattorro/Humans.pdf


  this implementation has trouble with finding the true peak


because autocorrelation will produce peaks at the correct frequency but also at all its sub-harmonics, and this function just naively chooses the highest peak.  You need to plot the correlation curve and find a way to choose the correct results for your waveforms.