Skip to content

Instantly share code, notes, and snippets.

@jaimedantas
Created January 8, 2020 02:40
Show Gist options
  • Save jaimedantas/ee380e225b79f0dca3662c4e8808071b to your computer and use it in GitHub Desktop.
Save jaimedantas/ee380e225b79f0dca3662c4e8808071b to your computer and use it in GitHub Desktop.
Goertzel
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