-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.cpp
135 lines (105 loc) · 3.03 KB
/
main.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
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#include "GP3InputStream.h"
#include "GP4InputStream.h"
#include "GP5InputStream.h"
#include "TGFactory.h"
#include <fstream>
#include "TGBeat.h"
#include "TGStroke.h"
#include "TGChord.h"
#include "TGVoice.h"
#include <cstdio>
#include "DAS.h"
void showSong(TGSong* song)
{
for (int i=0; i<song->countTracks(); ++i)
{
TGTrack* t = song->getTrack(i);
printf("track name: %s\n", t->getName().c_str());
printf("offset: %d\n", t->getOffset());
printf("num of measures: %d\n", t->countMeasures());
printf("string count: %d\n", t->stringCount());
for (int j=0; j<t->countMeasures(); ++j)
{
printf(" measure %d\n", j);
TGMeasure* m=t->getMeasure(j);
for (int k=0; k<m->countBeats(); ++k)
{
printf(" beat %d\n", k);
TGBeat* b = m->getBeat(k);
TGStroke* s = b->getStroke();
printf(" stroke: dir=%d v=%d\n", s->getDirection(), s->getValue());
TGChord* c = b->getChord();
if (c)
{
printf(" chord: firstFret=%d stringsCount=%d\n", c->getFirstFret(), c->countStrings());
for (int l=0; l<c->countStrings(); ++l)
{
printf(" string: %d\n", c->getStrings()[l]);
}
}
TGVoice* v0 = b->getVoice(0);
//TGVoice* v1 = b->getVoice(1);
TGDuration* d0 = v0->getDuration();
//TGDuration* d1 = v1->getDuration();
for (int l=0; l<v0->countNotes(); ++l)
{
TGNote* n = v0->getNote(l);
printf(" v0 note: %d\n", n->getValue());
}
printf(" duration: %d\n", d0->getValue());
}
}
}
}
int main()
{
DumbAllocationSystem d;
bool b = d.initialize(1024*1024*4, 1024*1024);
if (!b)
{
printf("das init failed\n");
return -1;
}
das_set_global(&d);
if (1)
{
TGFactory factory;
GP3InputStream a;
std::ifstream f;
printf("highway_star.gp3\n");
f.open("highway_star.gp3", std::ios::in);
a.init(&factory, &f);
TGSong* song = a.readSong();
showSong(song);
// getc(stdin);
}
d.reset();
if (1)
{
TGFactory factory;
GP4InputStream a;
std::ifstream f;
printf("god_knows.gp4\n");
f.open("god_knows.gp4", std::ios::in);
a.init(&factory, &f);
TGSong* song = a.readSong();
// getc(stdin);
showSong(song);
}
d.reset();
if (1)
{
TGFactory factory;
GP5InputStream a;
std::ifstream f;
printf("smoke.gp5\n");
f.open("smoke.gp5", std::ios::in);
a.init(&factory, &f);
TGSong* song = a.readSong();
showSong(song);
//getc(stdin);
}
d.reset();
d.finalize();
return 0;
}