-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLowVolumeFlapjacks.pde
80 lines (65 loc) · 1.67 KB
/
LowVolumeFlapjacks.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
// Pancake Drums inspired by Vulfpeck's Birds of a Feather
// https://www.youtube.com/watch?v=WQm4R0LM2mE
// Allows us to play our audio
import ddf.minim.*;
// Initialize audio lib
Minim minim;
// Allows us to work with bird image data
JSONArray json;
import http.requests.*;
PImage birdImage;
// Create instance for each drum file
AudioSample kick;
AudioSample snare;
AudioSample hihat;
AudioSample tom;
void setup() {
// Set http agent
System.setProperty("http.agent", "Chrome");
size(1000, 1000);
minim = new Minim(this);
// Buffer is set to 150 for less input delay
kick = minim.loadSample("kick.wav", 150);
snare = minim.loadSample("snare.mp3", 150);
hihat = minim.loadSample("hihat.mp3", 150);
tom = minim.loadSample("tom.wav", 150);
// Get our initial bird image
callBird();
}
void draw() {
background(255, 255, 255);
image(birdImage, 300, 300);
}
// Grab a random bird from the API
void callBird() {
clear();
GetRequest get = new GetRequest("http://shibe.online/api/birds?count=[1-100]&urls=[true/false]&httpsUrls=[true/false]");
get.send();
JSONArray json = parseJSONArray(get.getContent());
println(json);
birdImage = loadImage("https://cdn.shibe.online/birds/" + json.getString(0) + ".jpg", "jpg");
delay(1000);
}
// Trigger our drum hits
void keyPressed() {
// Kick
if (key == CODED && keyCode == UP) {
kick.trigger();
callBird();
}
// Snare
if (key == CODED && keyCode == DOWN) {
snare.trigger();
callBird();
}
// Hihat
if (key == CODED && keyCode == LEFT) {
hihat.trigger();
callBird();
}
// Tom
if (key == CODED && keyCode == RIGHT) {
tom.trigger();
callBird();
}
}