-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBassListener.h
More file actions
41 lines (28 loc) · 922 Bytes
/
BassListener.h
File metadata and controls
41 lines (28 loc) · 922 Bytes
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
#pragma once
class BassListener
{
public:
BassListener(int micPin);
bool readMic();
bool hasHit() const { return hit; }
void setSensitivity(int sens);
int getLastFrameAvgAmp() const { return lastFrameAvg; }
private:
const int pin;
int count;
int frameAvg;
int frameMin;
int frameMax;
long frameStart;
int lastFrameAvg;
static const int AMPBUFFER_SIZE = 50; //12; //15;
int idxAmpBuffer;
int ampBuffer[AMPBUFFER_SIZE];
int hitCooldown;
bool hit;
float sensitivity;
int completeFrame();
void ampBufferWrite(int amp);
void ampBufferEval(int* minAmp, int* maxAmp, int* avgAmp) const;
bool evalHit(int amp, int minAmp, int maxAmp, int avgAmp);
};