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 private BasicParameter sz = new BasicParameter("SIZE", 0.5);
11 private BasicParameter beatAmount = new BasicParameter("BEAT", 0.1);
13 Pulley(GLucose glucose) {
15 for (int i = 0; i < NUM_DIVISIONS; ++i) {
16 addModulator(gravity[i] = new Accelerator(0, 0, 0));
17 addModulator(delays[i] = new Click(0));
19 addModulator(reset).start();
21 addParameter(beatAmount);
25 private void trigger() {
28 for (Accelerator g : gravity) {
30 g.setSpeed(random(40, 50), 0).start();
32 g.setVelocity(0).setAcceleration(-420);
33 delays[i].setDuration(random(0, 500)).trigger();
39 public void run(double deltaMs) {
44 for (Click d : delays) {
52 for (Accelerator g : gravity) {
54 if (g.getValuef() > model.yMax) {
56 } else if (g.getValuef() > model.yMax*.55) {
57 if (g.getVelocityf() > 10) {
58 g.setAcceleration(-16);
64 if (g.getValuef() < 0) {
65 g.setValue(-g.getValuef());
66 g.setVelocity(-g.getVelocityf() * random(0.74, 0.84));
71 float fPos = 1 - lx.tempo.rampf();
73 fPos = .2 + 4 * (.2 - fPos);
75 float falloff = 100. / (3 + sz.getValuef() * 36 + fPos * beatAmount.getValuef()*48);
76 for (Point p : model.points) {
77 int i = (int) constrain((p.x - model.xMin) * NUM_DIVISIONS / (model.xMax - model.xMin), 0, NUM_DIVISIONS-1);
78 colors[p.index] = color(
79 (lx.getBaseHuef() + abs(p.x - model.cx)*.8 + p.y*.4) % 360,
80 constrain(130 - p.y*.8, 0, 100),
81 max(0, 100 - abs(p.y - gravity[i].getValuef())*falloff)
87 class ViolinWave extends SCPattern {
89 BasicParameter level = new BasicParameter("LVL", 0.45);
90 BasicParameter range = new BasicParameter("RNG", 0.5);
91 BasicParameter edge = new BasicParameter("EDG", 0.5);
92 BasicParameter release = new BasicParameter("RLS", 0.5);
93 BasicParameter speed = new BasicParameter("SPD", 0.5);
94 BasicParameter amp = new BasicParameter("AMP", 0.25);
95 BasicParameter period = new BasicParameter("WAVE", 0.5);
96 BasicParameter pSize = new BasicParameter("PSIZE", 0.5);
97 BasicParameter pSpeed = new BasicParameter("PSPD", 0.5);
98 BasicParameter pDensity = new BasicParameter("PDENS", 0.25);
100 LinearEnvelope dbValue = new LinearEnvelope(0, 0, 10);
102 ViolinWave(GLucose glucose) {
107 addParameter(release);
110 addParameter(period);
112 addParameter(pSpeed);
113 addParameter(pDensity);
115 addModulator(dbValue);
118 final List<Particle> particles = new ArrayList<Particle>();
122 LinearEnvelope x = new LinearEnvelope(0, 0, 0);
123 LinearEnvelope y = new LinearEnvelope(0, 0, 0);
130 Particle trigger(boolean direction) {
131 float xInit = random(model.xMin, model.xMax);
132 float time = 3000 - 2500*pSpeed.getValuef();
133 x.setRange(xInit, xInit + random(-40, 40), time).trigger();
134 y.setRange(model.cy + 10, direction ? model.yMax + 50 : model.yMin - 50, time).trigger();
139 return x.isRunning() || y.isRunning();
142 public void run(double deltaMs) {
147 float pFalloff = (30 - 27*pSize.getValuef());
148 for (Point p : model.points) {
149 float b = 100 - pFalloff * (abs(p.x - x.getValuef()) + abs(p.y - y.getValuef()));
151 colors[p.index] = blendColor(colors[p.index], color(
152 lx.getBaseHuef(), 20, b
159 float[] centers = new float[30];
161 boolean rising = true;
163 void fireParticle(boolean direction) {
164 boolean gotOne = false;
165 for (Particle p : particles) {
167 p.trigger(direction);
171 particles.add(new Particle().trigger(direction));
174 public void run(double deltaMs) {
175 accum += deltaMs / (1000. - 900.*speed.getValuef());
176 for (int i = 0; i < centers.length; ++i) {
177 centers[i] = model.cy + 30*amp.getValuef()*sin((float) (accum + (i-centers.length/2.)/(1. + 9.*period.getValuef())));
180 float zeroDBReference = pow(10, (50 - 190*level.getValuef())/20.);
181 float dB = 20*GraphicEQ.log10(lx.audioInput().mix.level() / zeroDBReference);
182 if (dB > dbValue.getValuef()) {
184 dbValue.setRangeFromHereTo(dB, 10).trigger();
187 for (int j = 0; j < pDensity.getValuef()*3; ++j) {
193 dbValue.setRangeFromHereTo(max(dB, -96), 50 + 1000*release.getValuef()).trigger();
195 float edg = 1 + edge.getValuef() * 40;
196 float rng = (78 - 64 * range.getValuef()) / (model.yMax - model.cy);
197 float val = max(2, dbValue.getValuef());
199 for (Point p : model.points) {
200 int ci = (int) lerp(0, centers.length-1, (p.x - model.xMin) / (model.xMax - model.xMin));
201 float rFactor = 1.0 - 0.9 * abs(p.x - model.cx) / (model.xMax - model.cx);
202 colors[p.index] = color(
203 (lx.getBaseHuef() + abs(p.x - model.cx)) % 360,
204 min(100, 20 + 8*abs(p.y - centers[ci])),
205 constrain(edg*(val*rFactor - rng * abs(p.y-centers[ci])), 0, 100)
209 for (Particle p : particles) {
215 class BouncyBalls extends SCPattern {
217 static final int NUM_BALLS = 6;
222 TriangleLFO xPos = new TriangleLFO(0, model.xMax, random(8000, 19000));
226 addModulator(xPos).setBasis(random(0, TWO_PI)).start();
227 addModulator(yPos = new Accelerator(0, 0, 0));
228 zPos = lerp(model.zMin, model.zMax, (i+2.) / (NUM_BALLS + 4.));
231 void bounce(float midiVel) {
232 float v = 100 + 8*midiVel;
233 yPos.setSpeed(v, getAccel(v, 60 / lx.tempo.bpmf())).start();
236 float getAccel(float v, float oneBeat) {
237 return -2*v / oneBeat;
240 void run(double deltaMs) {
241 float flrLevel = flr.getValuef() * model.xMax/2.;
242 if (yPos.getValuef() < flrLevel) {
243 if (yPos.getVelocity() < -50) {
244 yPos.setValue(2*flrLevel-yPos.getValuef());
245 float v = -yPos.getVelocityf() * bounce.getValuef();
246 yPos.setSpeed(v, getAccel(v, 60 / lx.tempo.bpmf()));
248 yPos.setValue(flrLevel).stop();
251 float falloff = 130.f / (12 + blobSize.getValuef() * 36);
252 float xv = xPos.getValuef();
253 float yv = yPos.getValuef();
255 for (Point p : model.points) {
256 float d = sqrt((p.x-xv)*(p.x-xv) + (p.y-yv)*(p.y-yv) + .1*(p.z-zPos)*(p.z-zPos));
257 float b = constrain(130 - falloff*d, 0, 100);
259 colors[p.index] = blendColor(colors[p.index], color(
260 (lx.getBaseHuef() + p.y*.5 + abs(model.cx - p.x) * .5) % 360,
261 max(0, 100 - .45*(p.y - flrLevel)),
269 final BouncyBall[] balls = new BouncyBall[NUM_BALLS];
271 final BasicParameter bounce = new BasicParameter("BNC", .8);
272 final BasicParameter flr = new BasicParameter("FLR", 0);
273 final BasicParameter blobSize = new BasicParameter("SIZE", 0.5);
275 BouncyBalls(GLucose glucose) {
277 for (int i = 0; i < balls.length; ++i) {
278 balls[i] = new BouncyBall(i);
280 addParameter(bounce);
282 addParameter(blobSize);
285 public void run(double deltaMs) {
287 for (BouncyBall b : balls) {
292 public boolean noteOnReceived(Note note) {
293 int pitch = (note.getPitch() + note.getChannel()) % NUM_BALLS;
294 balls[pitch].bounce(note.getVelocity());
299 class SpaceTime extends SCPattern {
301 SinLFO pos = new SinLFO(0, 1, 3000);
302 SinLFO rate = new SinLFO(1000, 9000, 13000);
303 SinLFO falloff = new SinLFO(10, 70, 5000);
306 BasicParameter rateParameter = new BasicParameter("RATE", 0.5);
307 BasicParameter sizeParameter = new BasicParameter("SIZE", 0.5);
310 public SpaceTime(GLucose glucose) {
313 addModulator(pos).trigger();
314 addModulator(rate).trigger();
315 addModulator(falloff).trigger();
316 pos.modulateDurationBy(rate);
317 addParameter(rateParameter);
318 addParameter(sizeParameter);
321 public void onParameterChanged(LXParameter parameter) {
322 if (parameter == rateParameter) {
323 rate.stop().setValue(9000 - 8000*parameter.getValuef());
324 } else if (parameter == sizeParameter) {
325 falloff.stop().setValue(70 - 60*parameter.getValuef());
329 void run(double deltaMs) {
330 angle += deltaMs * 0.0007;
331 float sVal1 = model.strips.size() * (0.5 + 0.5*sin(angle));
332 float sVal2 = model.strips.size() * (0.5 + 0.5*cos(angle));
334 float pVal = pos.getValuef();
335 float fVal = falloff.getValuef();
338 for (Strip strip : model.strips) {
340 for (Point p : strip.points) {
341 colors[p.index] = color(
342 (lx.getBaseHuef() + 360 - p.fx*.2 + p.fy * .3) % 360,
343 constrain(.4 * min(abs(s - sVal1), abs(s - sVal2)), 20, 100),
344 max(0, 100 - fVal*abs(i - pVal*(strip.metrics.numPoints - 1)))
353 class Swarm extends SCPattern {
355 SawLFO offset = new SawLFO(0, 1, 1000);
356 SinLFO rate = new SinLFO(350, 1200, 63000);
357 SinLFO falloff = new SinLFO(15, 50, 17000);
358 SinLFO fX = new SinLFO(0, model.xMax, 19000);
359 SinLFO fY = new SinLFO(0, model.yMax, 11000);
360 SinLFO hOffX = new SinLFO(0, model.xMax, 13000);
362 public Swarm(GLucose glucose) {
365 addModulator(offset).trigger();
366 addModulator(rate).trigger();
367 addModulator(falloff).trigger();
368 addModulator(fX).trigger();
369 addModulator(fY).trigger();
370 addModulator(hOffX).trigger();
371 offset.modulateDurationBy(rate);
374 float modDist(float v1, float v2, float mod) {
378 return min(v2-v1, v1+mod-v2);
381 return min(v1-v2, v2+mod-v1);
385 void run(double deltaMs) {
387 for (Strip strip : model.strips ) {
389 for (Point p : strip.points) {
390 float fV = max(-1, 1 - dist(p.fx/2., p.fy, fX.getValuef()/2., fY.getValuef()) / 64.);
391 colors[p.index] = color(
392 (lx.getBaseHuef() + 0.3 * abs(p.fx - hOffX.getValuef())) % 360,
393 constrain(80 + 40 * fV, 0, 100),
394 constrain(100 - (30 - fV * falloff.getValuef()) * modDist(i + (s*63)%61, offset.getValuef() * strip.metrics.numPoints, strip.metrics.numPoints), 0, 100)
403 class SwipeTransition extends SCTransition {
405 final BasicParameter bleed = new BasicParameter("WIDTH", 0.5);
407 SwipeTransition(GLucose glucose) {
413 void computeBlend(int[] c1, int[] c2, double progress) {
414 float bleedf = 10 + bleed.getValuef() * 200.;
415 float xPos = (float) (-bleedf + progress * (model.xMax + bleedf));
416 for (Point p : model.points) {
417 float d = (p.fx - xPos) / bleedf;
419 colors[p.index] = c2[p.index];
421 colors[p.index] = c1[p.index];
423 colors[p.index] = lerpColor(c2[p.index], c1[p.index], d, RGB);
429 abstract class BlendTransition extends SCTransition {
433 BlendTransition(GLucose glucose, int blendType) {
435 this.blendType = blendType;
438 void computeBlend(int[] c1, int[] c2, double progress) {
439 if (progress < 0.5) {
440 for (int i = 0; i < c1.length; ++i) {
441 colors[i] = lerpColor(
443 blendColor(c1[i], c2[i], blendType),
444 (float) (2.*progress),
448 for (int i = 0; i < c1.length; ++i) {
449 colors[i] = lerpColor(
451 blendColor(c1[i], c2[i], blendType),
452 (float) (2.*(1. - progress)),
459 class MultiplyTransition extends BlendTransition {
460 MultiplyTransition(GLucose glucose) {
461 super(glucose, MULTIPLY);
465 class ScreenTransition extends BlendTransition {
466 ScreenTransition(GLucose glucose) {
467 super(glucose, SCREEN);
471 class BurnTransition extends BlendTransition {
472 BurnTransition(GLucose glucose) {
473 super(glucose, BURN);
477 class DodgeTransition extends BlendTransition {
478 DodgeTransition(GLucose glucose) {
479 super(glucose, DODGE);
483 class OverlayTransition extends BlendTransition {
484 OverlayTransition(GLucose glucose) {
485 super(glucose, OVERLAY);
489 class AddTransition extends BlendTransition {
490 AddTransition(GLucose glucose) {
495 class SubtractTransition extends BlendTransition {
496 SubtractTransition(GLucose glucose) {
497 super(glucose, SUBTRACT);
501 class SoftLightTransition extends BlendTransition {
502 SoftLightTransition(GLucose glucose) {
503 super(glucose, SOFT_LIGHT);
507 class BassPod extends SCPattern {
509 private GraphicEQ eq = null;
511 public BassPod(GLucose glucose) {
515 protected void onActive() {
517 eq = new GraphicEQ(lx, 16);
518 eq.slope.setValue(0.6);
519 addParameter(eq.level);
520 addParameter(eq.range);
521 addParameter(eq.attack);
522 addParameter(eq.release);
523 addParameter(eq.slope);
527 public void run(double deltaMs) {
530 float bassLevel = eq.getAverageLevel(0, 5);
532 for (Point p : model.points) {
533 int avgIndex = (int) constrain(1 + abs(p.fx-model.xMax/2.)/(model.xMax/2.)*(eq.numBands-5), 0, eq.numBands-5);
535 for (int i = avgIndex; i < avgIndex + 5; ++i) {
536 value += eq.getLevel(i);
540 float b = constrain(8 * (value*model.yMax - abs(p.fy-model.yMax/2.)), 0, 100);
541 colors[p.index] = color(
542 (lx.getBaseHuef() + abs(p.fy - model.cy) + abs(p.fx - model.cx)) % 360,
543 constrain(bassLevel*240 - .6*dist(p.fx, p.fy, model.cx, model.cy), 0, 100),
551 class CubeEQ extends SCPattern {
553 private GraphicEQ eq = null;
555 private final BasicParameter edge = new BasicParameter("EDGE", 0.5);
556 private final BasicParameter clr = new BasicParameter("CLR", 0.5);
557 private final BasicParameter blockiness = new BasicParameter("BLK", 0.5);
559 public CubeEQ(GLucose glucose) {
563 protected void onActive() {
565 eq = new GraphicEQ(lx, 16);
566 addParameter(eq.level);
567 addParameter(eq.range);
568 addParameter(eq.attack);
569 addParameter(eq.release);
570 addParameter(eq.slope);
573 addParameter(blockiness);
577 public void run(double deltaMs) {
580 float edgeConst = 2 + 30*edge.getValuef();
581 float clrConst = 1.1 + clr.getValuef();
583 for (Point p : model.points) {
584 float avgIndex = constrain(2 + p.fx / model.xMax * (eq.numBands-4), 0, eq.numBands-4);
585 int avgFloor = (int) avgIndex;
587 float leftVal = eq.getLevel(avgFloor);
588 float rightVal = eq.getLevel(avgFloor+1);
589 float smoothValue = lerp(leftVal, rightVal, avgIndex-avgFloor);
591 float chunkyValue = (
592 eq.getLevel(avgFloor/4*4) +
593 eq.getLevel(avgFloor/4*4 + 1) +
594 eq.getLevel(avgFloor/4*4 + 2) +
595 eq.getLevel(avgFloor/4*4 + 3)
598 float value = lerp(smoothValue, chunkyValue, blockiness.getValuef());
600 float b = constrain(edgeConst * (value*model.yMax - p.fy), 0, 100);
601 colors[p.index] = color(
602 (480 + lx.getBaseHuef() - min(clrConst*p.fy, 120)) % 360,
610 class BoomEffect extends SCEffect {
612 final BasicParameter falloff = new BasicParameter("WIDTH", 0.5);
613 final BasicParameter speed = new BasicParameter("SPD", 0.5);
614 final BasicParameter bright = new BasicParameter("BRT", 1.0);
615 final BasicParameter sat = new BasicParameter("SAT", 0.2);
616 List<Layer> layers = new ArrayList<Layer>();
617 final float maxr = sqrt(model.xMax*model.xMax + model.yMax*model.yMax + model.zMax*model.zMax) + 10;
620 LinearEnvelope boom = new LinearEnvelope(-40, 500, 1300);
628 float falloffv = falloffv();
629 boom.setRange(-100 / falloffv, maxr + 100/falloffv, 4000 - speed.getValuef() * 3300);
633 void doApply(int[] colors) {
634 float brightv = 100 * bright.getValuef();
635 float falloffv = falloffv();
636 float satv = sat.getValuef() * 100;
637 float huev = lx.getBaseHuef();
638 for (Point p : model.points) {
639 colors[p.index] = blendColor(
641 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)),
647 BoomEffect(GLucose glucose) {
648 super(glucose, true);
649 addParameter(falloff);
651 addParameter(bright);
655 public void onEnable() {
656 for (Layer l : layers) {
657 if (!l.boom.isRunning()) {
662 layers.add(new Layer());
665 private float falloffv() {
666 return 20 - 19 * falloff.getValuef();
669 public void onTrigger() {
673 public void doApply(int[] colors) {
674 for (Layer l : layers) {
675 if (l.boom.isRunning()) {
682 public class PianoKeyPattern extends SCPattern {
684 final LinearEnvelope[] cubeBrt;
686 final BasicParameter attack = new BasicParameter("ATK", 0.1);
687 final BasicParameter release = new BasicParameter("REL", 0.5);
688 final BasicParameter level = new BasicParameter("AMB", 0.6);
690 PianoKeyPattern(GLucose glucose) {
693 addParameter(attack);
694 addParameter(release);
696 cubeBrt = new LinearEnvelope[model.cubes.size() / 4];
697 for (int i = 0; i < cubeBrt.length; ++i) {
698 addModulator(cubeBrt[i] = new LinearEnvelope(0, 0, 100));
700 base = new SinLFO[model.cubes.size() / 12];
701 for (int i = 0; i < base.length; ++i) {
702 addModulator(base[i] = new SinLFO(0, 1, 7000 + 1000*i)).trigger();
706 private float getAttackTime() {
707 return 15 + attack.getValuef()*attack.getValuef() * 2000;
710 private float getReleaseTime() {
711 return 15 + release.getValuef() * 3000;
714 private LinearEnvelope getEnvelope(int index) {
715 return cubeBrt[index % cubeBrt.length];
718 private SinLFO getBase(int index) {
719 return base[index % base.length];
722 public boolean noteOnReceived(Note note) {
723 LinearEnvelope env = getEnvelope(note.getPitch());
724 env.setEndVal(min(1, env.getValuef() + (note.getVelocity() / 127.)), getAttackTime()).start();
728 public boolean noteOffReceived(Note note) {
729 getEnvelope(note.getPitch()).setEndVal(0, getReleaseTime()).start();
733 public void run(double deltaMs) {
735 float huef = lx.getBaseHuef();
736 float levelf = level.getValuef();
737 for (Cube c : model.cubes) {
738 float v = max(getBase(i).getValuef() * levelf/4., getEnvelope(i++).getValuef());
740 (huef + 20*v + abs(c.cx-model.xMax/2.)*.3 + c.cy) % 360,
748 class CrossSections extends SCPattern {
750 final SinLFO x = new SinLFO(0, model.xMax, 5000);
751 final SinLFO y = new SinLFO(0, model.yMax, 6000);
752 final SinLFO z = new SinLFO(0, model.zMax, 7000);
754 final BasicParameter xw = new BasicParameter("XWID", 0.3);
755 final BasicParameter yw = new BasicParameter("YWID", 0.3);
756 final BasicParameter zw = new BasicParameter("ZWID", 0.3);
757 final BasicParameter xr = new BasicParameter("XRAT", 0.7);
758 final BasicParameter yr = new BasicParameter("YRAT", 0.6);
759 final BasicParameter zr = new BasicParameter("ZRAT", 0.5);
760 final BasicParameter xl = new BasicParameter("XLEV", 1);
761 final BasicParameter yl = new BasicParameter("YLEV", 1);
762 final BasicParameter zl = new BasicParameter("ZLEV", 0.5);
765 CrossSections(GLucose glucose) {
767 addModulator(x).trigger();
768 addModulator(y).trigger();
769 addModulator(z).trigger();
773 protected void addParams() {
785 void onParameterChanged(LXParameter p) {
787 x.setDuration(10000 - 8800*p.getValuef());
788 } else if (p == yr) {
789 y.setDuration(10000 - 9000*p.getValuef());
790 } else if (p == zr) {
791 z.setDuration(10000 - 9000*p.getValuef());
797 protected void updateXYZVals() {
803 public void run(double deltaMs) {
806 float xlv = 100*xl.getValuef();
807 float ylv = 100*yl.getValuef();
808 float zlv = 100*zl.getValuef();
810 float xwv = 100. / (10 + 40*xw.getValuef());
811 float ywv = 100. / (10 + 40*yw.getValuef());
812 float zwv = 100. / (10 + 40*zw.getValuef());
814 for (Point p : model.points) {
816 c = blendColor(c, color(
817 (lx.getBaseHuef() + p.fx/10 + p.fy/3) % 360,
818 constrain(140 - 1.1*abs(p.fx - model.xMax/2.), 0, 100),
819 max(0, xlv - xwv*abs(p.fx - xv))
821 c = blendColor(c, color(
822 (lx.getBaseHuef() + 80 + p.fy/10) % 360,
823 constrain(140 - 2.2*abs(p.fy - model.yMax/2.), 0, 100),
824 max(0, ylv - ywv*abs(p.fy - yv))
826 c = blendColor(c, color(
827 (lx.getBaseHuef() + 160 + p.fz / 10 + p.fy/2) % 360,
828 constrain(140 - 2.2*abs(p.fz - model.zMax/2.), 0, 100),
829 max(0, zlv - zwv*abs(p.fz - zv))
836 class Blinders extends SCPattern {
841 final TriangleLFO hs;
843 public Blinders(GLucose glucose) {
846 for (int i = 0; i < m.length; ++i) {
847 addModulator(m[i] = new SinLFO(0.5, 120, (120000. / (3+i)))).trigger();
849 addModulator(r = new TriangleLFO(9000, 15000, 29000)).trigger();
850 addModulator(s = new SinLFO(-20, 275, 11000)).trigger();
851 addModulator(hs = new TriangleLFO(0.1, 0.5, 15000)).trigger();
852 s.modulateDurationBy(r);
855 public void run(double deltaMs) {
856 float hv = lx.getBaseHuef();
858 for (Strip strip : model.strips) {
860 float mv = m[si % m.length].getValuef();
861 for (Point p : strip.points) {
862 colors[p.index] = color(
863 (hv + p.fz + p.fy*hs.getValuef()) % 360,
864 min(100, abs(p.fx - s.getValuef())/2.),
865 max(0, 100 - mv/2. - mv * abs(i - (strip.metrics.length-1)/2.))
874 class Psychedelia extends SCPattern {
877 SinLFO m = new SinLFO(-0.5, NUM-0.5, 9000);
878 SinLFO s = new SinLFO(-20, 147, 11000);
879 TriangleLFO h = new TriangleLFO(0, 240, 19000);
880 SinLFO c = new SinLFO(-.2, .8, 31000);
882 Psychedelia(GLucose glucose) {
884 addModulator(m).trigger();
885 addModulator(s).trigger();
886 addModulator(h).trigger();
887 addModulator(c).trigger();
890 void run(double deltaMs) {
891 float huev = h.getValuef();
892 float cv = c.getValuef();
893 float sv = s.getValuef();
894 float mv = m.getValuef();
896 for (Strip strip : model.strips) {
897 for (Point p : strip.points) {
898 colors[p.index] = color(
899 (huev + i*constrain(cv, 0, 2) + p.fz/2. + p.fx/4.) % 360,
900 min(100, abs(p.fy-sv)),
901 max(0, 100 - 50*abs((i%NUM) - mv))
909 class AskewPlanes extends SCPattern {
912 private final SinLFO a;
913 private final SinLFO b;
914 private final SinLFO c;
921 addModulator(a = new SinLFO(-1, 1, 4000 + 1029*i)).trigger();
922 addModulator(b = new SinLFO(-1, 1, 11000 - 1104*i)).trigger();
923 addModulator(c = new SinLFO(-50, 50, 4000 + 1000*i * ((i % 2 == 0) ? 1 : -1))).trigger();
926 void run(double deltaMs) {
930 denom = sqrt(av*av + bv*bv);
934 final Plane[] planes;
935 final int NUM_PLANES = 3;
937 AskewPlanes(GLucose glucose) {
939 planes = new Plane[NUM_PLANES];
940 for (int i = 0; i < planes.length; ++i) {
941 planes[i] = new Plane(i);
945 public void run(double deltaMs) {
946 float huev = lx.getBaseHuef();
948 // This is super fucking bizarre. But if this is a for loop, the framerate
949 // tanks to like 30FPS, instead of 60. Call them manually and it works fine.
950 // Doesn't make ANY sense... there must be some weird side effect going on
951 // with the Processing internals perhaps?
952 // for (Plane plane : planes) {
953 // plane.run(deltaMs);
955 planes[0].run(deltaMs);
956 planes[1].run(deltaMs);
957 planes[2].run(deltaMs);
959 for (Point p : model.points) {
961 for (Plane plane : planes) {
962 if (plane.denom != 0) {
963 d = min(d, abs(plane.av*(p.fx-model.cx) + plane.bv*(p.fy-model.cy) + plane.cv) / plane.denom);
966 colors[p.index] = color(
967 (huev + abs(p.fx-model.cx)*.3 + p.fy*.8) % 360,
968 max(0, 100 - .8*abs(p.fx - model.cx)),
969 constrain(140 - 10.*d, 0, 100)
975 class ShiftingPlane extends SCPattern {
977 final SinLFO a = new SinLFO(-.2, .2, 5300);
978 final SinLFO b = new SinLFO(1, -1, 13300);
979 final SinLFO c = new SinLFO(-1.4, 1.4, 5700);
980 final SinLFO d = new SinLFO(-10, 10, 9500);
982 ShiftingPlane(GLucose glucose) {
984 addModulator(a).trigger();
985 addModulator(b).trigger();
986 addModulator(c).trigger();
987 addModulator(d).trigger();
990 public void run(double deltaMs) {
991 float hv = lx.getBaseHuef();
992 float av = a.getValuef();
993 float bv = b.getValuef();
994 float cv = c.getValuef();
995 float dv = d.getValuef();
996 float denom = sqrt(av*av + bv*bv + cv*cv);
997 for (Point p : model.points) {
998 float d = abs(av*(p.fx-model.cx) + bv*(p.fy-model.cy) + cv*(p.fz-model.cz) + dv) / denom;
999 colors[p.index] = color(
1000 (hv + abs(p.fx-model.cx)*.6 + abs(p.fy-model.cy)*.9 + abs(p.fz - model.cz)) % 360,
1001 constrain(110 - d*6, 0, 100),
1002 constrain(130 - 7*d, 0, 100)
1008 class Traktor extends SCPattern {
1010 final int FRAME_WIDTH = 60;
1012 final BasicParameter speed = new BasicParameter("SPD", 0.5);
1014 private float[] bass = new float[FRAME_WIDTH];
1015 private float[] treble = new float[FRAME_WIDTH];
1017 private int index = 0;
1018 private GraphicEQ eq = null;
1020 public Traktor(GLucose glucose) {
1022 for (int i = 0; i < FRAME_WIDTH; ++i) {
1026 addParameter(speed);
1029 public void onActive() {
1031 eq = new GraphicEQ(lx, 16);
1032 eq.slope.setValue(0.6);
1033 eq.level.setValue(0.65);
1034 eq.range.setValue(0.35);
1035 eq.release.setValue(0.4);
1036 addParameter(eq.level);
1037 addParameter(eq.range);
1038 addParameter(eq.attack);
1039 addParameter(eq.release);
1040 addParameter(eq.slope);
1046 public void run(double deltaMs) {
1049 int stepThresh = (int) (40 - 39*speed.getValuef());
1051 if (counter < stepThresh) {
1054 counter = counter % stepThresh;
1056 index = (index + 1) % FRAME_WIDTH;
1058 float rawBass = eq.getAverageLevel(0, 4);
1059 float rawTreble = eq.getAverageLevel(eq.numBands-7, 7);
1061 bass[index] = rawBass * rawBass * rawBass * rawBass;
1062 treble[index] = rawTreble * rawTreble;
1064 for (Point p : model.points) {
1065 int i = (int) constrain((model.xMax - p.x) / model.xMax * FRAME_WIDTH, 0, FRAME_WIDTH-1);
1066 int pos = (index + FRAME_WIDTH - i) % FRAME_WIDTH;
1068 colors[p.index] = color(
1069 (360 + lx.getBaseHuef() + .8*abs(p.x-model.cx)) % 360,
1071 constrain(9 * (bass[pos]*model.cy - abs(p.fy - model.cy)), 0, 100)
1073 colors[p.index] = blendColor(colors[p.index], color(
1074 (400 + lx.getBaseHuef() + .5*abs(p.x-model.cx)) % 360,
1076 constrain(5 * (treble[pos]*.6*model.cy - abs(p.fy - model.cy)), 0, 100)
1083 class ColorFuckerEffect extends SCEffect {
1085 BasicParameter hueShift = new BasicParameter("HSHFT", 0);
1086 BasicParameter sat = new BasicParameter("SAT", 1);
1087 BasicParameter bright = new BasicParameter("BRT", 1);
1089 ColorFuckerEffect(GLucose glucose) {
1091 addParameter(hueShift);
1092 addParameter(bright);
1096 public void doApply(int[] colors) {
1100 float bMod = bright.getValuef();
1101 float sMod = sat.getValuef();
1102 float hMod = hueShift.getValuef();
1103 if (bMod < 1 || sMod < 1 || hMod > 0) {
1104 for (int i = 0; i < colors.length; ++i) {
1106 (hue(colors[i]) + hueShift.getValuef()*360.) % 360,
1107 saturation(colors[i]) * sat.getValuef(),
1108 brightness(colors[i]) * bright.getValuef()
1115 class BlurEffect extends SCEffect {
1117 final LXParameter amount = new BasicParameter("AMT", 0);
1119 final LinearEnvelope env = new LinearEnvelope(0, 1, 100);
1121 BlurEffect(GLucose glucose) {
1123 addParameter(amount);
1125 frame = new int[lx.total];
1126 for (int i = 0; i < frame.length; ++i) {
1131 public void onEnable() {
1132 env.setRangeFromHereTo(1, 400).start();
1133 for (int i = 0; i < frame.length; ++i) {
1138 public void onDisable() {
1139 env.setRangeFromHereTo(0, 1000).start();
1142 public void doApply(int[] colors) {
1143 float amt = env.getValuef() * amount.getValuef();
1146 amt = 1 - (amt*amt*amt);
1147 for (int i = 0; i < colors.length; ++i) {
1148 // frame[i] = colors[i] = blendColor(colors[i], lerpColor(#000000, frame[i], amt, RGB), SCREEN);
1149 frame[i] = colors[i] = lerpColor(colors[i], blendColor(colors[i], frame[i], SCREEN), amt, RGB);