X-Git-Url: http://git.harvie.cz/?a=blobdiff_plain;f=c%2Fgoertzel%2Fgoertzel.c;h=85637ae43652097beb365abc5f943cdc8dc8a904;hb=128ba9ae44b6757a55af6d7fbc952ce925ecf69f;hp=19bfdf56eec479d9e372c6f1d3067241b0384fa2;hpb=599af17a2a0cc574095f2ec50971928ef5ef3ead;p=mirrors%2FPrograms.git diff --git a/c/goertzel/goertzel.c b/c/goertzel/goertzel.c index 19bfdf5..85637ae 100644 --- a/c/goertzel/goertzel.c +++ b/c/goertzel/goertzel.c @@ -29,10 +29,11 @@ float goertzel_mag(int numSamples,float TARGET_FREQUENCY,int SAMPLING_RATE, floa // calculate the real and imaginary results // scaling appropriately - real = (q2 - q1 * cosine) / scalingFactor; + real = (q1 * cosine - q2) / scalingFactor; imag = (q1 * sine) / scalingFactor; magnitude = sqrtf(real*real + imag*imag); + //phase = atan(imag/real) return magnitude; }