1 class Pulley extends SCPattern {
3 final int NUM_DIVISIONS = 16;
4 private final Accelerator[] gravity = new Accelerator[NUM_DIVISIONS];
5 private final Click[] delays = new Click[NUM_DIVISIONS];
7 private final Click reset = new Click(9000);
8 private boolean isRising = false;
10 Pulley(GLucose glucose) {
12 for (int i = 0; i < NUM_DIVISIONS; ++i) {
13 addModulator(gravity[i] = new Accelerator(0, 0, 0));
14 addModulator(delays[i] = new Click(0));
16 addModulator(reset).start();
20 private void trigger() {
23 for (Accelerator g : gravity) {
25 g.setSpeed(random(40, 50), 0).start();
27 g.setVelocity(0).setAcceleration(-420);
28 delays[i].setDuration(random(0, 500)).trigger();
34 public void run(double deltaMs) {
39 for (Click d : delays) {
47 for (Accelerator g : gravity) {
49 if (g.getValuef() > model.yMax) {
51 } else if (g.getValuef() > model.yMax*.55) {
52 if (g.getVelocityf() > 10) {
53 g.setAcceleration(-16);
59 if (g.getValuef() < 0) {
60 g.setValue(-g.getValuef());
61 g.setVelocity(-g.getVelocityf() * random(0.74, 0.84));
66 for (Point p : model.points) {
67 int i = (int) constrain((p.x - model.xMin) * NUM_DIVISIONS / (model.xMax - model.xMin), 0, NUM_DIVISIONS-1);
68 colors[p.index] = color(
69 (lx.getBaseHuef() + abs(p.x - model.cx)*.8 + p.y*.4) % 360,
70 constrain(130 - p.y*.8, 0, 100),
71 max(0, 100 - abs(p.y - gravity[i].getValuef())*4.)
77 class ViolinWave extends SCPattern {
79 BasicParameter level = new BasicParameter("LVL", 0.45);
80 BasicParameter range = new BasicParameter("RNG", 0.5);
81 BasicParameter edge = new BasicParameter("EDG", 0.5);
82 BasicParameter release = new BasicParameter("RLS", 0.5);
83 BasicParameter speed = new BasicParameter("SPD", 0.5);
84 BasicParameter amp = new BasicParameter("AMP", 0.25);
85 BasicParameter period = new BasicParameter("WAVE", 0.5);
86 BasicParameter pSize = new BasicParameter("PSIZE", 0.5);
87 BasicParameter pSpeed = new BasicParameter("PSPD", 0.5);
88 BasicParameter pDensity = new BasicParameter("PDENS", 0.25);
90 LinearEnvelope dbValue = new LinearEnvelope(0, 0, 10);
92 ViolinWave(GLucose glucose) {
97 addParameter(release);
100 addParameter(period);
102 addParameter(pSpeed);
103 addParameter(pDensity);
105 addModulator(dbValue);
108 final List<Particle> particles = new ArrayList<Particle>();
112 LinearEnvelope x = new LinearEnvelope(0, 0, 0);
113 LinearEnvelope y = new LinearEnvelope(0, 0, 0);
120 Particle trigger(boolean direction) {
121 float xInit = random(model.xMin, model.xMax);
122 float time = 3000 - 2500*pSpeed.getValuef();
123 x.setRange(xInit, xInit + random(-40, 40), time).trigger();
124 y.setRange(model.cy + 10, direction ? model.yMax + 50 : model.yMin - 50, time).trigger();
129 return x.isRunning() || y.isRunning();
132 public void run(double deltaMs) {
137 float pFalloff = (30 - 27*pSize.getValuef());
138 for (Point p : model.points) {
139 float b = 100 - pFalloff * (abs(p.x - x.getValuef()) + abs(p.y - y.getValuef()));
141 colors[p.index] = blendColor(colors[p.index], color(
142 lx.getBaseHuef(), 20, b
149 float[] centers = new float[30];
151 boolean rising = true;
153 void fireParticle(boolean direction) {
154 boolean gotOne = false;
155 for (Particle p : particles) {
157 p.trigger(direction);
161 particles.add(new Particle().trigger(direction));
164 public void run(double deltaMs) {
165 accum += deltaMs / (1000. - 900.*speed.getValuef());
166 for (int i = 0; i < centers.length; ++i) {
167 centers[i] = model.cy + 30*amp.getValuef()*sin((float) (accum + (i-centers.length/2.)/(1. + 9.*period.getValuef())));
170 float zeroDBReference = pow(10, (50 - 190*level.getValuef())/20.);
171 float dB = 20*GraphicEQ.log10(lx.audioInput().mix.level() / zeroDBReference);
172 if (dB > dbValue.getValuef()) {
174 dbValue.setRangeFromHereTo(dB, 10).trigger();
177 for (int j = 0; j < pDensity.getValuef()*3; ++j) {
183 dbValue.setRangeFromHereTo(max(dB, -96), 50 + 1000*release.getValuef()).trigger();
185 float edg = 1 + edge.getValuef() * 40;
186 float rng = (78 - 64 * range.getValuef()) / (model.yMax - model.cy);
187 float val = max(2, dbValue.getValuef());
189 for (Point p : model.points) {
190 int ci = (int) lerp(0, centers.length-1, (p.x - model.xMin) / (model.xMax - model.xMin));
191 float rFactor = 1.0 - 0.9 * abs(p.x - model.cx) / (model.xMax - model.cx);
192 colors[p.index] = color(
193 (lx.getBaseHuef() + abs(p.x - model.cx)) % 360,
194 min(100, 20 + 8*abs(p.y - centers[ci])),
195 constrain(edg*(val*rFactor - rng * abs(p.y-centers[ci])), 0, 100)
199 for (Particle p : particles) {
205 class BouncyBalls extends SCPattern {
207 static final int NUM_BALLS = 6;
212 TriangleLFO xPos = new TriangleLFO(0, model.xMax, random(8000, 19000));
216 addModulator(xPos).setBasis(random(0, TWO_PI)).start();
217 addModulator(yPos = new Accelerator(0, 0, 0));
218 zPos = lerp(model.zMin, model.zMax, (i+2.) / (NUM_BALLS + 4.));
221 void bounce(float midiVel) {
222 float v = 100 + 8*midiVel;
223 yPos.setSpeed(v, getAccel(v, 60 / lx.tempo.bpmf())).start();
226 float getAccel(float v, float oneBeat) {
227 return -2*v / oneBeat;
230 void run(double deltaMs) {
231 float flrLevel = flr.getValuef() * model.xMax/2.;
232 if (yPos.getValuef() < flrLevel) {
233 if (yPos.getVelocity() < -50) {
234 yPos.setValue(2*flrLevel-yPos.getValuef());
235 float v = -yPos.getVelocityf() * bounce.getValuef();
236 yPos.setSpeed(v, getAccel(v, 60 / lx.tempo.bpmf()));
238 yPos.setValue(flrLevel).stop();
241 float falloff = 130.f / (12 + blobSize.getValuef() * 36);
242 float xv = xPos.getValuef();
243 float yv = yPos.getValuef();
245 for (Point p : model.points) {
246 float d = sqrt((p.x-xv)*(p.x-xv) + (p.y-yv)*(p.y-yv) + .1*(p.z-zPos)*(p.z-zPos));
247 float b = constrain(130 - falloff*d, 0, 100);
249 colors[p.index] = blendColor(colors[p.index], color(
250 (lx.getBaseHuef() + p.y*.5 + abs(model.cx - p.x) * .5) % 360,
251 max(0, 100 - .45*(p.y - flrLevel)),
259 final BouncyBall[] balls = new BouncyBall[NUM_BALLS];
261 final BasicParameter bounce = new BasicParameter("BNC", .8);
262 final BasicParameter flr = new BasicParameter("FLR", 0);
263 final BasicParameter blobSize = new BasicParameter("SIZE", 0.5);
265 BouncyBalls(GLucose glucose) {
267 for (int i = 0; i < balls.length; ++i) {
268 balls[i] = new BouncyBall(i);
270 addParameter(bounce);
272 addParameter(blobSize);
275 public void run(double deltaMs) {
277 for (BouncyBall b : balls) {
282 public boolean noteOnReceived(Note note) {
283 int pitch = (note.getPitch() + note.getChannel()) % NUM_BALLS;
284 balls[pitch].bounce(note.getVelocity());
289 class SpaceTime extends SCPattern {
291 SinLFO pos = new SinLFO(0, 1, 3000);
292 SinLFO rate = new SinLFO(1000, 9000, 13000);
293 SinLFO falloff = new SinLFO(10, 70, 5000);
296 BasicParameter rateParameter = new BasicParameter("RATE", 0.5);
297 BasicParameter sizeParameter = new BasicParameter("SIZE", 0.5);
300 public SpaceTime(GLucose glucose) {
303 addModulator(pos).trigger();
304 addModulator(rate).trigger();
305 addModulator(falloff).trigger();
306 pos.modulateDurationBy(rate);
307 addParameter(rateParameter);
308 addParameter(sizeParameter);
311 public void onParameterChanged(LXParameter parameter) {
312 if (parameter == rateParameter) {
313 rate.stop().setValue(9000 - 8000*parameter.getValuef());
314 } else if (parameter == sizeParameter) {
315 falloff.stop().setValue(70 - 60*parameter.getValuef());
319 void run(double deltaMs) {
320 angle += deltaMs * 0.0007;
321 float sVal1 = model.strips.size() * (0.5 + 0.5*sin(angle));
322 float sVal2 = model.strips.size() * (0.5 + 0.5*cos(angle));
324 float pVal = pos.getValuef();
325 float fVal = falloff.getValuef();
328 for (Strip strip : model.strips) {
330 for (Point p : strip.points) {
331 colors[p.index] = color(
332 (lx.getBaseHuef() + 360 - p.fx*.2 + p.fy * .3) % 360,
333 constrain(.4 * min(abs(s - sVal1), abs(s - sVal2)), 20, 100),
334 max(0, 100 - fVal*abs(i - pVal*(strip.metrics.numPoints - 1)))
343 class Swarm extends SCPattern {
345 SawLFO offset = new SawLFO(0, 1, 1000);
346 SinLFO rate = new SinLFO(350, 1200, 63000);
347 SinLFO falloff = new SinLFO(15, 50, 17000);
348 SinLFO fX = new SinLFO(0, model.xMax, 19000);
349 SinLFO fY = new SinLFO(0, model.yMax, 11000);
350 SinLFO hOffX = new SinLFO(0, model.xMax, 13000);
352 public Swarm(GLucose glucose) {
355 addModulator(offset).trigger();
356 addModulator(rate).trigger();
357 addModulator(falloff).trigger();
358 addModulator(fX).trigger();
359 addModulator(fY).trigger();
360 addModulator(hOffX).trigger();
361 offset.modulateDurationBy(rate);
364 float modDist(float v1, float v2, float mod) {
368 return min(v2-v1, v1+mod-v2);
371 return min(v1-v2, v2+mod-v1);
375 void run(double deltaMs) {
377 for (Strip strip : model.strips ) {
379 for (Point p : strip.points) {
380 float fV = max(-1, 1 - dist(p.fx/2., p.fy, fX.getValuef()/2., fY.getValuef()) / 64.);
381 colors[p.index] = color(
382 (lx.getBaseHuef() + 0.3 * abs(p.fx - hOffX.getValuef())) % 360,
383 constrain(80 + 40 * fV, 0, 100),
384 constrain(100 - (30 - fV * falloff.getValuef()) * modDist(i + (s*63)%61, offset.getValuef() * strip.metrics.numPoints, strip.metrics.numPoints), 0, 100)
393 class SwipeTransition extends SCTransition {
395 final BasicParameter bleed = new BasicParameter("WIDTH", 0.5);
397 SwipeTransition(GLucose glucose) {
403 void computeBlend(int[] c1, int[] c2, double progress) {
404 float bleedf = 10 + bleed.getValuef() * 200.;
405 float xPos = (float) (-bleedf + progress * (model.xMax + bleedf));
406 for (Point p : model.points) {
407 float d = (p.fx - xPos) / bleedf;
409 colors[p.index] = c2[p.index];
411 colors[p.index] = c1[p.index];
413 colors[p.index] = lerpColor(c2[p.index], c1[p.index], d, RGB);
419 abstract class BlendTransition extends SCTransition {
423 BlendTransition(GLucose glucose, int blendType) {
425 this.blendType = blendType;
428 void computeBlend(int[] c1, int[] c2, double progress) {
429 if (progress < 0.5) {
430 for (int i = 0; i < c1.length; ++i) {
431 colors[i] = lerpColor(
433 blendColor(c1[i], c2[i], blendType),
434 (float) (2.*progress),
438 for (int i = 0; i < c1.length; ++i) {
439 colors[i] = lerpColor(
441 blendColor(c1[i], c2[i], blendType),
442 (float) (2.*(1. - progress)),
449 class MultiplyTransition extends BlendTransition {
450 MultiplyTransition(GLucose glucose) {
451 super(glucose, MULTIPLY);
455 class ScreenTransition extends BlendTransition {
456 ScreenTransition(GLucose glucose) {
457 super(glucose, SCREEN);
461 class BurnTransition extends BlendTransition {
462 BurnTransition(GLucose glucose) {
463 super(glucose, BURN);
467 class DodgeTransition extends BlendTransition {
468 DodgeTransition(GLucose glucose) {
469 super(glucose, DODGE);
473 class OverlayTransition extends BlendTransition {
474 OverlayTransition(GLucose glucose) {
475 super(glucose, OVERLAY);
479 class AddTransition extends BlendTransition {
480 AddTransition(GLucose glucose) {
485 class SubtractTransition extends BlendTransition {
486 SubtractTransition(GLucose glucose) {
487 super(glucose, SUBTRACT);
491 class SoftLightTransition extends BlendTransition {
492 SoftLightTransition(GLucose glucose) {
493 super(glucose, SOFT_LIGHT);
497 class BassPod extends SCPattern {
499 private GraphicEQ eq = null;
501 public BassPod(GLucose glucose) {
505 protected void onActive() {
507 eq = new GraphicEQ(lx, 16);
508 eq.slope.setValue(0.6);
509 addParameter(eq.level);
510 addParameter(eq.range);
511 addParameter(eq.attack);
512 addParameter(eq.release);
513 addParameter(eq.slope);
517 public void run(double deltaMs) {
520 float bassLevel = eq.getAverageLevel(0, 5);
522 for (Point p : model.points) {
523 int avgIndex = (int) constrain(1 + abs(p.fx-model.xMax/2.)/(model.xMax/2.)*(eq.numBands-5), 0, eq.numBands-5);
525 for (int i = avgIndex; i < avgIndex + 5; ++i) {
526 value += eq.getLevel(i);
530 float b = constrain(8 * (value*model.yMax - abs(p.fy-model.yMax/2.)), 0, 100);
531 colors[p.index] = color(
532 (lx.getBaseHuef() + abs(p.fy - model.cy) + abs(p.fx - model.cx)) % 360,
533 constrain(bassLevel*240 - .6*dist(p.fx, p.fy, model.cx, model.cy), 0, 100),
541 class CubeEQ extends SCPattern {
543 private GraphicEQ eq = null;
545 private final BasicParameter edge = new BasicParameter("EDGE", 0.5);
546 private final BasicParameter clr = new BasicParameter("CLR", 0.5);
547 private final BasicParameter blockiness = new BasicParameter("BLK", 0.5);
549 public CubeEQ(GLucose glucose) {
553 protected void onActive() {
555 eq = new GraphicEQ(lx, 16);
556 addParameter(eq.level);
557 addParameter(eq.range);
558 addParameter(eq.attack);
559 addParameter(eq.release);
560 addParameter(eq.slope);
563 addParameter(blockiness);
567 public void run(double deltaMs) {
570 float edgeConst = 2 + 30*edge.getValuef();
571 float clrConst = 1.1 + clr.getValuef();
573 for (Point p : model.points) {
574 float avgIndex = constrain(2 + p.fx / model.xMax * (eq.numBands-4), 0, eq.numBands-4);
575 int avgFloor = (int) avgIndex;
577 float leftVal = eq.getLevel(avgFloor);
578 float rightVal = eq.getLevel(avgFloor+1);
579 float smoothValue = lerp(leftVal, rightVal, avgIndex-avgFloor);
581 float chunkyValue = (
582 eq.getLevel(avgFloor/4*4) +
583 eq.getLevel(avgFloor/4*4 + 1) +
584 eq.getLevel(avgFloor/4*4 + 2) +
585 eq.getLevel(avgFloor/4*4 + 3)
588 float value = lerp(smoothValue, chunkyValue, blockiness.getValuef());
590 float b = constrain(edgeConst * (value*model.yMax - p.fy), 0, 100);
591 colors[p.index] = color(
592 (480 + lx.getBaseHuef() - min(clrConst*p.fy, 120)) % 360,
600 class BoomEffect extends SCEffect {
602 final BasicParameter falloff = new BasicParameter("WIDTH", 0.5);
603 final BasicParameter speed = new BasicParameter("SPD", 0.5);
604 final BasicParameter bright = new BasicParameter("BRT", 1.0);
605 final BasicParameter sat = new BasicParameter("SAT", 0.2);
606 List<Layer> layers = new ArrayList<Layer>();
607 final float maxr = sqrt(model.xMax*model.xMax + model.yMax*model.yMax + model.zMax*model.zMax) + 10;
610 LinearEnvelope boom = new LinearEnvelope(-40, 500, 1300);
618 float falloffv = falloffv();
619 boom.setRange(-100 / falloffv, maxr + 100/falloffv, 4000 - speed.getValuef() * 3300);
623 void doApply(int[] colors) {
624 float brightv = 100 * bright.getValuef();
625 float falloffv = falloffv();
626 float satv = sat.getValuef() * 100;
627 float huev = lx.getBaseHuef();
628 for (Point p : model.points) {
629 colors[p.index] = blendColor(
631 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)),
637 BoomEffect(GLucose glucose) {
638 super(glucose, true);
639 addParameter(falloff);
641 addParameter(bright);
645 public void onEnable() {
646 for (Layer l : layers) {
647 if (!l.boom.isRunning()) {
652 layers.add(new Layer());
655 private float falloffv() {
656 return 20 - 19 * falloff.getValuef();
659 public void onTrigger() {
663 public void doApply(int[] colors) {
664 for (Layer l : layers) {
665 if (l.boom.isRunning()) {
672 public class PianoKeyPattern extends SCPattern {
674 final LinearEnvelope[] cubeBrt;
676 final BasicParameter attack = new BasicParameter("ATK", 0.1);
677 final BasicParameter release = new BasicParameter("REL", 0.5);
678 final BasicParameter level = new BasicParameter("AMB", 0.6);
680 PianoKeyPattern(GLucose glucose) {
683 addParameter(attack);
684 addParameter(release);
686 cubeBrt = new LinearEnvelope[model.cubes.size() / 4];
687 for (int i = 0; i < cubeBrt.length; ++i) {
688 addModulator(cubeBrt[i] = new LinearEnvelope(0, 0, 100));
690 base = new SinLFO[model.cubes.size() / 12];
691 for (int i = 0; i < base.length; ++i) {
692 addModulator(base[i] = new SinLFO(0, 1, 7000 + 1000*i)).trigger();
696 private float getAttackTime() {
697 return 15 + attack.getValuef()*attack.getValuef() * 2000;
700 private float getReleaseTime() {
701 return 15 + release.getValuef() * 3000;
704 private LinearEnvelope getEnvelope(int index) {
705 return cubeBrt[index % cubeBrt.length];
708 private SinLFO getBase(int index) {
709 return base[index % base.length];
712 public boolean noteOnReceived(Note note) {
713 LinearEnvelope env = getEnvelope(note.getPitch());
714 env.setEndVal(min(1, env.getValuef() + (note.getVelocity() / 127.)), getAttackTime()).start();
718 public boolean noteOffReceived(Note note) {
719 getEnvelope(note.getPitch()).setEndVal(0, getReleaseTime()).start();
723 public void run(double deltaMs) {
725 float huef = lx.getBaseHuef();
726 float levelf = level.getValuef();
727 for (Cube c : model.cubes) {
728 float v = max(getBase(i).getValuef() * levelf/4., getEnvelope(i++).getValuef());
730 (huef + 20*v + abs(c.cx-model.xMax/2.)*.3 + c.cy) % 360,
738 class CrossSections extends SCPattern {
740 final SinLFO x = new SinLFO(0, model.xMax, 5000);
741 final SinLFO y = new SinLFO(0, model.yMax, 6000);
742 final SinLFO z = new SinLFO(0, model.zMax, 7000);
744 final BasicParameter xw = new BasicParameter("XWID", 0.3);
745 final BasicParameter yw = new BasicParameter("YWID", 0.3);
746 final BasicParameter zw = new BasicParameter("ZWID", 0.3);
747 final BasicParameter xr = new BasicParameter("XRAT", 0.7);
748 final BasicParameter yr = new BasicParameter("YRAT", 0.6);
749 final BasicParameter zr = new BasicParameter("ZRAT", 0.5);
750 final BasicParameter xl = new BasicParameter("XLEV", 1);
751 final BasicParameter yl = new BasicParameter("YLEV", 1);
752 final BasicParameter zl = new BasicParameter("ZLEV", 0.5);
755 CrossSections(GLucose glucose) {
757 addModulator(x).trigger();
758 addModulator(y).trigger();
759 addModulator(z).trigger();
763 protected void addParams() {
775 void onParameterChanged(LXParameter p) {
777 x.setDuration(10000 - 8800*p.getValuef());
778 } else if (p == yr) {
779 y.setDuration(10000 - 9000*p.getValuef());
780 } else if (p == zr) {
781 z.setDuration(10000 - 9000*p.getValuef());
787 protected void updateXYZVals() {
793 public void run(double deltaMs) {
796 float xlv = 100*xl.getValuef();
797 float ylv = 100*yl.getValuef();
798 float zlv = 100*zl.getValuef();
800 float xwv = 100. / (10 + 40*xw.getValuef());
801 float ywv = 100. / (10 + 40*yw.getValuef());
802 float zwv = 100. / (10 + 40*zw.getValuef());
804 for (Point p : model.points) {
806 c = blendColor(c, color(
807 (lx.getBaseHuef() + p.fx/10 + p.fy/3) % 360,
808 constrain(140 - 1.1*abs(p.fx - model.xMax/2.), 0, 100),
809 max(0, xlv - xwv*abs(p.fx - xv))
811 c = blendColor(c, color(
812 (lx.getBaseHuef() + 80 + p.fy/10) % 360,
813 constrain(140 - 2.2*abs(p.fy - model.yMax/2.), 0, 100),
814 max(0, ylv - ywv*abs(p.fy - yv))
816 c = blendColor(c, color(
817 (lx.getBaseHuef() + 160 + p.fz / 10 + p.fy/2) % 360,
818 constrain(140 - 2.2*abs(p.fz - model.zMax/2.), 0, 100),
819 max(0, zlv - zwv*abs(p.fz - zv))
826 class Blinders extends SCPattern {
831 final TriangleLFO hs;
833 public Blinders(GLucose glucose) {
836 for (int i = 0; i < m.length; ++i) {
837 addModulator(m[i] = new SinLFO(0.5, 120, (120000. / (3+i)))).trigger();
839 addModulator(r = new TriangleLFO(9000, 15000, 29000)).trigger();
840 addModulator(s = new SinLFO(-20, 275, 11000)).trigger();
841 addModulator(hs = new TriangleLFO(0.1, 0.5, 15000)).trigger();
842 s.modulateDurationBy(r);
845 public void run(double deltaMs) {
846 float hv = lx.getBaseHuef();
848 for (Strip strip : model.strips) {
850 float mv = m[si % m.length].getValuef();
851 for (Point p : strip.points) {
852 colors[p.index] = color(
853 (hv + p.fz + p.fy*hs.getValuef()) % 360,
854 min(100, abs(p.fx - s.getValuef())/2.),
855 max(0, 100 - mv/2. - mv * abs(i - (strip.metrics.length-1)/2.))
864 class Psychedelia extends SCPattern {
867 SinLFO m = new SinLFO(-0.5, NUM-0.5, 9000);
868 SinLFO s = new SinLFO(-20, 147, 11000);
869 TriangleLFO h = new TriangleLFO(0, 240, 19000);
870 SinLFO c = new SinLFO(-.2, .8, 31000);
872 Psychedelia(GLucose glucose) {
874 addModulator(m).trigger();
875 addModulator(s).trigger();
876 addModulator(h).trigger();
877 addModulator(c).trigger();
880 void run(double deltaMs) {
881 float huev = h.getValuef();
882 float cv = c.getValuef();
883 float sv = s.getValuef();
884 float mv = m.getValuef();
886 for (Strip strip : model.strips) {
887 for (Point p : strip.points) {
888 colors[p.index] = color(
889 (huev + i*constrain(cv, 0, 2) + p.fz/2. + p.fx/4.) % 360,
890 min(100, abs(p.fy-sv)),
891 max(0, 100 - 50*abs((i%NUM) - mv))
899 class AskewPlanes extends SCPattern {
902 private final SinLFO a;
903 private final SinLFO b;
904 private final SinLFO c;
911 addModulator(a = new SinLFO(-1, 1, 4000 + 1029*i)).trigger();
912 addModulator(b = new SinLFO(-1, 1, 11000 - 1104*i)).trigger();
913 addModulator(c = new SinLFO(-50, 50, 4000 + 1000*i * ((i % 2 == 0) ? 1 : -1))).trigger();
916 void run(double deltaMs) {
920 denom = sqrt(av*av + bv*bv);
924 final Plane[] planes;
925 final int NUM_PLANES = 3;
927 AskewPlanes(GLucose glucose) {
929 planes = new Plane[NUM_PLANES];
930 for (int i = 0; i < planes.length; ++i) {
931 planes[i] = new Plane(i);
935 public void run(double deltaMs) {
936 float huev = lx.getBaseHuef();
938 // This is super fucking bizarre. But if this is a for loop, the framerate
939 // tanks to like 30FPS, instead of 60. Call them manually and it works fine.
940 // Doesn't make ANY sense... there must be some weird side effect going on
941 // with the Processing internals perhaps?
942 // for (Plane plane : planes) {
943 // plane.run(deltaMs);
945 planes[0].run(deltaMs);
946 planes[1].run(deltaMs);
947 planes[2].run(deltaMs);
949 for (Point p : model.points) {
951 for (Plane plane : planes) {
952 if (plane.denom != 0) {
953 d = min(d, abs(plane.av*(p.fx-model.cx) + plane.bv*(p.fy-model.cy) + plane.cv) / plane.denom);
956 colors[p.index] = color(
957 (huev + abs(p.fx-model.cx)*.3 + p.fy*.8) % 360,
958 max(0, 100 - .8*abs(p.fx - model.cx)),
959 constrain(140 - 10.*d, 0, 100)
965 class ShiftingPlane extends SCPattern {
967 final SinLFO a = new SinLFO(-.2, .2, 5300);
968 final SinLFO b = new SinLFO(1, -1, 13300);
969 final SinLFO c = new SinLFO(-1.4, 1.4, 5700);
970 final SinLFO d = new SinLFO(-10, 10, 9500);
972 ShiftingPlane(GLucose glucose) {
974 addModulator(a).trigger();
975 addModulator(b).trigger();
976 addModulator(c).trigger();
977 addModulator(d).trigger();
980 public void run(double deltaMs) {
981 float hv = lx.getBaseHuef();
982 float av = a.getValuef();
983 float bv = b.getValuef();
984 float cv = c.getValuef();
985 float dv = d.getValuef();
986 float denom = sqrt(av*av + bv*bv + cv*cv);
987 for (Point p : model.points) {
988 float d = abs(av*(p.fx-model.cx) + bv*(p.fy-model.cy) + cv*(p.fz-model.cz) + dv) / denom;
989 colors[p.index] = color(
990 (hv + abs(p.fx-model.cx)*.6 + abs(p.fy-model.cy)*.9 + abs(p.fz - model.cz)) % 360,
991 constrain(110 - d*6, 0, 100),
992 constrain(130 - 7*d, 0, 100)
998 class Traktor extends SCPattern {
1000 final int FRAME_WIDTH = 60;
1002 final BasicParameter speed = new BasicParameter("SPD", 0.5);
1004 private float[] bass = new float[FRAME_WIDTH];
1005 private float[] treble = new float[FRAME_WIDTH];
1007 private int index = 0;
1008 private GraphicEQ eq = null;
1010 public Traktor(GLucose glucose) {
1012 for (int i = 0; i < FRAME_WIDTH; ++i) {
1016 addParameter(speed);
1019 public void onActive() {
1021 eq = new GraphicEQ(lx, 16);
1022 eq.slope.setValue(0.6);
1023 eq.level.setValue(0.65);
1024 eq.range.setValue(0.35);
1025 eq.release.setValue(0.4);
1026 addParameter(eq.level);
1027 addParameter(eq.range);
1028 addParameter(eq.attack);
1029 addParameter(eq.release);
1030 addParameter(eq.slope);
1036 public void run(double deltaMs) {
1039 int stepThresh = (int) (40 - 39*speed.getValuef());
1041 if (counter < stepThresh) {
1044 counter = counter % stepThresh;
1046 index = (index + 1) % FRAME_WIDTH;
1048 float rawBass = eq.getAverageLevel(0, 4);
1049 float rawTreble = eq.getAverageLevel(eq.numBands-7, 7);
1051 bass[index] = rawBass * rawBass * rawBass * rawBass;
1052 treble[index] = rawTreble * rawTreble;
1054 for (Point p : model.points) {
1055 int i = (int) constrain((model.xMax - p.x) / model.xMax * FRAME_WIDTH, 0, FRAME_WIDTH-1);
1056 int pos = (index + FRAME_WIDTH - i) % FRAME_WIDTH;
1058 colors[p.index] = color(
1059 (360 + lx.getBaseHuef() + .8*abs(p.x-model.cx)) % 360,
1061 constrain(9 * (bass[pos]*model.cy - abs(p.fy - model.cy)), 0, 100)
1063 colors[p.index] = blendColor(colors[p.index], color(
1064 (400 + lx.getBaseHuef() + .5*abs(p.x-model.cx)) % 360,
1066 constrain(5 * (treble[pos]*.6*model.cy - abs(p.fy - model.cy)), 0, 100)
1073 class ColorFuckerEffect extends SCEffect {
1075 BasicParameter hueShift = new BasicParameter("HSHFT", 0);
1076 BasicParameter sat = new BasicParameter("SAT", 1);
1077 BasicParameter bright = new BasicParameter("BRT", 1);
1079 ColorFuckerEffect(GLucose glucose) {
1081 addParameter(hueShift);
1082 addParameter(bright);
1086 public void doApply(int[] colors) {
1090 float bMod = bright.getValuef();
1091 float sMod = sat.getValuef();
1092 float hMod = hueShift.getValuef();
1093 if (bMod < 1 || sMod < 1 || hMod > 0) {
1094 for (int i = 0; i < colors.length; ++i) {
1096 (hue(colors[i]) + hueShift.getValuef()*360.) % 360,
1097 saturation(colors[i]) * sat.getValuef(),
1098 brightness(colors[i]) * bright.getValuef()
1105 class BlurEffect extends SCEffect {
1107 final LXParameter amount = new BasicParameter("AMT", 0);
1109 final LinearEnvelope env = new LinearEnvelope(0, 1, 100);
1111 BlurEffect(GLucose glucose) {
1113 addParameter(amount);
1115 frame = new int[lx.total];
1116 for (int i = 0; i < frame.length; ++i) {
1121 public void onEnable() {
1122 env.setRangeFromHereTo(1, 400).start();
1123 for (int i = 0; i < frame.length; ++i) {
1128 public void onDisable() {
1129 env.setRangeFromHereTo(0, 1000).start();
1132 public void doApply(int[] colors) {
1133 float amt = env.getValuef() * amount.getValuef();
1136 amt = 1 - (amt*amt*amt);
1137 for (int i = 0; i < colors.length; ++i) {
1138 // frame[i] = colors[i] = blendColor(colors[i], lerpColor(#000000, frame[i], amt, RGB), SCREEN);
1139 frame[i] = colors[i] = lerpColor(colors[i], blendColor(colors[i], frame[i], SCREEN), amt, RGB);