-
Notifications
You must be signed in to change notification settings - Fork 0
/
Print10_Music_WhiteBlack.pde
107 lines (89 loc) · 2.02 KB
/
Print10_Music_WhiteBlack.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
import ddf.minim.*;
import ddf.minim.analysis.*;
Minim minim;
AudioPlayer track;
BeatDetect beat;
BeatListener bl;
int size;
int x;
int y;
int spacing = 10;
color[] colArray = {
color(35, 31, 32), //raisin
color(187, 68, 48),
color(126, 189, 194),
color(243, 223, 162),
color(239, 230, 221)
};
float kickSize, snareSize, hatSize;
class BeatListener implements AudioListener
{
private BeatDetect beat;
private AudioPlayer source;
BeatListener(BeatDetect beat, AudioPlayer source)
{
this.source = source;
this.source.addListener(this);
this.beat = beat;
}
void samples(float[] samps)
{
beat.detect(source.mix);
}
void samples(float[] sampsL, float[] sampsR)
{
beat.detect(source.mix);
}
}
void setup() {
//fullScreen();
size(600, 600);
background(255);
//frameRate(15);
minim = new Minim(this);
track = minim.loadFile("constellations.wav");
track.play();
beat = new BeatDetect(track.bufferSize(), track.sampleRate());
beat.setSensitivity(10);
kickSize = snareSize = hatSize = 16;
// make a new beat listener, so that we won't miss any buffers for the analysis
bl = new BeatListener(beat, track);
textFont(createFont("Helvetica", 16));
textAlign(CENTER);
}
void draw() {
//background(0);
if ( beat.isSnare() ) {
strokeWeight(5);
stroke(0);
} else if ( beat.isKick() ) {
strokeWeight(3);
stroke(0);
} else if (beat.isHat() ) {
strokeWeight(1);
stroke(0);
} else {
strokeWeight(0);
//stroke(243, 223, 162);
stroke(0);
}
//stroke(255);
//stroke(colArray[int(random(5))]);
//fill(colArray[int(random(5))]);
if (random(1) < 1) {
//rect(x,y,spacing,spacing);
line(x, y, x+spacing, y+spacing);
} else {
//line(x, y + spacing, x +spacing, y);
}
x = x + spacing;
if (x >= width) {
x = 0;
if (y >= height) {
background(255);
y = 0;
} else {
y += spacing;
}
}
}