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

Basically an array, with an input pointer and an output pointer given by variables. Two ways you can arrange this but nothing much to choose between them. Have the input pointer pointing to the next free buffer space and the output pointer to the next output value. When ever you put something in or take something out you increment the pointers and make them wrap round, that is start again at zero when it reaches the size of the array.

If on incrementing the input pointer it exceeds the output pointer then your buffer has overflowed.