X-Git-Url: http://git.harvie.cz/?a=blobdiff_plain;f=c%2Fgoertzel%2Fgoertzel.c;h=85637ae43652097beb365abc5f943cdc8dc8a904;hb=8df6da88c80f10cb96ed53233ce6c4d414368059;hp=2cde63bfe2a015ef2ec398c99c3d69a1f958b3d5;hpb=9bd0f29973c4e65df394a95027707b7d33dbbebe;p=mirrors%2FPrograms.git diff --git a/c/goertzel/goertzel.c b/c/goertzel/goertzel.c index 2cde63b..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 = (q1 - q2 * cosine) / scalingFactor; - imag = (q2 * sine) / scalingFactor; + real = (q1 * cosine - q2) / scalingFactor; + imag = (q1 * sine) / scalingFactor; magnitude = sqrtf(real*real + imag*imag); + //phase = atan(imag/real) return magnitude; }