-
Notifications
You must be signed in to change notification settings - Fork 0
/
Edge.pde
76 lines (68 loc) · 2.29 KB
/
Edge.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
class Edge {
int fromNode;
int toNode;
float lifespan;
float eLength;
float amp;
TapOut delayOut;
Envelope env;
Glide delayTimeGlide;
Gain outputGain;
Glide outputGainGlide;
int keepBits;
//int reducer = 1;
//float cutoff = 1000;
//Glide lpfGlide;
//BiquadFilter lpf;
Edge(int fromNode_, int toNode_, float distance) {
fromNode = fromNode_;
toNode = toNode_;
eLength = distance;
lifespan = maxLife;
delayTimeGlide = new Glide(ac, eLength, 10);
delayOut = new TapOut(ac, ps.getParticle(fromNode).delayIn, delayTimeGlide); // create the delay output - the final parameter is the length of the initial delay time in milliseconds
outputGainGlide = new Glide(ac, 1, 10);
outputGain = new Gain(ac, 1, outputGainGlide);
outputGain.addInput(delayOut);
ps.getParticle(toNode).signalInput.addInput(outputGain); // connect the delay output to the Particle
}
void disconnect() {
setGain(0.0);
ps.getParticle(toNode).signalInput.removeAllConnections(outputGain); // remove outputGain from all inputs of signalInput
outputGain.clearInputConnections(); // clear all input connections
delayOut.kill();
delayTimeGlide.kill();
outputGain.kill();
outputGainGlide.kill();
//println("disconnected: " + this.fromNode + " " + this.toNode);
}
boolean isAlive() {
lifespan--;
setGain(max (0.0, lifespan / maxLife ));
if (lifespan <= -100.0) {
return false;
} else {
return true;
}
}
void setDelay(float delaytime) {
if (delaytime < 1) delaytime = 1;
delayTimeGlide.setValue(delaytime);
}
void setGain(float gain) {
outputGainGlide.setValue(gain);
}
void display() {
//for (int i = 0; i < rmsValNbr; i++) {
//rmsValHistReadIndx = rmsValHistWriteIndx - i;
// if(rmsValHistReadIndx < 0) rmsValHistReadIndx = rmsValNbr + rmsValHistReadIndx;
//rmsSave = rmsValHist[rmsValHistReadIndx];
// if(rmsSave <= rmsValHist[rmsValHistWriteIndx]) { // smaller current rms value
//stroke( sqrt(rmsSave) * 255 * (rmsValNbr - i) / rmsValNbr, 255 * (rmsValNbr - i) / rmsValNbr);
////stroke( 255 * (rmsValNbr - i) / rmsValNbr, 255 * (rmsValNbr - i) / rmsValNbr);
//ellipse(location.x, location.y, rmsSave * diameter + 2, rmsSave * diameter + 2);
// }
// }
//
}
}