I have some code, shown below that I have been using to find the fundamental of a guitar string. After this function is called, I go thru the real buffer and find the peak, whose location gives me the period of the fundamental. Now I have a need to find the phase of the fundamental in relation to the start of the buffer. Is there a way to find this phase from the info available in the code?
If this is not possible, is there a better algorithm to find both the fundamental and it's phase?
void AutoCorrelate(int real[],int imag[],int N,int sine[]){
fftTwiddle(real, imag, N);
fftForward(real,imag,N,sine);
for (int i=0;i<N;i++)
{
int h;
unsigned int l;
MACS(h,l,real[i],real[i],0,0);
MACS(real[i],l,imag[i],imag[i],h,l);
imag[i] = 0;
}
fftTwiddle(real, imag, N);
fftInverse(real,imag,N,sine);}