-
Notifications
You must be signed in to change notification settings - Fork 1
/
DisplayWave.pde
54 lines (43 loc) · 1.26 KB
/
DisplayWave.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
class DisplayWave extends AbstractDisplay {
final int MAX_INSTANCES = 200;
final int ONE_INIT = 1;
List<AlphaBall> balls;
PGraphics lg;
float _maxRadius, _radiusY;
DisplayWave(ARect bound) {
super(bound);
balls = new ArrayList();
}
void draw(PGraphics g) {
if (super.hidden) return;
lg = createGraphics(super.bound);
lg.beginDraw();
balls.removeIf(b -> (b.dead));
if (balls.size() >= MAX_INSTANCES) {
balls = new ArrayList();
}
float bandwidth = lg.width / float(NUM_SAMPLES_WAVE);
for(int i=0; i< NUM_SAMPLES_WAVE; i++){
AlphaBall b = new AlphaBall(int(i * bandwidth),
(int)map(waveform.data[i], -1, 1, 0.3 * height, lg.height * 0.7)
, bound);
b.vel_px_per_sec = 0.01;
b.radius = 2;
b.maxRadius = _maxRadius;
b.radiusY = _radiusY * b.radius ;
b.alpha = 190 + random(2,40);
balls.add(b);
}
for(AlphaBall b: balls){
b.draw(lg);
}
lg.endDraw();
drawOn(lg, g, super.bound);
updateParams();
}
void updateParams() {
if(frameCount % APP_PARAM_UPDATE_RATE != 0) return;
_maxRadius = 2 + 8 * mapCtrlA(0,1);
_radiusY = mapCtrlA(1,8);
}
}