Add diagnostics meter to show time things take
[SugarCubes.git] / MarkSlee.pde
index 6cf0da01c5e68ba054c8efdf283b37d9c04cf45a..efcf7d7f6832d36a22ca90e0c4fcf014197a7a1b 100644 (file)
@@ -516,7 +516,7 @@ class BouncyBalls extends SCPattern {
     float zPos;
     
     BouncyBall(int i) {
-      addModulator(xPos).setBasis(random(0, TWO_PI)).start();
+      addModulator(xPos.setBasis(random(0, TWO_PI)).start());
       addModulator(yPos = new Accelerator(0, 0, 0));
       zPos = lerp(model.zMin, model.zMax, (i+2.) / (NUM_BALLS + 4.));
     }
@@ -644,7 +644,7 @@ class SpaceTime extends SCPattern {
 }
 
 class Swarm extends SCPattern {
-
+  
   SawLFO offset = new SawLFO(0, 1, 1000);
   SinLFO rate = new SinLFO(350, 1200, 63000);
   SinLFO falloff = new SinLFO(15, 50, 17000);
@@ -801,13 +801,18 @@ class BassPod extends SCPattern {
 
   private GraphicEQ eq = null;
   
+  private final BasicParameter clr = new BasicParameter("CLR", 0.5);
+  
   public BassPod(GLucose glucose) {
     super(glucose);
+    addParameter(clr);
   }
   
   protected void onActive() {
     if (eq == null) {
       eq = new GraphicEQ(lx, 16);
+      eq.range.setValue(0.4);
+      eq.level.setValue(0.4);
       eq.slope.setValue(0.6);
       addParameter(eq.level);
       addParameter(eq.range);
@@ -822,8 +827,10 @@ class BassPod extends SCPattern {
     
     float bassLevel = eq.getAverageLevel(0, 5);
     
+    float satBase = bassLevel*480*clr.getValuef();
+    
     for (Point p : model.points) {
-      int avgIndex = (int) constrain(1 + abs(p.x-model.xMax/2.)/(model.xMax/2.)*(eq.numBands-5), 0, eq.numBands-5);
+      int avgIndex = (int) constrain(1 + abs(p.x-model.cx)/(model.cx)*(eq.numBands-5), 0, eq.numBands-5);
       float value = 0;
       for (int i = avgIndex; i < avgIndex + 5; ++i) {
         value += eq.getLevel(i);
@@ -833,7 +840,7 @@ class BassPod extends SCPattern {
       float b = constrain(8 * (value*model.yMax - abs(p.y-model.yMax/2.)), 0, 100);
       colors[p.index] = lx.hsb(
         (lx.getBaseHuef() + abs(p.y - model.cy) + abs(p.x - model.cx)) % 360,
-        constrain(bassLevel*240 - .6*dist(p.x, p.y, model.cx, model.cy), 0, 100),
+        constrain(satBase - .6*dist(p.x, p.y, model.cx, model.cy), 0, 100),
         b
       );
     }
@@ -923,7 +930,7 @@ class BoomEffect extends SCEffect {
       boom.trigger();
     }
 
-    void doApply(int[] colors) {
+    void apply(int[] colors) {
       float brightv = 100 * bright.getValuef();
       float falloffv = falloffv();
       float satv = sat.getValuef() * 100;
@@ -963,10 +970,10 @@ class BoomEffect extends SCEffect {
     onEnable();
   }
 
-  public void doApply(int[] colors) {
+  public void apply(int[] colors) {
     for (Layer l : layers) {
       if (l.boom.isRunning()) {
-        l.doApply(colors);
+        l.apply(colors);
       }
     }
   }
@@ -1397,7 +1404,7 @@ class ColorFuckerEffect extends SCEffect {
     addParameter(invert);
   }
   
-  public void doApply(int[] colors) {
+  public void apply(int[] colors) {
     if (!enabled) {
       return;
     }
@@ -1449,7 +1456,7 @@ class QuantizeEffect extends SCEffect {
     lastQuant = 0;
   } 
   
-  public void doApply(int[] colors) {
+  public void apply(int[] colors) {
     float fQuant = amount.getValuef();
     if (fQuant > 0) {
       float tRamp = (lx.tempo.rampf() % (1./pow(2,floor((1-fQuant) * 4))));
@@ -1495,7 +1502,7 @@ class BlurEffect extends SCEffect {
     env.setRangeFromHereTo(0, 1000).start();
   }
   
-  public void doApply(int[] colors) {
+  public void apply(int[] colors) {
     float amt = env.getValuef() * amount.getValuef();
     if (amt > 0) {    
       amt = (1 - amt);