-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCSVtoMascii.cpp
More file actions
87 lines (87 loc) · 1.96 KB
/
CSVtoMascii.cpp
File metadata and controls
87 lines (87 loc) · 1.96 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
for(int x=1;x<=1;x++)
{
char *name1, c = 'a';
int y = 0, div = 0, basetime = 0, endtime = 0;
vector<vector<string>> v;
vector<int> Note[200];
vector<char> Time[80000];
string num, on = "Note_on_c", off = "Note_off_c", head = "Header";
bool Tr[88] = {0};
num = to_string(x);
num.append(".csv");
name1 = &num[0];
FILE *fp1 = fopen(name1, "r"), *fp2 = fopen("input.txt", "a+");
if(!fp1||!fp2)
{
printf("ERROR!\n");
continue;
}
c = fgetc(fp1);
while(c!=EOF)
{
vector<string> tmp;
while(c!='\n'&&c!=EOF)
{
string temp;
while(c!='\n'&&c!=','&&c!=EOF)
{
if(c == ' ') c = fgetc(fp1);
if(c == '\n'||c == ',') break;
temp.push_back(c);
c = fgetc(fp1);
}
tmp.push_back(temp);
if(c == '\n') break;
c = fgetc(fp1);
}
v.push_back(tmp);
c = fgetc(fp1);
}
for(int i=0;i<v.size();i++)
if(v[i][2]!=head&&v[i][2]!=on&&v[i][2]!=off)
v.erase(v.begin()+i--);
/*else if(v[i][2] == head) v[i][2] = "h";
else if(v[i][2] == on) v[i][2] = "n";
else if(v[i][2] == off) v[i][2] = "f";*/
for(int i=1;i<v.size();i++)
{
v[i].erase(v[i].begin());
v[i].erase(v[i].begin()+2);
v[i].erase(v[i].end());
}
div = stoi(v[0][5]);
v.erase(v.begin());
v.pop_back();
for(auto i:v)
{
basetime = min(basetime, stoi(i[0]));
endtime = max(endtime, stoi(i[0]));
}
endtime = 8*(endtime-basetime)/div;
printf("%d: %d %d %d\n", x, div, basetime, endtime);
for(auto i:v)
Note[stoi(i.back())].push_back(8*(stoi(i.front())-basetime)/div);
for(int i=0;i<200;i++)
if(Note[i].size()>0)
for(auto j:Note[i])
Time[j].push_back(i+12);
fprintf(fp2, "\n\n%d\n\n", x);
for(int i=0;i<endtime+100;i++)
{
for(auto j:Time[i])
Tr[j] = 1-Tr[j];
for(int j=0;j<200;j++)
if(Tr[j])
fprintf(fp2, "%c", j);
fprintf(fp2, " ");
}
for(int i=0;i<100;i++)
fprintf(fp2, " ");
fclose(fp1);
fclose(fp2);
}
}