-
-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathJSynLBCF.java
More file actions
51 lines (40 loc) · 1.27 KB
/
JSynLBCF.java
File metadata and controls
51 lines (40 loc) · 1.27 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
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.FilterOnePole;
import com.jsyn.unitgen.MultiplyAdd;
import com.jsyn.unitgen.PassThrough;
// see https://ccrma.stanford.edu/~jos/pasp/Lowpass_Feedback_Comb_Filter.html
class JSynLBCF extends Circuit {
protected UnitInputPort input;
protected UnitOutputPort output;
private MultiplyAdd mixer;
private Delay delay;
private FilterOnePole filter;
public JSynLBCF(double f, double d, int N) {
PassThrough in = new PassThrough();
this.add(in);
this.add(this.mixer = new MultiplyAdd());
this.setF(f);
this.add(this.filter = new FilterOnePole());
this.setD(d);
this.add(this.delay = new Delay());
this.delay.allocate(N);
this.input = in.input;
// in.output.connect(this.mixer.inputC);
in.output.connect(this.delay.input);
this.delay.output.connect(this.filter.input);
this.filter.output.connect(this.mixer.inputB);
this.output = this.mixer.output;
}
// see https://ccrma.stanford.edu/~jos/fp/One_Pole.html
protected void setD(double d) {
this.filter.a0.setValue(1 - d);
this.filter.b1.setValue(-d);
}
protected void setF(double f) {
this.mixer.inputA.set(f);
}
}