-
-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathJSynAllPass.java
More file actions
36 lines (28 loc) · 860 Bytes
/
JSynAllPass.java
File metadata and controls
36 lines (28 loc) · 860 Bytes
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
package processing.sound;
import com.jsyn.ports.UnitInputPort;
import com.jsyn.ports.UnitOutputPort;
import com.jsyn.unitgen.Circuit;
import com.jsyn.unitgen.Delay;
import com.jsyn.unitgen.MultiplyAdd;
// https://ccrma.stanford.edu/~jos/pasp/Allpass_Two_Combs.html
// y = b0*x + x(-N) - b0*y(-N)
class JSynAllPass extends Circuit {
protected UnitInputPort input;
protected UnitOutputPort output;
public JSynAllPass(double g, int N) {
MultiplyAdd pre = new MultiplyAdd();
this.add(pre);
this.input = pre.inputC;
Delay delay = new Delay();
delay.allocate(N);
this.add(delay);
delay.input.connect(pre.output);
pre.inputA.set(-g);
pre.inputB.connect(delay.output);
MultiplyAdd post = new MultiplyAdd();
post.inputA.set(g);
post.inputB.connect(pre.output);
post.inputC.connect(delay.output);
this.output = post.output;
}
}