-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscore.ck
More file actions
115 lines (93 loc) · 2.21 KB
/
score.ck
File metadata and controls
115 lines (93 loc) · 2.21 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
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
TriOsc osc => ADSR env => dac;
(1::ms, 100::ms, 0, 1::ms) => env.set;
FileIO io;
StringTokenizer tok;
io.open("scores/song_moonlight_densetsu.txt", FileIO.READ) => int result;
// io.open("scores/linkin_park.txt", FileIO.READ) => int result;
// io.open("scores/score.txt", FileIO.READ) => int result;
Clape clape;
5 => clape.mOctave;
2::second => dur beat;
48 => int offset;
fun void ProcessComment(string line)
{
<<< line >>>;
}
fun void ProcessRest(string line)
{
tok.set(line);
tok.next() => string rest;
tok.next() => Std.atoi => int div;
<<< rest, div >>>;
beat / div => now;
}
fun void ProcessNote(string line)
{
tok.set(line);
tok.next() => string note;
tok.next() => Std.atoi => int div;
<<< note, div >>>;
clape.note2freq(note) => osc.freq;
//<<< "tok ", tok.more() >>>;
// note + offset => Std.mtof => osc.freq;
1 => env.keyOn;
beat / div => now;
}
fun void ProcessOctave(string line)
{
tok.set(line);
tok.next() => string op;
if (op == "OCT")
tok.next() => Std.atoi => clape.mOctave;
else if (op == "DOWN")
clape.octave_down();
else if (op == "UP")
clape.octave_up();
<<< clape.mOctave >>>;
}
0 => int lineStart;
0 => int numLine;
//while (true)
{
while (io.more())
{
string line;
if (numLine < lineStart)
{
// Jump lines
io.readLine() => line;
1 + numLine => numLine;
continue;
}
io.readLine() => line;
if (line.find ("//") == 0)
{
// Process comment
line => ProcessComment;
}
else if (line.find("R") == 0)
{
// Process Rest
line => ProcessRest;
}
else if (line.find("OCT") == 0 ||
line.find("DOWN") == 0 ||
line.find("UP") == 0)
{
line => ProcessOctave;
}
else {
line => ProcessNote;
}
}
0 => io.seek;
}
// while (!io.eof())
// {
// // read tokens
// io => string token;
// // read line
// // io.readLine() => string token;
// <<< token >>>;
// }
// // <<< result >>>;