-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSound.pde
77 lines (66 loc) · 2.18 KB
/
Sound.pde
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
public static class Planes {
public enum Plane {
XY,
ZY,
XZ,
YZ,
YX,
ZX
}
}
//@LXCategory(LXCategory.FORM)
@LXCategory("Oz")
public class GraphicEqualizerPattern extends LXPattern {
public final EnumParameter<Planes.Plane> plane =
new EnumParameter<Planes.Plane>("Plane", Planes.Plane.XY)
.setDescription("Which plane the equalizer renders on");
public final CompoundParameter gain =
new CompoundParameter("Gain", 1, 0, 3)
.setDescription("Amount of gain-scaling");
public final CompoundParameter center =
new CompoundParameter("Center", 0)
.setDescription("Center point on the axis");
public final CompoundParameter fade = (CompoundParameter)
new CompoundParameter("Fade", 0.1)
.setExponent(2)
.setDescription("Amount of fade");
public final CompoundParameter sharp = (CompoundParameter)
new CompoundParameter("Sharp", 0.9)
.setExponent(2)
.setDescription("Amount of sharpness");
public GraphicEqualizerPattern(LX lx) {
super(lx);
addParameter("gain", this.gain);
addParameter("center", this.center);
addParameter("fade", this.fade);
addParameter("sharp", this.sharp);
addParameter("plane", this.plane);
}
@Override
public void run(double deltaMs) {
GraphicMeter eq = lx.engine.audio.meter;
float center = this.center.getValuef();
float fade = 100 / this.fade.getValuef();
float sharp = 100 / (1 - this.sharp.getValuef());
float gain = this.gain.getValuef();
Planes.Plane plane = this.plane.getEnum();
float v1 = 0, v2 = 0;
for (LXPoint p : model.points) {
switch (plane) {
case XY: v1 = p.xn; v2 = p.yn; break;
case ZY: v1 = p.zn; v2 = p.yn; break;
case XZ: v1 = p.xn; v2 = p.zn; break;
case YZ: v1 = p.yn; v2 = p.zn; break;
case YX: v1 = p.yn; v2 = p.xn; break;
case ZX: v1 = p.zn; v2 = p.xn; break;
}
float level = gain * eq.getBandf((int) (v1 * (eq.numBands - 1)));
float value = Math.abs(v2 - center);
if (value > level) {
colors[p.index] = LXColor.BLACK;
} else {
colors[p.index] = LXColor.gray(Math.min(100, Math.min((level-value) * sharp, value * fade)));
}
}
}
}