Goerzel algorithm - increasing accuracy I have an audio buffer with 1024 samples per second.
The sample rate is 44100.
I am trying to identify the frequency tones.
Using the Gorzel algorithm, I can get the frequency but it's not that accurate.
I was trying some other scope program and I got better results with the same hardware.
How can I decrease the id-bandwidth (to be sharper) so the id will be accurate for the target frequency?
(I can't use FFT because it's real time and takes some memory.)

float goertzel_mag(int16_t* data ,int SAMPLING_RATE ,double TARGET_FREQUENCY,int numSamples )
{
    int     k,i;
    float   floatnumSamples;
    float   omega,sine,cosine,coeff,q0,q1,q2,magnitude,real,imag;
    float   scalingFactor = numSamples / 2; // -2

    floatnumSamples = (float) numSamples;
    k = (int) (0.5 + ((floatnumSamples * TARGET_FREQUENCY) / SAMPLING_RATE));
    omega = (2.0 * M_PI * k) / floatnumSamples;
    sine = sin(omega);
    cosine = cos(omega);
    coeff = 2.0 * cosine;
    q0=0;
    q1=0;
    q2=0;

    for(i=0; i&lt;numSamples; i++)
    {
        q0 = coeff * q1 - q2 + data[i];
        q2 = q1;
        q1 = q0;
    }


    real = (q1 - q2 * cosine) / scalingFactor;
    imag = (q2 * sine) / scalingFactor;

    //double theta = atan2 ( imag, real); //PHASE
    magnitude = sqrtf(real*real + imag*imag);
    return magnitude;
}
There are two things you can do:


Use a different algorithm, like autocorrelation.
Use the phase information! This technique is discussed in chapter 9 of DAFX. You can find matlab source here.


DAFX discussed the phase-based technique using the FFT, but it should apply to Goerzel's algorithm as well, assuming you have real data at that frequency. The key concept is that you must note how much the phase changes over time to determine the exact frequency.

You may want to experiment with an FFT of smaller size instead of Goerzel's algorithm to validate the assumptions.