-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMusicAnalyzer.h
More file actions
54 lines (36 loc) · 971 Bytes
/
MusicAnalyzer.h
File metadata and controls
54 lines (36 loc) · 971 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
42
43
44
45
46
47
48
49
50
51
52
53
54
#ifndef MusicAnalyzer_H
#define MusicAnalyzer_H
#include <Arduino.h>
#include "arduinoFFT.h" // Standard Arduino FFT library https://github.com/kosme/arduinoFFT
typedef struct
{
bool beat;
bool peakNow[10];
uint8_t freq[10];
uint8_t peak[10];
uint8_t resolution;
uint8_t loudness_computed=0;
uint8_t loudness=0;
uint8_t loudness_old;
uint8_t max_loudness;
} frq;
class MusicAnalyzer
{
public:
MusicAnalyzer(uint8_t pin, double *vReal,double *vImag,frq *pass_frequency, uint16_t samples, uint16_t sampling_frequency);
void sample();
void splitAuxValues(uint8_t reduce,uint8_t min_max_loudness);
void beatRecognize();
private:
arduinoFFT _FFT;
uint8_t _pin;
uint8_t _resolution;
uint16_t _samples;
uint16_t _sampling_frequency;
unsigned long readTime;
double *_vReal;
double *_vImag;
frq *_pass_frequency;
uint8_t setResolution();
};
#endif