Add GraphicEQ audio helper class, improve audio animations
[SugarCubes.git] / MarkSlee.pde
1 class SpaceTime extends SCPattern {
2
3 SinLFO pos = new SinLFO(0, 1, 3000);
4 SinLFO rate = new SinLFO(1000, 9000, 13000);
5 SinLFO falloff = new SinLFO(10, 70, 5000);
6 float angle = 0;
7
8 BasicParameter rateParameter = new BasicParameter("RATE", 0.5);
9 BasicParameter sizeParameter = new BasicParameter("SIZE", 0.5);
10
11
12 public SpaceTime(GLucose glucose) {
13 super(glucose);
14
15 addModulator(pos).trigger();
16 addModulator(rate).trigger();
17 addModulator(falloff).trigger();
18 pos.modulateDurationBy(rate);
19 addParameter(rateParameter);
20 addParameter(sizeParameter);
21 }
22
23 public void onParameterChanged(LXParameter parameter) {
24 if (parameter == rateParameter) {
25 rate.stop().setValue(9000 - 8000*parameter.getValuef());
26 } else if (parameter == sizeParameter) {
27 falloff.stop().setValue(70 - 60*parameter.getValuef());
28 }
29 }
30
31 void run(int deltaMs) {
32 angle += deltaMs * 0.0007;
33 float sVal1 = model.strips.size() * (0.5 + 0.5*sin(angle));
34 float sVal2 = model.strips.size() * (0.5 + 0.5*cos(angle));
35
36 float pVal = pos.getValuef();
37 float fVal = falloff.getValuef();
38
39 int s = 0;
40 for (Strip strip : model.strips) {
41 int i = 0;
42 for (Point p : strip.points) {
43 colors[p.index] = color(
44 (lx.getBaseHuef() + 360 - p.fx*.2 + p.fy * .3) % 360,
45 constrain(.4 * min(abs(s - sVal1), abs(s - sVal2)), 20, 100),
46 max(0, 100 - fVal*abs(i - pVal*(strip.metrics.numPoints - 1)))
47 );
48 ++i;
49 }
50 ++s;
51 }
52 }
53 }
54
55 class Swarm extends SCPattern {
56
57 SawLFO offset = new SawLFO(0, 1, 1000);
58 SinLFO rate = new SinLFO(350, 1200, 63000);
59 SinLFO falloff = new SinLFO(15, 50, 17000);
60 SinLFO fX = new SinLFO(0, model.xMax, 19000);
61 SinLFO fY = new SinLFO(0, model.yMax, 11000);
62 SinLFO hOffX = new SinLFO(0, model.xMax, 13000);
63
64 public Swarm(GLucose glucose) {
65 super(glucose);
66
67 addModulator(offset).trigger();
68 addModulator(rate).trigger();
69 addModulator(falloff).trigger();
70 addModulator(fX).trigger();
71 addModulator(fY).trigger();
72 addModulator(hOffX).trigger();
73 offset.modulateDurationBy(rate);
74 }
75
76 float modDist(float v1, float v2, float mod) {
77 v1 = v1 % mod;
78 v2 = v2 % mod;
79 if (v2 > v1) {
80 return min(v2-v1, v1+mod-v2);
81 }
82 else {
83 return min(v1-v2, v2+mod-v1);
84 }
85 }
86
87 void run(int deltaMs) {
88 float s = 0;
89 for (Strip strip : model.strips ) {
90 int i = 0;
91 for (Point p : strip.points) {
92 float fV = max(-1, 1 - dist(p.fx/2., p.fy, fX.getValuef()/2., fY.getValuef()) / 64.);
93 colors[p.index] = color(
94 (lx.getBaseHuef() + 0.3 * abs(p.fx - hOffX.getValuef())) % 360,
95 constrain(80 + 40 * fV, 0, 100),
96 constrain(100 - (30 - fV * falloff.getValuef()) * modDist(i + (s*63)%61, (int) (offset.getValuef() * strip.metrics.numPoints), strip.metrics.numPoints), 0, 100)
97 );
98 ++i;
99 }
100 ++s;
101 }
102 }
103 }
104
105 class SwipeTransition extends SCTransition {
106
107 final BasicParameter bleed = new BasicParameter("WIDTH", 0.5);
108
109 SwipeTransition(GLucose glucose) {
110 super(glucose);
111 setDuration(5000);
112 addParameter(bleed);
113 }
114
115 void computeBlend(int[] c1, int[] c2, double progress) {
116 float bleedf = 10 + bleed.getValuef() * 200.;
117 float xPos = (float) (-bleedf + progress * (model.xMax + bleedf));
118 for (Point p : model.points) {
119 float d = (p.fx - xPos) / bleedf;
120 if (d < 0) {
121 colors[p.index] = c2[p.index];
122 } else if (d > 1) {
123 colors[p.index] = c1[p.index];
124 } else {
125 colors[p.index] = lerpColor(c2[p.index], c1[p.index], d, RGB);
126 }
127 }
128 }
129 }
130
131 class BassPod extends SCPattern {
132
133 private GraphicEQ eq = null;
134
135 public BassPod(GLucose glucose) {
136 super(glucose);
137 }
138
139 protected void onActive() {
140 if (eq == null) {
141 eq = new GraphicEQ(lx, 16);
142 eq.slope.setValue(0.6);
143 addParameter(eq.level);
144 addParameter(eq.range);
145 addParameter(eq.attack);
146 addParameter(eq.release);
147 addParameter(eq.slope);
148 }
149 }
150
151 public void run(int deltaMs) {
152 eq.run(deltaMs);
153
154 float bassLevel = eq.getAverageLevel(0, 5);
155
156 for (Point p : model.points) {
157 int avgIndex = (int) constrain(1 + abs(p.fx-model.xMax/2.)/(model.xMax/2.)*(eq.numBands-5), 0, eq.numBands-5);
158 float value = 0;
159 for (int i = avgIndex; i < avgIndex + 5; ++i) {
160 value += eq.getLevel(i);
161 }
162 value /= 5.;
163
164 float b = constrain(8 * (value*model.yMax - abs(p.fy-model.yMax/2.)), 0, 100);
165 colors[p.index] = color(
166 (lx.getBaseHuef() + abs(p.fy - model.cy) + abs(p.fx - model.cx)) % 360,
167 constrain(bassLevel*240 - .6*dist(p.fx, p.fy, model.cx, model.cy), 0, 100),
168 b
169 );
170 }
171 }
172 }
173
174
175 class CubeEQ extends SCPattern {
176
177 private GraphicEQ eq = null;
178
179 private final BasicParameter edge = new BasicParameter("EDGE", 0.5);
180 private final BasicParameter clr = new BasicParameter("CLR", 0.5);
181 private final BasicParameter blockiness = new BasicParameter("BLK", 0.5);
182
183 public CubeEQ(GLucose glucose) {
184 super(glucose);
185 }
186
187 protected void onActive() {
188 if (eq == null) {
189 eq = new GraphicEQ(lx, 16);
190 addParameter(eq.level);
191 addParameter(eq.range);
192 addParameter(eq.attack);
193 addParameter(eq.release);
194 addParameter(eq.slope);
195 addParameter(edge);
196 addParameter(clr);
197 addParameter(blockiness);
198 }
199 }
200
201 public void run(int deltaMs) {
202 eq.run(deltaMs);
203
204 float edgeConst = 2 + 30*edge.getValuef();
205 float clrConst = 1.1 + clr.getValuef();
206
207 for (Point p : model.points) {
208 float avgIndex = constrain(2 + p.fx / model.xMax * (eq.numBands-4), 0, eq.numBands-4);
209 int avgFloor = (int) avgIndex;
210
211 float leftVal = eq.getLevel(avgFloor);
212 float rightVal = eq.getLevel(avgFloor+1);
213 float smoothValue = lerp(leftVal, rightVal, avgIndex-avgFloor);
214
215 float chunkyValue = (
216 eq.getLevel(avgFloor/4*4) +
217 eq.getLevel(avgFloor/4*4 + 1) +
218 eq.getLevel(avgFloor/4*4 + 2) +
219 eq.getLevel(avgFloor/4*4 + 3)
220 ) / 4.;
221
222 float value = lerp(smoothValue, chunkyValue, blockiness.getValuef());
223
224 float b = constrain(edgeConst * (value*model.yMax - p.fy), 0, 100);
225 colors[p.index] = color(
226 (480 + lx.getBaseHuef() - min(clrConst*p.fy, 120)) % 360,
227 100,
228 b
229 );
230 }
231 }
232 }
233
234 class BoomEffect extends SCEffect {
235
236 final BasicParameter falloff = new BasicParameter("WIDTH", 0.5);
237 final BasicParameter speed = new BasicParameter("SPD", 0.5);
238 final BasicParameter bright = new BasicParameter("BRT", 1.0);
239 final BasicParameter sat = new BasicParameter("SAT", 0.2);
240 List<Layer> layers = new ArrayList<Layer>();
241 final float maxr = sqrt(model.xMax*model.xMax + model.yMax*model.yMax + model.zMax*model.zMax) + 10;
242
243 class Layer {
244 LinearEnvelope boom = new LinearEnvelope(-40, 500, 1300);
245
246 Layer() {
247 addModulator(boom);
248 trigger();
249 }
250
251 void trigger() {
252 float falloffv = falloffv();
253 boom.setRange(-100 / falloffv, maxr + 100/falloffv, 4000 - speed.getValuef() * 3300);
254 boom.trigger();
255 }
256
257 void doApply(int[] colors) {
258 float brightv = 100 * bright.getValuef();
259 float falloffv = falloffv();
260 float satv = sat.getValuef() * 100;
261 float huev = lx.getBaseHuef();
262 for (Point p : model.points) {
263 colors[p.index] = blendColor(
264 colors[p.index],
265 color(huev, satv, constrain(brightv - falloffv*abs(boom.getValuef() - dist(p.fx, 2*p.fy, 3*p.fz, model.xMax/2, model.yMax, model.zMax*1.5)), 0, 100)),
266 ADD);
267 }
268 }
269 }
270
271 BoomEffect(GLucose glucose) {
272 super(glucose, true);
273 addParameter(falloff);
274 addParameter(speed);
275 addParameter(bright);
276 addParameter(sat);
277 }
278
279 public void onEnable() {
280 for (Layer l : layers) {
281 if (!l.boom.isRunning()) {
282 l.trigger();
283 return;
284 }
285 }
286 layers.add(new Layer());
287 }
288
289 private float falloffv() {
290 return 20 - 19 * falloff.getValuef();
291 }
292
293 public void onTrigger() {
294 onEnable();
295 }
296
297 public void doApply(int[] colors) {
298 for (Layer l : layers) {
299 if (l.boom.isRunning()) {
300 l.doApply(colors);
301 }
302 }
303 }
304 }
305
306 public class PianoKeyPattern extends SCPattern {
307
308 final LinearEnvelope[] cubeBrt;
309 final SinLFO base[];
310 final BasicParameter attack = new BasicParameter("ATK", 0.1);
311 final BasicParameter release = new BasicParameter("REL", 0.5);
312 final BasicParameter level = new BasicParameter("AMB", 0.6);
313
314 PianoKeyPattern(GLucose glucose) {
315 super(glucose);
316
317 for (MidiInputDevice input : RWMidi.getInputDevices()) {
318 input.createInput(this);
319 }
320
321 addParameter(attack);
322 addParameter(release);
323 addParameter(level);
324 cubeBrt = new LinearEnvelope[model.cubes.size() / 4];
325 for (int i = 0; i < cubeBrt.length; ++i) {
326 addModulator(cubeBrt[i] = new LinearEnvelope(0, 0, 100));
327 }
328 base = new SinLFO[model.cubes.size() / 12];
329 for (int i = 0; i < base.length; ++i) {
330 addModulator(base[i] = new SinLFO(0, 1, 7000 + 1000*i)).trigger();
331 }
332 }
333
334 private float getAttackTime() {
335 return 15 + attack.getValuef()*attack.getValuef() * 2000;
336 }
337
338 private float getReleaseTime() {
339 return 15 + release.getValuef() * 3000;
340 }
341
342 private LinearEnvelope getEnvelope(int index) {
343 return cubeBrt[index % cubeBrt.length];
344 }
345
346 private SinLFO getBase(int index) {
347 return base[index % base.length];
348 }
349
350 public void noteOnReceived(Note note) {
351 LinearEnvelope env = getEnvelope(note.getPitch());
352 env.setEndVal(min(1, env.getValuef() + (note.getVelocity() / 127.)), getAttackTime()).start();
353 }
354
355 public void noteOffReceived(Note note) {
356 getEnvelope(note.getPitch()).setEndVal(0, getReleaseTime()).start();
357 }
358
359 public void run(int deltaMs) {
360 int i = 0;
361 float huef = lx.getBaseHuef();
362 float levelf = level.getValuef();
363 for (Cube c : model.cubes) {
364 float v = max(getBase(i).getValuef() * levelf/4., getEnvelope(i++).getValuef());
365 setColor(c, color(
366 (huef + 20*v + abs(c.cx-model.xMax/2.)*.3 + c.cy) % 360,
367 min(100, 120*v),
368 100*v
369 ));
370 }
371 }
372 }
373
374 class CrossSections extends SCPattern {
375
376 final SinLFO x = new SinLFO(0, model.xMax, 5000);
377 final SinLFO y = new SinLFO(0, model.yMax, 6000);
378 final SinLFO z = new SinLFO(0, model.zMax, 7000);
379
380 final BasicParameter xw = new BasicParameter("XWID", 0.3);
381 final BasicParameter yw = new BasicParameter("YWID", 0.3);
382 final BasicParameter zw = new BasicParameter("ZWID", 0.3);
383 final BasicParameter xr = new BasicParameter("XRAT", 0.7);
384 final BasicParameter yr = new BasicParameter("YRAT", 0.6);
385 final BasicParameter zr = new BasicParameter("ZRAT", 0.5);
386 final BasicParameter xl = new BasicParameter("XLEV", 1);
387 final BasicParameter yl = new BasicParameter("YLEV", 1);
388 final BasicParameter zl = new BasicParameter("ZLEV", 0.5);
389
390
391 CrossSections(GLucose glucose) {
392 super(glucose);
393 addModulator(x).trigger();
394 addModulator(y).trigger();
395 addModulator(z).trigger();
396 addParams();
397 }
398
399 protected void addParams() {
400 addParameter(xr);
401 addParameter(yr);
402 addParameter(zr);
403 addParameter(xw);
404 addParameter(xl);
405 addParameter(yl);
406 addParameter(zl);
407 addParameter(yw);
408 addParameter(zw);
409 }
410
411 void onParameterChanged(LXParameter p) {
412 if (p == xr) {
413 x.setDuration(10000 - 8800*p.getValuef());
414 } else if (p == yr) {
415 y.setDuration(10000 - 9000*p.getValuef());
416 } else if (p == zr) {
417 z.setDuration(10000 - 9000*p.getValuef());
418 }
419 }
420
421 float xv, yv, zv;
422
423 protected void updateXYZVals() {
424 xv = x.getValuef();
425 yv = y.getValuef();
426 zv = z.getValuef();
427 }
428
429 public void run(int deltaMs) {
430 updateXYZVals();
431
432 float xlv = 100*xl.getValuef();
433 float ylv = 100*yl.getValuef();
434 float zlv = 100*zl.getValuef();
435
436 float xwv = 100. / (10 + 40*xw.getValuef());
437 float ywv = 100. / (10 + 40*yw.getValuef());
438 float zwv = 100. / (10 + 40*zw.getValuef());
439
440 for (Point p : model.points) {
441 color c = 0;
442 c = blendColor(c, color(
443 (lx.getBaseHuef() + p.fx/10 + p.fy/3) % 360,
444 constrain(140 - 1.1*abs(p.fx - model.xMax/2.), 0, 100),
445 max(0, xlv - xwv*abs(p.fx - xv))
446 ), ADD);
447 c = blendColor(c, color(
448 (lx.getBaseHuef() + 80 + p.fy/10) % 360,
449 constrain(140 - 2.2*abs(p.fy - model.yMax/2.), 0, 100),
450 max(0, ylv - ywv*abs(p.fy - yv))
451 ), ADD);
452 c = blendColor(c, color(
453 (lx.getBaseHuef() + 160 + p.fz / 10 + p.fy/2) % 360,
454 constrain(140 - 2.2*abs(p.fz - model.zMax/2.), 0, 100),
455 max(0, zlv - zwv*abs(p.fz - zv))
456 ), ADD);
457 colors[p.index] = c;
458 }
459 }
460 }
461
462 class Blinders extends SCPattern {
463
464 final SinLFO[] m;
465 final TriangleLFO r;
466 final SinLFO s;
467 final TriangleLFO hs;
468
469 public Blinders(GLucose glucose) {
470 super(glucose);
471 m = new SinLFO[12];
472 for (int i = 0; i < m.length; ++i) {
473 addModulator(m[i] = new SinLFO(0.5, 120, (120000. / (3+i)))).trigger();
474 }
475 addModulator(r = new TriangleLFO(9000, 15000, 29000)).trigger();
476 addModulator(s = new SinLFO(-20, 275, 11000)).trigger();
477 addModulator(hs = new TriangleLFO(0.1, 0.5, 15000)).trigger();
478 s.modulateDurationBy(r);
479 }
480
481 public void run(int deltaMs) {
482 float hv = lx.getBaseHuef();
483 int si = 0;
484 for (Strip strip : model.strips) {
485 int i = 0;
486 float mv = m[si % m.length].getValuef();
487 for (Point p : strip.points) {
488 colors[p.index] = color(
489 (hv + p.fz + p.fy*hs.getValuef()) % 360,
490 min(100, abs(p.fx - s.getValuef())/2.),
491 max(0, 100 - mv/2. - mv * abs(i - (strip.metrics.length-1)/2.))
492 );
493 ++i;
494 }
495 ++si;
496 }
497 }
498 }
499
500 class Psychedelia extends SCPattern {
501
502 final int NUM = 3;
503 SinLFO m = new SinLFO(-0.5, NUM-0.5, 9000);
504 SinLFO s = new SinLFO(-20, 147, 11000);
505 TriangleLFO h = new TriangleLFO(0, 240, 19000);
506 SinLFO c = new SinLFO(-.2, .8, 31000);
507
508 Psychedelia(GLucose glucose) {
509 super(glucose);
510 addModulator(m).trigger();
511 addModulator(s).trigger();
512 addModulator(h).trigger();
513 addModulator(c).trigger();
514 }
515
516 void run(int deltaMs) {
517 float huev = h.getValuef();
518 float cv = c.getValuef();
519 float sv = s.getValuef();
520 float mv = m.getValuef();
521 int i = 0;
522 for (Strip strip : model.strips) {
523 for (Point p : strip.points) {
524 colors[p.index] = color(
525 (huev + i*constrain(cv, 0, 2) + p.fz/2. + p.fx/4.) % 360,
526 min(100, abs(p.fy-sv)),
527 max(0, 100 - 50*abs((i%NUM) - mv))
528 );
529 }
530 ++i;
531 }
532 }
533 }
534
535 class AskewPlanes extends SCPattern {
536
537 class Plane {
538 private final SinLFO a;
539 private final SinLFO b;
540 private final SinLFO c;
541 float av = 1;
542 float bv = 1;
543 float cv = 1;
544 float denom = 0.1;
545
546 Plane(int i) {
547 addModulator(a = new SinLFO(-1, 1, 4000 + 1029*i)).trigger();
548 addModulator(b = new SinLFO(-1, 1, 11000 - 1104*i)).trigger();
549 addModulator(c = new SinLFO(-50, 50, 4000 + 1000*i * ((i % 2 == 0) ? 1 : -1))).trigger();
550 }
551
552 void run(int deltaMs) {
553 av = a.getValuef();
554 bv = b.getValuef();
555 cv = c.getValuef();
556 denom = sqrt(av*av + bv*bv);
557 }
558 }
559
560 final Plane[] planes;
561 final int NUM_PLANES = 3;
562
563 AskewPlanes(GLucose glucose) {
564 super(glucose);
565 planes = new Plane[NUM_PLANES];
566 for (int i = 0; i < planes.length; ++i) {
567 planes[i] = new Plane(i);
568 }
569 }
570
571 public void run(int deltaMs) {
572 float huev = lx.getBaseHuef();
573
574 // This is super fucking bizarre. But if this is a for loop, the framerate
575 // tanks to like 30FPS, instead of 60. Call them manually and it works fine.
576 // Doesn't make ANY sense... there must be some weird side effect going on
577 // with the Processing internals perhaps?
578 // for (Plane plane : planes) {
579 // plane.run(deltaMs);
580 // }
581 planes[0].run(deltaMs);
582 planes[1].run(deltaMs);
583 planes[2].run(deltaMs);
584
585 for (Point p : model.points) {
586 float d = MAX_FLOAT;
587 for (Plane plane : planes) {
588 if (plane.denom != 0) {
589 d = min(d, abs(plane.av*(p.fx-model.cx) + plane.bv*(p.fy-model.cy) + plane.cv) / plane.denom);
590 }
591 }
592 colors[p.index] = color(
593 (huev + abs(p.fx-model.cx)*.3 + p.fy*.8) % 360,
594 max(0, 100 - .8*abs(p.fx - model.cx)),
595 constrain(140 - 10.*d, 0, 100)
596 );
597 }
598 }
599 }
600
601 class ShiftingPlane extends SCPattern {
602
603 final SinLFO a = new SinLFO(-.2, .2, 5300);
604 final SinLFO b = new SinLFO(1, -1, 13300);
605 final SinLFO c = new SinLFO(-1.4, 1.4, 5700);
606 final SinLFO d = new SinLFO(-10, 10, 9500);
607
608 ShiftingPlane(GLucose glucose) {
609 super(glucose);
610 addModulator(a).trigger();
611 addModulator(b).trigger();
612 addModulator(c).trigger();
613 addModulator(d).trigger();
614 }
615
616 public void run(int deltaMs) {
617 float hv = lx.getBaseHuef();
618 float av = a.getValuef();
619 float bv = b.getValuef();
620 float cv = c.getValuef();
621 float dv = d.getValuef();
622 float denom = sqrt(av*av + bv*bv + cv*cv);
623 for (Point p : model.points) {
624 float d = abs(av*(p.fx-model.cx) + bv*(p.fy-model.cy) + cv*(p.fz-model.cz) + dv) / denom;
625 colors[p.index] = color(
626 (hv + abs(p.fx-model.cx)*.6 + abs(p.fy-model.cy)*.9 + abs(p.fz - model.cz)) % 360,
627 constrain(110 - d*6, 0, 100),
628 constrain(130 - 7*d, 0, 100)
629 );
630 }
631 }
632 }
633
634 class Traktor extends SCPattern {
635
636 final int FRAME_WIDTH = 60;
637
638 final BasicParameter speed = new BasicParameter("SPD", 0.5);
639
640 private float[] bass = new float[FRAME_WIDTH];
641 private float[] treble = new float[FRAME_WIDTH];
642
643 private int index = 0;
644 private GraphicEQ eq = null;
645
646 public Traktor(GLucose glucose) {
647 super(glucose);
648 for (int i = 0; i < FRAME_WIDTH; ++i) {
649 bass[i] = 0;
650 treble[i] = 0;
651 }
652 addParameter(speed);
653 }
654
655 public void onActive() {
656 if (eq == null) {
657 eq = new GraphicEQ(lx, 16);
658 eq.slope.setValue(0.6);
659 eq.level.setValue(0.65);
660 eq.range.setValue(0.35);
661 eq.release.setValue(0.4);
662 addParameter(eq.level);
663 addParameter(eq.range);
664 addParameter(eq.attack);
665 addParameter(eq.release);
666 addParameter(eq.slope);
667 }
668 }
669
670 int counter = 0;
671
672 public void run(int deltaMs) {
673 eq.run(deltaMs);
674
675 int stepThresh = (int) (40 - 39*speed.getValuef());
676 counter += deltaMs;
677 if (counter < stepThresh) {
678 return;
679 }
680 counter = counter % stepThresh;
681
682 index = (index + 1) % FRAME_WIDTH;
683
684 float rawBass = eq.getAverageLevel(0, 4);
685 float rawTreble = eq.getAverageLevel(eq.numBands-7, 7);
686
687 bass[index] = rawBass * rawBass * rawBass * rawBass;
688 treble[index] = rawTreble * rawTreble;
689
690 for (Point p : model.points) {
691 int i = (int) constrain((model.xMax - p.x) / model.xMax * FRAME_WIDTH, 0, FRAME_WIDTH-1);
692 int pos = (index + FRAME_WIDTH - i) % FRAME_WIDTH;
693
694 colors[p.index] = color(
695 (360 + lx.getBaseHuef() + .8*abs(p.x-model.cx)) % 360,
696 100,
697 constrain(9 * (bass[pos]*model.cy - abs(p.fy - model.cy)), 0, 100)
698 );
699 colors[p.index] = blendColor(colors[p.index], color(
700 (400 + lx.getBaseHuef() + .5*abs(p.x-model.cx)) % 360,
701 60,
702 constrain(5 * (treble[pos]*.6*model.cy - abs(p.fy - model.cy)), 0, 100)
703
704 ), ADD);
705 }
706 }
707 }