Arduino pitch detection in realtime (using autocorrelation and peak detection)

MrMark, thank you for the very clear explanation and the feedback on my coding. My next step will be to implement interpolation and use lower sample frequencies. Is there a structural way to determine the best relation between the sample frequency and signal capture time, besides trial and error?