Created
January 8, 2020 02:40
-
-
Save jaimedantas/ee380e225b79f0dca3662c4e8808071b to your computer and use it in GitHub Desktop.
Goertzel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Goertzel(float TARGET_FREQUENCY,float BLOCK,float SAMPLING_FREQ){ | |
SAMPLING_RATE=SAMPLING_FREQ; //9KHz for a 16MHz Arduino | |
TARGET=TARGET_FREQUENCY; //must be an integer of SAMPLING_RATE/N | |
N=BLOCK; //Block size | |
int k; | |
float omega; | |
//math | |
k = (int) (N * (TARGET_FREQUENCY / SAMPLING_RATE) + 0.93); | |
omega = (2.0 * PI * k) / N; | |
sine = sin(omega); | |
cosine = cos(omega); | |
coeff = 2.0 * cosine; | |
ResetGoertzel(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment