-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflocksoundss.pde
More file actions
136 lines (113 loc) · 2.55 KB
/
flocksoundss.pde
File metadata and controls
136 lines (113 loc) · 2.55 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
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
import ddf.minim.*;
import ddf.minim.ugens.*;
import ddf.minim.effects.*;
Minim minim;
AudioOutput out;
Flock flock;
int ss;
ArrayList<SoundForm> forms = new ArrayList<SoundForm>();
int baseOctave = 1;
int octaves = 5;
int[] tones;
int colorRange= 36;
int toneClr = colorRange/12;
int strongColor= (int)(colorRange*0.9);
AudioRecorder recorder;
SoundForm selected;
void setup() {
size(displayWidth, displayHeight, P2D);
smooth();
frameRate(25);
ellipseMode(RADIUS);
rectMode(CENTER);
imageMode(CENTER);
// size(800,600 , P2D);
if (randomSeed != -1)
randomSeed(randomSeed);
flock = new Flock();
colorMode(HSB, colorRange);
minim = new Minim(this);
out = minim.getLineOut();
initSounds();
// Add an initial set of boids into the system
initFlock();
initForms();
if (boidsMode==GRADIANTS) {
boidImage= loadImage("a.png");
blendMode(MULTIPLY);
}
if (recordSound) {
recorder = minim.createRecorder(out, "myrecording.wav", true);
recorder.beginRecord();
}
}
void initSounds() {
int baseTone = (int) random(baseOctave*12, (baseOctave+1)*12);
// get the tones from the function jazzchord, in the notes tab
tones = new int[octaves*4];
for (int oct = 0; oct <octaves;oct++) {
for (int i=0; i < 4; i++) { //chord
tones[oct*4+i] = baseTone + 12*oct +jazzchord(i);
}
}
ss = tones.length;
}
void initFlock() {
for (int i = 0; i < n; i++) {
Boid b = new Boid(width/2, height/2,flock.nextID++);
flock.addBoid(b);
}
}
void initForms() {
for (SoundForm sf: forms)
sf.unPatch();
forms.clear();
for (int i=0; i < ss;i++)
forms.add(new SoundForm(i, tones[i]));
}
void draw() {
background(0);
flock.run();
fill(0);
noStroke();
for (int i=0; i < ss;i++)
forms.get(i).draw();
if (selected != null)
selected.location.set(mouseX, mouseY, 0);
if (captureImages)
saveFrame("pics/frame-####.bmp");
if (autoEnd>0 && frameCount == autoEnd) {
if (recordSound) {
recorder.endRecord();
recorder.save();
}
exit();
}
}
void keyPressed() {
switch(key) {
case 's':
initForms();
break;
case 'f':
initFlock();
break;
//else if (
}
}
void mousePressed() {
for (int i=0; i < ss;i++)
if (forms.get(i).location.dist(new PVector(mouseX, mouseY)) <forms.get(i).r ) {
selected = forms.get(i);
break;
}
}
void mouseReleased() {
selected = null;
}
// bugs
// bezierpoints btw. boid and soundforms
// falsche farben der bezierkurven
// falsche drehrichtung der sf
// ideen:
// klaviertasten