Skip to content

Commit a6a9993

Browse files
committed
Add AllPass class example
1 parent 37277fd commit a6a9993

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import processing.sound.*;
2+
3+
SawOsc saw;
4+
AllPass allPass;
5+
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+
}

0 commit comments

Comments
 (0)