forked from jacobrosenthal/Goertzel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Goertzel.h
executable file
·48 lines (38 loc) · 1.35 KB
/
Goertzel.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
The Goertzel algorithm is long standing so see
http://en.wikipedia.org/wiki/Goertzel_algorithm for a full description.
It is often used in DTMF tone detection as an alternative to the Fast
Fourier Transform because it is quick with low overheard because it
is only searching for a single frequency rather than showing the
occurrence of all frequencies.
This work is entirely based on the Kevin Banks code found at
http://www.eetimes.com/design/embedded/4024443/The-Goertzel-Algorithm
so full credit to him for his generic implementation and breakdown. I've
simply massaged it into an Arduino library. I recommend reading his article
for a full description of whats going on behind the scenes.
See Contributors.md and add yourself for pull requests
Released into the public domain.
*/
// ensure this library description is only included once
#ifndef Goertzel_h
#define Goertzel_h
// include types & constants of Wiring core API
#include "Arduino.h"
#define MAXN 200
#define ADCCENTER 512
// library interface description
class Goertzel
{
// user-accessible "public" interface
public:
Goertzel(float,float,float);
Goertzel(float,float);
void sample(int);
float detect();
// library-accessible "private" interface
private:
void GetRealImag(float*,float*);
void ProcessSample(int);
void ResetGoertzel(void);
};
#endif