-
Notifications
You must be signed in to change notification settings - Fork 2
/
features.h
67 lines (55 loc) · 1.55 KB
/
features.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
57
58
59
60
61
62
63
64
65
66
67
#ifndef FEATURES_H
#define FEATURES_H
#include <iostream>
#include <vector>
#include <map>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#include <xtract/libxtract.h>
#include <xtract/xtract_stateful.h>
#include <xtract/xtract_scalar.h>
#include <xtract/xtract_helper.h>
/*
* Features that are useful and can be extracted by this module:
* Scalar features:
* - [a] - ZCR (Zero cross rating)
* - [b] - HZCRR (high zero cross rate ratio)
* - [c] - kurtosis
* - [d] - skewness
* - [e] - Spectral mean
* - [f] - Spectral variance
* - [g] - Spectral deviation
* - [h] - Spectral centroid
* - [i] - Spectral kurtosis
* - [j] - Spectral skewness
* - [k] - Sharpness
* - [l] - Loudness
* - [m] - RMS (root mean square)
* Vector features:
* - [n] - LPC (linear predictive coefficients) [LPCC is bugged]
* - [o] - MFCC (mel-frequency cepstral coefficients)
* - [p] - Bark frequency coeficcients
* - [q] - PLP (perceptual linear prediction)
*/
using namespace std;
template <typename T> int sgn(T val) {
return (T(0) < val) - (val < T(0));
}
class soundFeatures
{
private:
int subWindow;
long wavSamples;
double *wavData;
int samplerate;
map<char, vector<double> > result;
public:
soundFeatures();
~soundFeatures();
void setData(double *data, long n, int window, int samp);
void clearFeatures();
map<char, vector<double> > calcFeatures (string , int windowStart, int windowLength);
};
#endif // FEATURES_H