-
Notifications
You must be signed in to change notification settings - Fork 14
/
chord_detector_wrapper.cpp
62 lines (49 loc) · 1.4 KB
/
chord_detector_wrapper.cpp
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
#include <Chromagram.h>
#include <ChordDetector.h>
#include <emscripten.h>
#include <stdio.h>
using namespace std;
extern "C" {
void *Chromagram_constructor(int frameSize, int samplingFrequency) {
Chromagram *c = new Chromagram(frameSize, samplingFrequency);
return c;
}
void Chromagram_destructor(Chromagram *c) {
delete c;
}
void Chromagram_processAudioFrame(Chromagram *c, double* frames) {
c->processAudioFrame(frames);
}
int Chromagram_isReady(Chromagram *c) {
if (c->isReady()) {
return 1;
} else {
return 0;
};
}
void Chromagram_getChromagram(Chromagram *c, double* chromaDest) {
std::vector<double> chroma = c->getChromagram();
for(int ii = 0; ii < 12; ii++) {
chromaDest[ii] = chroma[ii];
}
}
void *ChordDetector_constructor() {
ChordDetector *c = new ChordDetector();
return c;
}
void ChordDetector_destructor(ChordDetector *c) {
delete c;
}
void ChordDetector_detectChord(ChordDetector *c, double *chroma) {
c->detectChord(chroma);
}
int ChordDetector_getRootNote(ChordDetector *c) {
return c->rootNote;
}
int ChordDetector_getQuality(ChordDetector *c) {
return c->quality;
}
int ChordDetector_getIntervals(ChordDetector *c) {
return c->intervals;
}
}