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 beatAmount = new BasicParameter("BEAT", 0.1);
12 Pulley(GLucose glucose) {
14 for (int i = 0; i < NUM_DIVISIONS; ++i) {
15 addModulator(gravity[i] = new Accelerator(0, 0, 0));
16 addModulator(delays[i] = new Click(0));
18 addModulator(reset).start();
19 addParameter(beatAmount);
23 private void trigger() {
26 for (Accelerator g : gravity) {
28 g.setSpeed(random(40, 50), 0).start();
30 g.setVelocity(0).setAcceleration(-420);
31 delays[i].setDuration(random(0, 500)).trigger();
37 public void run(double deltaMs) {
42 for (Click d : delays) {
50 for (Accelerator g : gravity) {
52 if (g.getValuef() > model.yMax) {
54 } else if (g.getValuef() > model.yMax*.55) {
55 if (g.getVelocityf() > 10) {
56 g.setAcceleration(-16);
62 if (g.getValuef() < 0) {
63 g.setValue(-g.getValuef());
64 g.setVelocity(-g.getVelocityf() * random(0.74, 0.84));
69 float fPos = 1 - lx.tempo.rampf();
71 fPos = .2 + 4 * (.2 - fPos);
73 float falloff = 100. / (12 + fPos * beatAmount.getValuef()*48);
74 for (Point p : model.points) {
75 int i = (int) constrain((p.x - model.xMin) * NUM_DIVISIONS / (model.xMax - model.xMin), 0, NUM_DIVISIONS-1);
76 colors[p.index] = color(
77 (lx.getBaseHuef() + abs(p.x - model.cx)*.8 + p.y*.4) % 360,
78 constrain(130 - p.y*.8, 0, 100),
79 max(0, 100 - abs(p.y - gravity[i].getValuef())*falloff)
85 class ViolinWave extends SCPattern {
87 BasicParameter level = new BasicParameter("LVL", 0.45);
88 BasicParameter range = new BasicParameter("RNG", 0.5);
89 BasicParameter edge = new BasicParameter("EDG", 0.5);
90 BasicParameter release = new BasicParameter("RLS", 0.5);
91 BasicParameter speed = new BasicParameter("SPD", 0.5);
92 BasicParameter amp = new BasicParameter("AMP", 0.25);
93 BasicParameter period = new BasicParameter("WAVE", 0.5);
94 BasicParameter pSize = new BasicParameter("PSIZE", 0.5);
95 BasicParameter pSpeed = new BasicParameter("PSPD", 0.5);
96 BasicParameter pDensity = new BasicParameter("PDENS", 0.25);
98 LinearEnvelope dbValue = new LinearEnvelope(0, 0, 10);
100 ViolinWave(GLucose glucose) {
105 addParameter(release);
108 addParameter(period);
110 addParameter(pSpeed);
111 addParameter(pDensity);
113 addModulator(dbValue);
116 final List<Particle> particles = new ArrayList<Particle>();
120 LinearEnvelope x = new LinearEnvelope(0, 0, 0);
121 LinearEnvelope y = new LinearEnvelope(0, 0, 0);
128 Particle trigger(boolean direction) {
129 float xInit = random(model.xMin, model.xMax);
130 float time = 3000 - 2500*pSpeed.getValuef();
131 x.setRange(xInit, xInit + random(-40, 40), time).trigger();
132 y.setRange(model.cy + 10, direction ? model.yMax + 50 : model.yMin - 50, time).trigger();
137 return x.isRunning() || y.isRunning();
140 public void run(double deltaMs) {
145 float pFalloff = (30 - 27*pSize.getValuef());
146 for (Point p : model.points) {
147 float b = 100 - pFalloff * (abs(p.x - x.getValuef()) + abs(p.y - y.getValuef()));
149 colors[p.index] = blendColor(colors[p.index], color(
150 lx.getBaseHuef(), 20, b
157 float[] centers = new float[30];
159 boolean rising = true;
161 void fireParticle(boolean direction) {
162 boolean gotOne = false;
163 for (Particle p : particles) {
165 p.trigger(direction);
169 particles.add(new Particle().trigger(direction));
172 public void run(double deltaMs) {
173 accum += deltaMs / (1000. - 900.*speed.getValuef());
174 for (int i = 0; i < centers.length; ++i) {
175 centers[i] = model.cy + 30*amp.getValuef()*sin((float) (accum + (i-centers.length/2.)/(1. + 9.*period.getValuef())));
178 float zeroDBReference = pow(10, (50 - 190*level.getValuef())/20.);
179 float dB = 20*GraphicEQ.log10(lx.audioInput().mix.level() / zeroDBReference);
180 if (dB > dbValue.getValuef()) {
182 dbValue.setRangeFromHereTo(dB, 10).trigger();
185 for (int j = 0; j < pDensity.getValuef()*3; ++j) {
191 dbValue.setRangeFromHereTo(max(dB, -96), 50 + 1000*release.getValuef()).trigger();
193 float edg = 1 + edge.getValuef() * 40;
194 float rng = (78 - 64 * range.getValuef()) / (model.yMax - model.cy);
195 float val = max(2, dbValue.getValuef());
197 for (Point p : model.points) {
198 int ci = (int) lerp(0, centers.length-1, (p.x - model.xMin) / (model.xMax - model.xMin));
199 float rFactor = 1.0 - 0.9 * abs(p.x - model.cx) / (model.xMax - model.cx);
200 colors[p.index] = color(
201 (lx.getBaseHuef() + abs(p.x - model.cx)) % 360,
202 min(100, 20 + 8*abs(p.y - centers[ci])),
203 constrain(edg*(val*rFactor - rng * abs(p.y-centers[ci])), 0, 100)
207 for (Particle p : particles) {
213 class BouncyBalls extends SCPattern {
215 static final int NUM_BALLS = 6;
220 TriangleLFO xPos = new TriangleLFO(0, model.xMax, random(8000, 19000));
224 addModulator(xPos).setBasis(random(0, TWO_PI)).start();
225 addModulator(yPos = new Accelerator(0, 0, 0));
226 zPos = lerp(model.zMin, model.zMax, (i+2.) / (NUM_BALLS + 4.));
229 void bounce(float midiVel) {
230 float v = 100 + 8*midiVel;
231 yPos.setSpeed(v, getAccel(v, 60 / lx.tempo.bpmf())).start();
234 float getAccel(float v, float oneBeat) {
235 return -2*v / oneBeat;
238 void run(double deltaMs) {
239 float flrLevel = flr.getValuef() * model.xMax/2.;
240 if (yPos.getValuef() < flrLevel) {
241 if (yPos.getVelocity() < -50) {
242 yPos.setValue(2*flrLevel-yPos.getValuef());
243 float v = -yPos.getVelocityf() * bounce.getValuef();
244 yPos.setSpeed(v, getAccel(v, 60 / lx.tempo.bpmf()));
246 yPos.setValue(flrLevel).stop();
249 float falloff = 130.f / (12 + blobSize.getValuef() * 36);
250 float xv = xPos.getValuef();
251 float yv = yPos.getValuef();
253 for (Point p : model.points) {
254 float d = sqrt((p.x-xv)*(p.x-xv) + (p.y-yv)*(p.y-yv) + .1*(p.z-zPos)*(p.z-zPos));
255 float b = constrain(130 - falloff*d, 0, 100);
257 colors[p.index] = blendColor(colors[p.index], color(
258 (lx.getBaseHuef() + p.y*.5 + abs(model.cx - p.x) * .5) % 360,
259 max(0, 100 - .45*(p.y - flrLevel)),
267 final BouncyBall[] balls = new BouncyBall[NUM_BALLS];
269 final BasicParameter bounce = new BasicParameter("BNC", .8);
270 final BasicParameter flr = new BasicParameter("FLR", 0);
271 final BasicParameter blobSize = new BasicParameter("SIZE", 0.5);
273 BouncyBalls(GLucose glucose) {
275 for (int i = 0; i < balls.length; ++i) {
276 balls[i] = new BouncyBall(i);
278 addParameter(bounce);
280 addParameter(blobSize);
283 public void run(double deltaMs) {
285 for (BouncyBall b : balls) {
290 public boolean noteOnReceived(Note note) {
291 int pitch = (note.getPitch() + note.getChannel()) % NUM_BALLS;
292 balls[pitch].bounce(note.getVelocity());
297 class SpaceTime extends SCPattern {
299 SinLFO pos = new SinLFO(0, 1, 3000);
300 SinLFO rate = new SinLFO(1000, 9000, 13000);
301 SinLFO falloff = new SinLFO(10, 70, 5000);
304 BasicParameter rateParameter = new BasicParameter("RATE", 0.5);
305 BasicParameter sizeParameter = new BasicParameter("SIZE", 0.5);
308 public SpaceTime(GLucose glucose) {
311 addModulator(pos).trigger();
312 addModulator(rate).trigger();
313 addModulator(falloff).trigger();
314 pos.modulateDurationBy(rate);
315 addParameter(rateParameter);
316 addParameter(sizeParameter);
319 public void onParameterChanged(LXParameter parameter) {
320 if (parameter == rateParameter) {
321 rate.stop().setValue(9000 - 8000*parameter.getValuef());
322 } else if (parameter == sizeParameter) {
323 falloff.stop().setValue(70 - 60*parameter.getValuef());
327 void run(double deltaMs) {
328 angle += deltaMs * 0.0007;
329 float sVal1 = model.strips.size() * (0.5 + 0.5*sin(angle));
330 float sVal2 = model.strips.size() * (0.5 + 0.5*cos(angle));
332 float pVal = pos.getValuef();
333 float fVal = falloff.getValuef();
336 for (Strip strip : model.strips) {
338 for (Point p : strip.points) {
339 colors[p.index] = color(
340 (lx.getBaseHuef() + 360 - p.fx*.2 + p.fy * .3) % 360,
341 constrain(.4 * min(abs(s - sVal1), abs(s - sVal2)), 20, 100),
342 max(0, 100 - fVal*abs(i - pVal*(strip.metrics.numPoints - 1)))
351 class Swarm extends SCPattern {
353 SawLFO offset = new SawLFO(0, 1, 1000);
354 SinLFO rate = new SinLFO(350, 1200, 63000);
355 SinLFO falloff = new SinLFO(15, 50, 17000);
356 SinLFO fX = new SinLFO(0, model.xMax, 19000);
357 SinLFO fY = new SinLFO(0, model.yMax, 11000);
358 SinLFO hOffX = new SinLFO(0, model.xMax, 13000);
360 public Swarm(GLucose glucose) {
363 addModulator(offset).trigger();
364 addModulator(rate).trigger();
365 addModulator(falloff).trigger();
366 addModulator(fX).trigger();
367 addModulator(fY).trigger();
368 addModulator(hOffX).trigger();
369 offset.modulateDurationBy(rate);
372 float modDist(float v1, float v2, float mod) {
376 return min(v2-v1, v1+mod-v2);
379 return min(v1-v2, v2+mod-v1);
383 void run(double deltaMs) {
385 for (Strip strip : model.strips ) {
387 for (Point p : strip.points) {
388 float fV = max(-1, 1 - dist(p.fx/2., p.fy, fX.getValuef()/2., fY.getValuef()) / 64.);
389 colors[p.index] = color(
390 (lx.getBaseHuef() + 0.3 * abs(p.fx - hOffX.getValuef())) % 360,
391 constrain(80 + 40 * fV, 0, 100),
392 constrain(100 - (30 - fV * falloff.getValuef()) * modDist(i + (s*63)%61, offset.getValuef() * strip.metrics.numPoints, strip.metrics.numPoints), 0, 100)
401 class SwipeTransition extends SCTransition {
403 final BasicParameter bleed = new BasicParameter("WIDTH", 0.5);
405 SwipeTransition(GLucose glucose) {
411 void computeBlend(int[] c1, int[] c2, double progress) {
412 float bleedf = 10 + bleed.getValuef() * 200.;
413 float xPos = (float) (-bleedf + progress * (model.xMax + bleedf));
414 for (Point p : model.points) {
415 float d = (p.fx - xPos) / bleedf;
417 colors[p.index] = c2[p.index];
419 colors[p.index] = c1[p.index];
421 colors[p.index] = lerpColor(c2[p.index], c1[p.index], d, RGB);
427 abstract class BlendTransition extends SCTransition {
431 BlendTransition(GLucose glucose, int blendType) {
433 this.blendType = blendType;
436 void computeBlend(int[] c1, int[] c2, double progress) {
437 if (progress < 0.5) {
438 for (int i = 0; i < c1.length; ++i) {
439 colors[i] = lerpColor(
441 blendColor(c1[i], c2[i], blendType),
442 (float) (2.*progress),
446 for (int i = 0; i < c1.length; ++i) {
447 colors[i] = lerpColor(
449 blendColor(c1[i], c2[i], blendType),
450 (float) (2.*(1. - progress)),
457 class MultiplyTransition extends BlendTransition {
458 MultiplyTransition(GLucose glucose) {
459 super(glucose, MULTIPLY);
463 class ScreenTransition extends BlendTransition {
464 ScreenTransition(GLucose glucose) {
465 super(glucose, SCREEN);
469 class BurnTransition extends BlendTransition {
470 BurnTransition(GLucose glucose) {
471 super(glucose, BURN);
475 class DodgeTransition extends BlendTransition {
476 DodgeTransition(GLucose glucose) {
477 super(glucose, DODGE);
481 class OverlayTransition extends BlendTransition {
482 OverlayTransition(GLucose glucose) {
483 super(glucose, OVERLAY);
487 class AddTransition extends BlendTransition {
488 AddTransition(GLucose glucose) {
493 class SubtractTransition extends BlendTransition {
494 SubtractTransition(GLucose glucose) {
495 super(glucose, SUBTRACT);
499 class SoftLightTransition extends BlendTransition {
500 SoftLightTransition(GLucose glucose) {
501 super(glucose, SOFT_LIGHT);
505 class BassPod extends SCPattern {
507 private GraphicEQ eq = null;
509 public BassPod(GLucose glucose) {
513 protected void onActive() {
515 eq = new GraphicEQ(lx, 16);
516 eq.slope.setValue(0.6);
517 addParameter(eq.level);
518 addParameter(eq.range);
519 addParameter(eq.attack);
520 addParameter(eq.release);
521 addParameter(eq.slope);
525 public void run(double deltaMs) {
528 float bassLevel = eq.getAverageLevel(0, 5);
530 for (Point p : model.points) {
531 int avgIndex = (int) constrain(1 + abs(p.fx-model.xMax/2.)/(model.xMax/2.)*(eq.numBands-5), 0, eq.numBands-5);
533 for (int i = avgIndex; i < avgIndex + 5; ++i) {
534 value += eq.getLevel(i);
538 float b = constrain(8 * (value*model.yMax - abs(p.fy-model.yMax/2.)), 0, 100);
539 colors[p.index] = color(
540 (lx.getBaseHuef() + abs(p.fy - model.cy) + abs(p.fx - model.cx)) % 360,
541 constrain(bassLevel*240 - .6*dist(p.fx, p.fy, model.cx, model.cy), 0, 100),
549 class CubeEQ extends SCPattern {
551 private GraphicEQ eq = null;
553 private final BasicParameter edge = new BasicParameter("EDGE", 0.5);
554 private final BasicParameter clr = new BasicParameter("CLR", 0.5);
555 private final BasicParameter blockiness = new BasicParameter("BLK", 0.5);
557 public CubeEQ(GLucose glucose) {
561 protected void onActive() {
563 eq = new GraphicEQ(lx, 16);
564 addParameter(eq.level);
565 addParameter(eq.range);
566 addParameter(eq.attack);
567 addParameter(eq.release);
568 addParameter(eq.slope);
571 addParameter(blockiness);
575 public void run(double deltaMs) {
578 float edgeConst = 2 + 30*edge.getValuef();
579 float clrConst = 1.1 + clr.getValuef();
581 for (Point p : model.points) {
582 float avgIndex = constrain(2 + p.fx / model.xMax * (eq.numBands-4), 0, eq.numBands-4);
583 int avgFloor = (int) avgIndex;
585 float leftVal = eq.getLevel(avgFloor);
586 float rightVal = eq.getLevel(avgFloor+1);
587 float smoothValue = lerp(leftVal, rightVal, avgIndex-avgFloor);
589 float chunkyValue = (
590 eq.getLevel(avgFloor/4*4) +
591 eq.getLevel(avgFloor/4*4 + 1) +
592 eq.getLevel(avgFloor/4*4 + 2) +
593 eq.getLevel(avgFloor/4*4 + 3)
596 float value = lerp(smoothValue, chunkyValue, blockiness.getValuef());
598 float b = constrain(edgeConst * (value*model.yMax - p.fy), 0, 100);
599 colors[p.index] = color(
600 (480 + lx.getBaseHuef() - min(clrConst*p.fy, 120)) % 360,
608 class BoomEffect extends SCEffect {
610 final BasicParameter falloff = new BasicParameter("WIDTH", 0.5);
611 final BasicParameter speed = new BasicParameter("SPD", 0.5);
612 final BasicParameter bright = new BasicParameter("BRT", 1.0);
613 final BasicParameter sat = new BasicParameter("SAT", 0.2);
614 List<Layer> layers = new ArrayList<Layer>();
615 final float maxr = sqrt(model.xMax*model.xMax + model.yMax*model.yMax + model.zMax*model.zMax) + 10;
618 LinearEnvelope boom = new LinearEnvelope(-40, 500, 1300);
626 float falloffv = falloffv();
627 boom.setRange(-100 / falloffv, maxr + 100/falloffv, 4000 - speed.getValuef() * 3300);
631 void doApply(int[] colors) {
632 float brightv = 100 * bright.getValuef();
633 float falloffv = falloffv();
634 float satv = sat.getValuef() * 100;
635 float huev = lx.getBaseHuef();
636 for (Point p : model.points) {
637 colors[p.index] = blendColor(
639 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)),
645 BoomEffect(GLucose glucose) {
646 super(glucose, true);
647 addParameter(falloff);
649 addParameter(bright);
653 public void onEnable() {
654 for (Layer l : layers) {
655 if (!l.boom.isRunning()) {
660 layers.add(new Layer());
663 private float falloffv() {
664 return 20 - 19 * falloff.getValuef();
667 public void onTrigger() {
671 public void doApply(int[] colors) {
672 for (Layer l : layers) {
673 if (l.boom.isRunning()) {
680 public class PianoKeyPattern extends SCPattern {
682 final LinearEnvelope[] cubeBrt;
684 final BasicParameter attack = new BasicParameter("ATK", 0.1);
685 final BasicParameter release = new BasicParameter("REL", 0.5);
686 final BasicParameter level = new BasicParameter("AMB", 0.6);
688 PianoKeyPattern(GLucose glucose) {
691 addParameter(attack);
692 addParameter(release);
694 cubeBrt = new LinearEnvelope[model.cubes.size() / 4];
695 for (int i = 0; i < cubeBrt.length; ++i) {
696 addModulator(cubeBrt[i] = new LinearEnvelope(0, 0, 100));
698 base = new SinLFO[model.cubes.size() / 12];
699 for (int i = 0; i < base.length; ++i) {
700 addModulator(base[i] = new SinLFO(0, 1, 7000 + 1000*i)).trigger();
704 private float getAttackTime() {
705 return 15 + attack.getValuef()*attack.getValuef() * 2000;
708 private float getReleaseTime() {
709 return 15 + release.getValuef() * 3000;
712 private LinearEnvelope getEnvelope(int index) {
713 return cubeBrt[index % cubeBrt.length];
716 private SinLFO getBase(int index) {
717 return base[index % base.length];
720 public boolean noteOnReceived(Note note) {
721 LinearEnvelope env = getEnvelope(note.getPitch());
722 env.setEndVal(min(1, env.getValuef() + (note.getVelocity() / 127.)), getAttackTime()).start();
726 public boolean noteOffReceived(Note note) {
727 getEnvelope(note.getPitch()).setEndVal(0, getReleaseTime()).start();
731 public void run(double deltaMs) {
733 float huef = lx.getBaseHuef();
734 float levelf = level.getValuef();
735 for (Cube c : model.cubes) {
736 float v = max(getBase(i).getValuef() * levelf/4., getEnvelope(i++).getValuef());
738 (huef + 20*v + abs(c.cx-model.xMax/2.)*.3 + c.cy) % 360,
746 class CrossSections extends SCPattern {
748 final SinLFO x = new SinLFO(0, model.xMax, 5000);
749 final SinLFO y = new SinLFO(0, model.yMax, 6000);
750 final SinLFO z = new SinLFO(0, model.zMax, 7000);
752 final BasicParameter xw = new BasicParameter("XWID", 0.3);
753 final BasicParameter yw = new BasicParameter("YWID", 0.3);
754 final BasicParameter zw = new BasicParameter("ZWID", 0.3);
755 final BasicParameter xr = new BasicParameter("XRAT", 0.7);
756 final BasicParameter yr = new BasicParameter("YRAT", 0.6);
757 final BasicParameter zr = new BasicParameter("ZRAT", 0.5);
758 final BasicParameter xl = new BasicParameter("XLEV", 1);
759 final BasicParameter yl = new BasicParameter("YLEV", 1);
760 final BasicParameter zl = new BasicParameter("ZLEV", 0.5);
763 CrossSections(GLucose glucose) {
765 addModulator(x).trigger();
766 addModulator(y).trigger();
767 addModulator(z).trigger();
771 protected void addParams() {
783 void onParameterChanged(LXParameter p) {
785 x.setDuration(10000 - 8800*p.getValuef());
786 } else if (p == yr) {
787 y.setDuration(10000 - 9000*p.getValuef());
788 } else if (p == zr) {
789 z.setDuration(10000 - 9000*p.getValuef());
795 protected void updateXYZVals() {
801 public void run(double deltaMs) {
804 float xlv = 100*xl.getValuef();
805 float ylv = 100*yl.getValuef();
806 float zlv = 100*zl.getValuef();
808 float xwv = 100. / (10 + 40*xw.getValuef());
809 float ywv = 100. / (10 + 40*yw.getValuef());
810 float zwv = 100. / (10 + 40*zw.getValuef());
812 for (Point p : model.points) {
814 c = blendColor(c, color(
815 (lx.getBaseHuef() + p.fx/10 + p.fy/3) % 360,
816 constrain(140 - 1.1*abs(p.fx - model.xMax/2.), 0, 100),
817 max(0, xlv - xwv*abs(p.fx - xv))
819 c = blendColor(c, color(
820 (lx.getBaseHuef() + 80 + p.fy/10) % 360,
821 constrain(140 - 2.2*abs(p.fy - model.yMax/2.), 0, 100),
822 max(0, ylv - ywv*abs(p.fy - yv))
824 c = blendColor(c, color(
825 (lx.getBaseHuef() + 160 + p.fz / 10 + p.fy/2) % 360,
826 constrain(140 - 2.2*abs(p.fz - model.zMax/2.), 0, 100),
827 max(0, zlv - zwv*abs(p.fz - zv))
834 class Blinders extends SCPattern {
839 final TriangleLFO hs;
841 public Blinders(GLucose glucose) {
844 for (int i = 0; i < m.length; ++i) {
845 addModulator(m[i] = new SinLFO(0.5, 120, (120000. / (3+i)))).trigger();
847 addModulator(r = new TriangleLFO(9000, 15000, 29000)).trigger();
848 addModulator(s = new SinLFO(-20, 275, 11000)).trigger();
849 addModulator(hs = new TriangleLFO(0.1, 0.5, 15000)).trigger();
850 s.modulateDurationBy(r);
853 public void run(double deltaMs) {
854 float hv = lx.getBaseHuef();
856 for (Strip strip : model.strips) {
858 float mv = m[si % m.length].getValuef();
859 for (Point p : strip.points) {
860 colors[p.index] = color(
861 (hv + p.fz + p.fy*hs.getValuef()) % 360,
862 min(100, abs(p.fx - s.getValuef())/2.),
863 max(0, 100 - mv/2. - mv * abs(i - (strip.metrics.length-1)/2.))
872 class Psychedelia extends SCPattern {
875 SinLFO m = new SinLFO(-0.5, NUM-0.5, 9000);
876 SinLFO s = new SinLFO(-20, 147, 11000);
877 TriangleLFO h = new TriangleLFO(0, 240, 19000);
878 SinLFO c = new SinLFO(-.2, .8, 31000);
880 Psychedelia(GLucose glucose) {
882 addModulator(m).trigger();
883 addModulator(s).trigger();
884 addModulator(h).trigger();
885 addModulator(c).trigger();
888 void run(double deltaMs) {
889 float huev = h.getValuef();
890 float cv = c.getValuef();
891 float sv = s.getValuef();
892 float mv = m.getValuef();
894 for (Strip strip : model.strips) {
895 for (Point p : strip.points) {
896 colors[p.index] = color(
897 (huev + i*constrain(cv, 0, 2) + p.fz/2. + p.fx/4.) % 360,
898 min(100, abs(p.fy-sv)),
899 max(0, 100 - 50*abs((i%NUM) - mv))
907 class AskewPlanes extends SCPattern {
910 private final SinLFO a;
911 private final SinLFO b;
912 private final SinLFO c;
919 addModulator(a = new SinLFO(-1, 1, 4000 + 1029*i)).trigger();
920 addModulator(b = new SinLFO(-1, 1, 11000 - 1104*i)).trigger();
921 addModulator(c = new SinLFO(-50, 50, 4000 + 1000*i * ((i % 2 == 0) ? 1 : -1))).trigger();
924 void run(double deltaMs) {
928 denom = sqrt(av*av + bv*bv);
932 final Plane[] planes;
933 final int NUM_PLANES = 3;
935 AskewPlanes(GLucose glucose) {
937 planes = new Plane[NUM_PLANES];
938 for (int i = 0; i < planes.length; ++i) {
939 planes[i] = new Plane(i);
943 public void run(double deltaMs) {
944 float huev = lx.getBaseHuef();
946 // This is super fucking bizarre. But if this is a for loop, the framerate
947 // tanks to like 30FPS, instead of 60. Call them manually and it works fine.
948 // Doesn't make ANY sense... there must be some weird side effect going on
949 // with the Processing internals perhaps?
950 // for (Plane plane : planes) {
951 // plane.run(deltaMs);
953 planes[0].run(deltaMs);
954 planes[1].run(deltaMs);
955 planes[2].run(deltaMs);
957 for (Point p : model.points) {
959 for (Plane plane : planes) {
960 if (plane.denom != 0) {
961 d = min(d, abs(plane.av*(p.fx-model.cx) + plane.bv*(p.fy-model.cy) + plane.cv) / plane.denom);
964 colors[p.index] = color(
965 (huev + abs(p.fx-model.cx)*.3 + p.fy*.8) % 360,
966 max(0, 100 - .8*abs(p.fx - model.cx)),
967 constrain(140 - 10.*d, 0, 100)
973 class ShiftingPlane extends SCPattern {
975 final SinLFO a = new SinLFO(-.2, .2, 5300);
976 final SinLFO b = new SinLFO(1, -1, 13300);
977 final SinLFO c = new SinLFO(-1.4, 1.4, 5700);
978 final SinLFO d = new SinLFO(-10, 10, 9500);
980 ShiftingPlane(GLucose glucose) {
982 addModulator(a).trigger();
983 addModulator(b).trigger();
984 addModulator(c).trigger();
985 addModulator(d).trigger();
988 public void run(double deltaMs) {
989 float hv = lx.getBaseHuef();
990 float av = a.getValuef();
991 float bv = b.getValuef();
992 float cv = c.getValuef();
993 float dv = d.getValuef();
994 float denom = sqrt(av*av + bv*bv + cv*cv);
995 for (Point p : model.points) {
996 float d = abs(av*(p.fx-model.cx) + bv*(p.fy-model.cy) + cv*(p.fz-model.cz) + dv) / denom;
997 colors[p.index] = color(
998 (hv + abs(p.fx-model.cx)*.6 + abs(p.fy-model.cy)*.9 + abs(p.fz - model.cz)) % 360,
999 constrain(110 - d*6, 0, 100),
1000 constrain(130 - 7*d, 0, 100)
1006 class Traktor extends SCPattern {
1008 final int FRAME_WIDTH = 60;
1010 final BasicParameter speed = new BasicParameter("SPD", 0.5);
1012 private float[] bass = new float[FRAME_WIDTH];
1013 private float[] treble = new float[FRAME_WIDTH];
1015 private int index = 0;
1016 private GraphicEQ eq = null;
1018 public Traktor(GLucose glucose) {
1020 for (int i = 0; i < FRAME_WIDTH; ++i) {
1024 addParameter(speed);
1027 public void onActive() {
1029 eq = new GraphicEQ(lx, 16);
1030 eq.slope.setValue(0.6);
1031 eq.level.setValue(0.65);
1032 eq.range.setValue(0.35);
1033 eq.release.setValue(0.4);
1034 addParameter(eq.level);
1035 addParameter(eq.range);
1036 addParameter(eq.attack);
1037 addParameter(eq.release);
1038 addParameter(eq.slope);
1044 public void run(double deltaMs) {
1047 int stepThresh = (int) (40 - 39*speed.getValuef());
1049 if (counter < stepThresh) {
1052 counter = counter % stepThresh;
1054 index = (index + 1) % FRAME_WIDTH;
1056 float rawBass = eq.getAverageLevel(0, 4);
1057 float rawTreble = eq.getAverageLevel(eq.numBands-7, 7);
1059 bass[index] = rawBass * rawBass * rawBass * rawBass;
1060 treble[index] = rawTreble * rawTreble;
1062 for (Point p : model.points) {
1063 int i = (int) constrain((model.xMax - p.x) / model.xMax * FRAME_WIDTH, 0, FRAME_WIDTH-1);
1064 int pos = (index + FRAME_WIDTH - i) % FRAME_WIDTH;
1066 colors[p.index] = color(
1067 (360 + lx.getBaseHuef() + .8*abs(p.x-model.cx)) % 360,
1069 constrain(9 * (bass[pos]*model.cy - abs(p.fy - model.cy)), 0, 100)
1071 colors[p.index] = blendColor(colors[p.index], color(
1072 (400 + lx.getBaseHuef() + .5*abs(p.x-model.cx)) % 360,
1074 constrain(5 * (treble[pos]*.6*model.cy - abs(p.fy - model.cy)), 0, 100)
1081 class ColorFuckerEffect extends SCEffect {
1083 BasicParameter hueShift = new BasicParameter("HSHFT", 0);
1084 BasicParameter sat = new BasicParameter("SAT", 1);
1085 BasicParameter bright = new BasicParameter("BRT", 1);
1087 ColorFuckerEffect(GLucose glucose) {
1089 addParameter(hueShift);
1090 addParameter(bright);
1094 public void doApply(int[] colors) {
1098 float bMod = bright.getValuef();
1099 float sMod = sat.getValuef();
1100 float hMod = hueShift.getValuef();
1101 if (bMod < 1 || sMod < 1 || hMod > 0) {
1102 for (int i = 0; i < colors.length; ++i) {
1104 (hue(colors[i]) + hueShift.getValuef()*360.) % 360,
1105 saturation(colors[i]) * sat.getValuef(),
1106 brightness(colors[i]) * bright.getValuef()
1113 class BlurEffect extends SCEffect {
1115 final LXParameter amount = new BasicParameter("AMT", 0);
1117 final LinearEnvelope env = new LinearEnvelope(0, 1, 100);
1119 BlurEffect(GLucose glucose) {
1121 addParameter(amount);
1123 frame = new int[lx.total];
1124 for (int i = 0; i < frame.length; ++i) {
1129 public void onEnable() {
1130 env.setRangeFromHereTo(1, 400).start();
1131 for (int i = 0; i < frame.length; ++i) {
1136 public void onDisable() {
1137 env.setRangeFromHereTo(0, 1000).start();
1140 public void doApply(int[] colors) {
1141 float amt = env.getValuef() * amount.getValuef();
1144 amt = 1 - (amt*amt*amt);
1145 for (int i = 0; i < colors.length; ++i) {
1146 // frame[i] = colors[i] = blendColor(colors[i], lerpColor(#000000, frame[i], amt, RGB), SCREEN);
1147 frame[i] = colors[i] = lerpColor(colors[i], blendColor(colors[i], frame[i], SCREEN), amt, RGB);