-
-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathAllPass.java
More file actions
53 lines (45 loc) · 1.44 KB
/
AllPass.java
File metadata and controls
53 lines (45 loc) · 1.44 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
package processing.sound;
import com.jsyn.unitgen.FilterAllPass;
import processing.core.PApplet;
/**
* This is an all pass filter. For signals processed, all frequencies hold the
* same amplitude but have their phase relationship modified using a delayline
* of one sample,<br />
* <br />
* <code>y(k) = -z * x(k) + x(k - 1) + z * y(k - 1)</code><br />
* <br />
* where <code>y</code> is the output, <code>x</code> is the input,
* <code>z</code> is the gain coefficient, and <code>k</code> is the signal.
* @webref Effects:AllPass
* @webBrief Outputs all input frequencies at the same amplitude but changes
* their phase relationship.
* @param parent PApplet: typically use "this"
**/
public class AllPass extends Effect<FilterAllPass> {
public AllPass(PApplet parent) {
super(parent);
}
@Override
protected FilterAllPass newInstance() {
return new FilterAllPass();
}
/**
* Sets the gain for the filter in the range 0.0 - 1.0, where larger values
* increase phase displacement.
* @webref Effects:AllPass
* @webBrief Sets the gain for the filter.
* @param g phase displacement in the range 0.0 - 1.0
**/
public void gain(float g) {
// Keep the user from throwing bad output signals.
if (g < 0.0) { g = 0.0f; }
if (g > 1.0) { g = 1.0f; }
//Set the gain of the effect.
this.left.gain.set(g);
this.right.gain.set(g);
}
public void process(SoundObject input, float g) {
this.gain(g);
this.process(input);
}
}