-
-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathJSynReverb.java
More file actions
87 lines (70 loc) · 2.29 KB
/
JSynReverb.java
File metadata and controls
87 lines (70 loc) · 2.29 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
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
77
78
79
80
81
82
83
84
85
86
87
package processing.sound;
import com.jsyn.engine.SynthesisEngine;
import com.jsyn.unitgen.Circuit;
import com.jsyn.unitgen.MixerMono;
import com.jsyn.unitgen.PassThrough;
import com.jsyn.unitgen.UnitFilter;
/**
* A JSyn implementation of the classic Freeverb design.
* @seealso https://ccrma.stanford.edu/~jos/pasp/Freeverb.html
*/
class JSynReverb extends UnitFilter {
private Circuit reverbCircuit;
// see https://ccrma.stanford.edu/~jos/pasp/Freeverb.html
private static int[] Ns = new int[] { 1557, 1617, 1491, 1422, 1277, 1356, 1188, 1116 };
private JSynLBCF[] lbcfs = new JSynLBCF[JSynReverb.Ns.length];
private static int[] As = new int[] { 225, 556, 441, 341 };
private MixerMono mixer;
public JSynReverb() {
this.reverbCircuit = new Circuit();
PassThrough in = new PassThrough();
this.reverbCircuit.add(in);
this.input = in.input;
JSynAllPass first = new JSynAllPass(0.5, JSynReverb.As[0]);
this.reverbCircuit.add(first);
JSynAllPass ap = first;
for (int i = 1; i < JSynReverb.As.length; i++) {
JSynAllPass next = new JSynAllPass(0.5, JSynReverb.As[i]);
ap.output.connect(next.input);
ap = next;
this.reverbCircuit.add(ap);
}
for (int i = 0; i < JSynReverb.Ns.length; i++) {
this.lbcfs[i] = new JSynLBCF(0.84, 0.2, JSynReverb.Ns[i]);
this.reverbCircuit.add(this.lbcfs[i]);
this.lbcfs[i].input.connect(in.output);
// multiple connected inputs to first AllPass are summed automatically
this.lbcfs[i].output.connect(first.input);
}
this.mixer = new MixerMono(2);
this.mixer.amplitude.set(1.0);
this.setWet(0.5f);
in.output.connect(0, this.mixer.input, 0);
ap.output.connect(0, this.mixer.input, 1);
this.output = this.mixer.output;
}
@Override
public void setSynthesisEngine(SynthesisEngine synthesisEngine) {
this.reverbCircuit.setSynthesisEngine(synthesisEngine);
}
@Override
public void generate(int start, int limit) {
// not called
}
protected void setDamp(float damp) {
// damp = initialdamp * 0.4
for (JSynLBCF lbcf : this.lbcfs) {
lbcf.setD(damp * 0.4);
}
}
protected void setRoom(float room) {
// roomsize = initialroom * 0.28 + 0.7
for (JSynLBCF lbcf : this.lbcfs) {
lbcf.setF(room * 0.28 + 0.7);
}
}
protected void setWet(float wet) {
this.mixer.gain.set(0, 1 - wet);
this.mixer.gain.set(1, wet);
}
}