forked from processing/processing
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFFT.java
More file actions
41 lines (35 loc) · 843 Bytes
/
Copy pathFFT.java
File metadata and controls
41 lines (35 loc) · 843 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
37
38
39
40
41
package processing.sound;
import processing.core.*;
public class FFT {
PApplet parent;
private Engine m_engine;
private long ptr;
public FFT(PApplet theParent) {
this.parent = theParent;
parent.registerMethod("dispose", this);
m_engine.setPreferences(theParent, 512, 44100);
m_engine.start();
}
public void input(SoundObject input, int fftSize){
ptr = m_engine.fft(input.returnId(), fftSize);
}
public void analyze(float[] value){
float[] m_value = m_engine.poll_fft(ptr);
int num_samples = Math.min(value.length, m_value.length);
for(int i=0; i<num_samples; i++){
value[i] = m_value[i];
}
}
/*
public void stop(){
m_engine.synthStop(m_nodeId);
}
public int returnId(){
return m_nodeId;
}
*/
public void dispose() {
m_engine.destroy_fft(ptr);
//m_engine.synthStop(m_nodeId);
}
}