-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaudio-reactive-visualizer.pde
More file actions
80 lines (67 loc) · 1.63 KB
/
audio-reactive-visualizer.pde
File metadata and controls
80 lines (67 loc) · 1.63 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
import ddf.minim.*;
import ddf.minim.analysis.*;
//PLAYER
Minim minim;
AudioPlayer player;
AudioMetaData meta;
BeatDetect beat;
//FLOAT PARA OS EFEITOS NO CENTRO DO ECRÃ
int r = 200, bsize;
float rad = 70, x, y, x2, y2, leftLevel;
//FLOAT PARA OS EFEITOS ESPALHADOS PELO ECRÃ TODO
float n;
void setup() {
fullScreen(P3D);
minim = new Minim(this);
player = minim.loadFile("song.mp3");
meta = player.getMetaData();
beat = new BeatDetect();
player.loop();
smooth();
background(26, 31, 24);
noCursor();
}
void draw() {
//BOLA CENTRADA E TUDO À VOLTA DELA
beat.detect(player.mix);
fill(26, 31, 24, 20);
noStroke();
//FUNDO DO ECRÃ
rect(0, 0, width, height);
translate(width/2, height/2);
noFill();
fill(-1, 10);
if (beat.isOnset())
rad = rad*0.9;
else rad = 70;
//BOLA NO CENTRO DO ECRÃ
ellipse(0, 0, 2*rad, 2*rad);
stroke(random(250), random(250), random(250));
bsize = player.bufferSize();
for (int i = 0; i < bsize - 1; i+=5) {
x = (r)*cos(i*2*PI/bsize);
y = (r)*sin(i*2*PI/bsize);
x2 = (r + player.left.get(i)*100)*cos(i*2*PI/bsize);
y2 = (r + player.left.get(i)*100)*sin(i*2*PI/bsize);
//LINHAS À VOLTA DA BOLA
line(x, y, x2, y2);
}
//EFEITOS ESPALHADOS PELO ECRÃ TODO
for (int i = 0; i < player.bufferSize() -1; i++) {
leftLevel = player.left.level() * 20;
ellipse(i, i, leftLevel, leftLevel);
rotateZ(n*-PI/3*0.05);
fill(random(250), random(250), random(250));
}
n += 0.008 ;
}
//PAUSA E PLAY
void keyPressed() {
switch (keyCode) {
case ' ':
if (player.isPlaying())
player.pause();
else
player.loop();
}
}