-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaudio.cpp
25 lines (24 loc) · 889 Bytes
/
audio.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
#include<bits/stdc++.h>
#include"libaudio.h"
using namespace std;
int main(int argc, char** argv) {
wavFile wav;
wav.open(argv[1]);
wav.outputBasicInfo();
audioData audio = audioData(wav, true, 20);
specturmData sp = specturmData(audio, 48, true, 20);
beatData beat = beatData(sp, 10, 1.1);
beat.drawGraph("test.svg");
beat.onsetDetection(0.1);
int beatNum = beat.fetchBeatNum();
float* beatTime = beat.fetchBeatTime();
cout << "Beat Number: " << beatNum << endl;
ofstream fout(argv[2]);
stringstream notes;
for (int i = 0; i < beatNum; i++) {
notes << "{\"type\": \"Single\", \"lane\": " << rand() % 7
<< ", \"beat\": " << 2 * beatTime[i] << "}" << (i != beatNum - 1 ? ", " : "");
}
fout << "[{\"type\": \"System\", \"cmd\": \"BPM\", \"beat\": 0, \"bpm\": 90}, ";
fout << notes.str() << "]";
}