-
Notifications
You must be signed in to change notification settings - Fork 1
/
avspectrum.h
56 lines (41 loc) · 1.11 KB
/
avspectrum.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
48
49
50
51
52
53
54
55
56
#ifndef AVSPECTRUM_H
#define AVSPECTRUM_H
#include "avobject.h"
#include <functional>
#include <fftw3.h>
class AVSpectrum: public AVObject
{
public:
enum WindowType {
Square,
Hann,
Hamming,
Blackman,
BlackmanHarris
};
std::function<void(float, float, float)> dataCallback;
AVSpectrum(size_t window_size=4096, WindowType window_type=Square, float threshold=0);
virtual ~AVSpectrum();
const char * getName() { return "AVSpectrogram"; }
virtual size_t pull(float *buffer_ptr, size_t buffer_size);
virtual size_t push(float *buffer_ptr, size_t buffer_size);
private:
size_t _window_size;
WindowType _window_type;
float _threshold;
size_t _cnt_in;
fftwf_plan _plan;
fftwf_complex *_in;
fftwf_complex *_out;
size_t _low_cnt, _mid_cnt, _high_cnt;
float _low_rms, _mid_rms, _high_rms;
void _processDomain();
void _windowHann();
void _windowHamming();
void _windowBlackman();
void _windowBlackmanHarris();
void _postProcess();
void _processDb();
void _processLinear();
};
#endif // AVSPECTRUM_H