-
-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathAnalyzer.java
More file actions
52 lines (41 loc) · 1.16 KB
/
Analyzer.java
File metadata and controls
52 lines (41 loc) · 1.16 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
package processing.sound;
import com.jsyn.ports.UnitOutputPort;
import processing.core.PApplet;
/**
* Common superclass of all audio analysis classes
* @webref Analysis
*/
public abstract class Analyzer {
protected SoundObject input;
protected Analyzer(PApplet parent) {
Engine.getEngine(parent);
}
/**
* Define the audio input for the analyzer.
*
* @param input The input sound source
* @webref Analysis:Analyzer
**/
public void input(SoundObject input) {
if (this.input == input) {
Engine.printWarning("This input was already connected to the analyzer");
} else {
if (this.input != null) {
if (!this.input.isPlaying()) {
// unit was only analyzed but not playing out loud - remove from synth
Engine.getEngine().remove(this.input.circuit);
}
this.removeInput();
}
this.input = input;
if (!this.input.isPlaying()) {
Engine.getEngine().add(input.circuit);
}
this.setInput(input.circuit.output.output);
}
}
// remove the current input
protected abstract void removeInput();
// connect sound source in subclass AND add analyser unit to Engine
protected abstract void setInput(UnitOutputPort input);
}