-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwaveformsaver.pde
More file actions
57 lines (53 loc) · 1.11 KB
/
Copy pathwaveformsaver.pde
File metadata and controls
57 lines (53 loc) · 1.11 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
class WaveformSaver implements AudioListener
{
private float[] left;
private float[] right;
WaveformSaver()
{
left = null;
right = null;
}
synchronized void samples(float[] samp)
{
left = samp;
for(float f : left)
output.println(f);
}
synchronized void samples(float[] sampL, float[] sampR)
{
left = sampL;
right = sampR;
}
synchronized void draw()
{
// we've got a stereo signal if right or left are not null
if ( left != null && right != null )
{
noFill();
stroke(255);
beginShape();
for ( int i = 0; i < left.length; i++ )
{
vertex(i, height/4 + left[i]*50);
}
endShape();
beginShape();
for ( int i = 0; i < right.length; i++ )
{
vertex(i, 3*(height/4) + right[i]*50);
}
endShape();
}
else if ( left != null )
{
noFill();
stroke(255);
beginShape();
for ( int i = 0; i < left.length; i++ )
{
vertex(i, height/2 + left[i]*50);
}
endShape();
}
}
}