Search code examples
c#algorithmgoertzel-algorithm

How can i implement the Goertzel Algorithm with this?


I got the code here: https://naudio.codeplex.com/discussions/270762.

The goertzel algorithm goes like this:

    public double goertzel(List<double> sngData, long N, float frequency, int samplerate)
    {
        double skn, skn1, skn2;
        skn = skn1 = skn2 = 0;
        samplerate = this.sampleRate;
        frequency = this.freq;

        double c = 2 * pi * frequency / samplerate;
        double cosan = Math.Cos(c);

        for (int i = 0; i < N; i++)
        {
            skn2 = skn1;
            skn1 = skn;
            skn = 2 * cosan * skn1 - skn2 + sngData[i];
        }

        return skn - Math.Exp(-c) * skn1;
    }

I want to transform the audio data (from wave file reader in the link above) by using that algorithm. How can i do that? Thanks


Solution

  • If you're doing DTMF detection, try "phoneToneDecoder" COM. it detects DTMF tones from your sound card. (i think it's proprietary)