-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rain.pde
296 lines (249 loc) · 5.9 KB
/
Rain.pde
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
import processing.opengl.*;
import ddf.minim.*;
import fullscreen.*;
//Projection
import processing.opengl.*;
import codeanticode.glgraphics.*;
import deadpixel.keystone.*;
GLGraphicsOffScreen offscreenA;
GLGraphicsOffScreen offscreenB;
Keystone ks;
CornerPinSurface surfaceA;
CornerPinSurface surfaceB;
Minim minim;
AudioSample beep;
AudioInput input;
float audioLevel = 0;
int audioGain = 50;
float audioThreshhold = 0;
FullScreen fs;
PFont font;
PShape dropShape;
PShape cloudShape;
int bpm = 60;
int tapBpm = 0;
int lyricSelect = 0;
int marginTopHud = 0;
boolean dynamicTempo = true;
boolean rainSwitch = true;
boolean lyricSwitch = true;
boolean hudSwitch = false;
boolean cursorSwitch = true;
ArrayList drops;
ArrayList blobs;
Cloud[] clouds = new Cloud[1];
String[] lyrics;
String[] lyricsA;
String[] lyricsB;
String[] lyricsC;
String[] lyricsD;
String[] lyricsE;
String[] lyricsF;
int cloudWidth;
int cloudHeight;
void setup() {
// size(1024,600,OPENGL);
/*size(1024,600,GLConstants.GLGRAPHICS); */
size(960,740,GLConstants.GLGRAPHICS);
hint(DISABLE_DEPTH_TEST);
//Projection
offscreenA = new GLGraphicsOffScreen(this, width-10, height-10);
offscreenB = new GLGraphicsOffScreen(this, width-50, height-50);
ks = new Keystone(this);
surfaceA = ks.createCornerPinSurface(width, height, 20);
surfaceB = ks.createCornerPinSurface(width, height, 20);
frameRate(30);
//Fullscreen
fs = new FullScreen(this);
fs.setResolution(1024, 600);
fs.setShortcutsEnabled(true);
//Font
font = loadFont("JUICELight-48.vlw");
textFont(font,18);
//Sound
minim = new Minim(this);
/*beep = minim.loadSample("tick.wav");*/
input = minim.getLineIn(Minim.STEREO, 512);
//Objects
drops = new ArrayList();
blobs = new ArrayList();
clouds[0] = new Cloud();
dropShape = loadShape("drop.svg");
cloudShape = loadShape("cloud.svg");
cloudHeight = int(cloudShape.height);
cloudWidth = int(cloudShape.width);
println("shape "+cloudShape.width);
//Text
lyrics = loadStrings("lyrics.txt");
lyricsA = loadStrings("lyrics_levelup.txt");
lyricsB = loadStrings("lyrics_somethinggood.txt");
lyricsC = loadStrings("lyrics_reallythought.txt");
}
void draw() {
PVector mouse = surfaceA.getTransformedMouse();
offscreenA.beginDraw();
background(0);
fill(255);
// convert
//HUD
audioLevel = input.mix.level () * audioGain;
if (hudSwitch == true){
fill(100);
text(" " + (float)input.mix.level(),20,marginTopHud+60);
text(" " + (float)audioLevel,20,marginTopHud+80);
text(" " + (int)audioGain,20,marginTopHud+100);
text(" " + bpm,60,marginTopHud+100);
text("L " + lyricSelect,100,marginTopHud+100);
fill(255);
// text("D " + dynamicTempo,20,160);
/*text("FPS "+int(frameRate),20,40);
text("Level: " + (float)input.mix.level(),20,60);
text("Gained: " + (float)audioLevel,20,80);
text("Gain [ü,+]: " + (int)audioGain,20,100);
text("Threshhold [ä,#]: " + (int)audioThreshhold,20,120);
text("BPM [j,k]: " + bpm,20,140);
text("Dynamic [d]: " + dynamicTempo,20,160);
text("Rain [r]: " + rainSwitch,20,180); */
}
//Make clouds rain
if (rainSwitch == true){
if (audioLevel > audioThreshhold) {
clouds[0].createDrops(int(audioLevel));
}
}
clouds[0].rain("drops");
offscreenA.endDraw();
offscreenB.beginDraw();
background(0);
clouds[0].rain("blobs");
offscreenB.endDraw();
background(0);
surfaceA.render(offscreenA.getTexture());
surfaceB.render(offscreenB.getTexture());
}
void selectLyric(Boolean switcher){
if (switcher == true){
lyricSelect++;
if (lyricSelect > 2){
lyricSelect = 0;
}
}
if (lyricSelect == 0){
lyrics = lyricsA;
}
if (lyricSelect == 1){
lyrics = lyricsB;
}
if (lyricSelect == 2){
lyrics = lyricsC;
}
/*switch(lyricSelect) {
case '0':
lyrics = lyricsA;
break;
case '1':
lyrics = lyricsB;
break;
case '2':
lyrics = lyricsC;
break;
} */
}
void keyPressed(){
switch(key) {
/*case ' ':
if (tapBpm != 0){
println("BPM Millis "+millis());
println("BPM TapBpm "+tapBpm);
bpm = int(((millis() - tapBpm)/1000)*60);
tapBpm = millis();
println("BPM Tap "+bpm);
} else {
tapBpm = millis();
}
break; */
case 'x':
clouds[0].createDrops(1);
break;
case 'h':
if (hudSwitch == true) {
hudSwitch = false;
} else {
hudSwitch = true;
}
break;
case 'l':
if (lyricSwitch == true) {
lyricSwitch = false;
} else {
lyricSwitch = true;
}
break;
case 'r':
if (rainSwitch == true) {
rainSwitch = false;
} else {
rainSwitch = true;
}
break;
case 'd':
if (dynamicTempo == true) {
dynamicTempo = false;
} else {
dynamicTempo = true;
}
break;
case 'm':
if (cursorSwitch == true) {
cursorSwitch = false;
noCursor();
} else {
cursorSwitch = true;
cursor(HAND);
}
break;
case '1':
lyrics = lyricsA;
break;
case '2':
lyrics = lyricsB;
break;
case '3':
lyrics = lyricsC;
break;
case '8':
selectLyric(true);
break;
case 'j':
bpm += 5;
break;
case 'k':
bpm -= 5;
break;
case 'ü':
audioGain += 5;
break;
case '+':
audioGain -= 5;
break;
case 'ä':
audioThreshhold += 0.5;
break;
case '#':
audioThreshhold -= 0.5;
break;
case 'c':
// enter/leave calibration mode, where surfaces can be warped
// & moved
ks.toggleCalibration();
break;
case 'a':
// loads the saved layout
ks.load();
break;
case 's':
// saves the layout
ks.save();
break;
}
}