Questions ? Ask here..

Any questions regarding postings or new requests dont hesitate to ask here..

Goertzel(modified FFT) algorithm implementation in c

 Goertzel(modified FFT) algorithm :

     The Goertzel algorithm is used to detect DTMF tones in telecom(Dual Tone Multi Frequency) with less CPU hourse power than the traditional FFT algorithm.

     I assume all the readers are well known of the algorithm so i give you example code api to implement it
/* Add FFT,Goertzel,Chirpz filtering techniques here */

/**************** 1. Goerzel method ***************************************
Description:
audioBlockSize : Size of the audio block (number of samples to be processed)
audioBuffer    : Actual samples of audio data (double)
sampleFreq     : Sample Rate or sampling Frequency (CCITT - telephone voice )
                 8000 Samples per second

targetFrequency: The frquency to test whether it lies in the sample block of processing
Energy value   : Magniture squared outpput value which will futher used to set
                 Threshold

Fix this       :---------
***************************************************************************/

double goerzelFilter(unsigned short audioBlockSize,  /* CCITT standard block Size */
                     double *audioRingBuffer,        /* Circular Audio Samples Buffer Input */
                     unsigned int SamplingFrequency, /* Sampling Rate of the Sampled signal */
                     unsigned int targetFrequency,   /* Which Frequency range want to detect */
                     int EnergyValue)                /* total Energy value Threshold to detect the Frequency range */
{

    /* Init Goertzel Filter  */
    int j = 0;
    double omega;
    int k;
    double cosines;
    double p;
    float Q0;
    float Q1;
    float Q2;
    double magnitude;

    //coefficient calculation;
    k = (int)(0.5 + ((audioBlockSize * targetFrequency)/ SamplingFrequency));
    omega   = ((2 * PI)/ audioBlockSize) * k;
    cosines = cos(omega);
    p = 2.0 * cosines;

    //goertzel detetion
    Q1 = 0.0;
    Q2 = 0.0;
    for(j = 0; j < audioBlockSize ; j++)
    {
        Q0 = (p * Q1)- (Q2 + audioRingBuffer[j]);
        Q2 = Q1;
        Q1 = Q0;
    }
    magnitude = sqrt(Q1 * Q1 + Q2 * Q2 - (Q1 * Q2 * p));
}