title: Goertzel algorithm to get the phase?
body: <p>I am using Goertzel algorithm to get the amplitude of a certain frequency. 
  I am trying now to get the phase from it, and I don't know how.</p>
  
  <p>Can some one explain, and show me how to get the phase of a certain-f from this code? </p>
  
  <p>Also, I am using it to 16khz, with sample rate 44.1. What's the smallest length of samples that I can run it on?</p>
  
  <pre><code>double AlgorithmGoertzel( int16_t *sample,int sampleRate, double Freq, int len )
  {
      double realW = 2.0 * cos(2.0 * M_PI * Freq / sampleRate);
      double imagW = 2.0 * sin(2.0 * M_PI * Freq / sampleRate);
      double d1 = 0;
      double d2 = 0;
      double y;
      for (int i = 0; i &lt; len; i++) {
          y=(double)(signed short)sample[i] +realW * d1 - d2;
          d2 = d1;
          d1 = y;
      }
      double rR = 0.5 * realW *d1-d2;
      double rI = 0.5 * imagW *d1-d2;
  
      return (sqrt(pow(rR, 2)+pow(rI,2)))/len;
  }
  </code></pre>