Skip to content

Commit 4b04d04

Browse files
pixmusixkevinstadler
authored andcommitted
Update AllPass_0.pde
Clean and more interesting example with no boiler plate code.
1 parent a6a9993 commit 4b04d04

1 file changed

Lines changed: 16 additions & 36 deletions

File tree

Lines changed: 16 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,18 @@
1-
import processing.sound.*;
1+
// Create two triangle waves with deconstructive frequencies.
2+
triA = new TriOsc(this);
3+
triA.freq(220);
4+
triB = new TriOsc(this);
5+
triB.freq(410);
26

3-
SawOsc saw;
4-
AllPass allPass;
7+
// Make an Allpass
8+
allPass = new AllPass(this);
9+
// Give Allpass a high gain to process yucky transience.
10+
allPass.gain(0.995);
511

6-
void setup() {
7-
size(512,360);
8-
background(255);
9-
10-
// Create a sawtooth wave and an AllPass filter
11-
saw = new SawOsc(this);
12-
saw.freq(200);
13-
allPass = new AllPass(this);
14-
15-
// Start the saw wave and push it through the allpass
16-
saw.play();
17-
allPass.process(saw);
18-
}
19-
20-
void draw() {
21-
background(0);
22-
23-
// Set the drive of the allPass with the mouse
24-
float g = map(mouseX, 0, width, 0., 1);
25-
allPass.gain(g);
26-
27-
// Draw some visuals for intuition
28-
float a = 50;
29-
strokeWeight(4);
30-
for (float i = 0; i < width; i = i + 3) {
31-
// Draw a wave
32-
stroke(255, 0, 0);
33-
point(i, sin(i) * a + width/2);
34-
// Draw that wave again after being driven by g
35-
stroke(0, 255, 0);
36-
point(i + g * TWO_PI, a * sin(i) + width/2);
37-
}
38-
}
12+
// Start both triangle waves together.
13+
// This will create a lot of unbridled bright sounds.
14+
triA.play();
15+
triB.play();
16+
// Processing the sound through this high gained Allpass will warm it up!
17+
allPass.process(triA);
18+
allPass.process(triB);

0 commit comments

Comments
 (0)