0
$\begingroup$

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);}
$\endgroup$
  • $\begingroup$ have a look to this question: dsp.stackexchange.com/questions/9514/… $\endgroup$ – Behind The Sciences May 5 '16 at 6:02
  • $\begingroup$ That is interesting but is comparing the phase between two signals. The only way I can think of using this is to recreate a reference signal at the fundamental frequency and use the window on this signal where I think the original signal is. I didn't explain that well, but this method seems dodgy and subject to drift error. $\endgroup$ – Chuck Carlson May 5 '16 at 13:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.