updated midi stuff
authorbb3dan <github@bb3systems.com>
Sat, 19 Oct 2013 01:15:38 +0000 (18:15 -0700)
committerbb3dan <github@bb3systems.com>
Sat, 19 Oct 2013 01:15:38 +0000 (18:15 -0700)
DanHorwitz.pde
DanUtil.pde
MarkSlee.pde
SugarCubes.pde
_Internals.pde
_MIDI.pde
_Mappings.pde

index 856c579a2e8ac7c7a14ce809b378abea3e4980d9..009d74f5515b6e2966c81026b9af109e6d5981ab 100644 (file)
@@ -1,6 +1,6 @@
 //----------------------------------------------------------------------------------------------------------------------------------
 public class Pong extends DPat {
-       SinLFO x,y,z,dx,dy,dz; 
+       SinLFO x,y,z,dx,dy,dz;
        float cRad;     DParam pSize;
        Pick    pChoose;
        xyz     v = new xyz(), vMir =  new xyz();
@@ -24,25 +24,25 @@ public class Pong extends DPat {
                v.z=0;p.z=0;// ignore z dimension
                switch(pChoose.Cur()) {
                case 0: vMir.set(mMax); vMir.subtract(p);
-                               return lx.hsb(0,0,c1c(1 - min(v.distance(p), v.distance(vMir))*.5/cRad));       // balls
-               case 1: return lx.hsb(0,0,c1c(1 - v.distance(p)*.5/cRad));                                                      // ball
+                               return lx.hsb(lxh(),100,c1c(1 - min(v.distance(p), v.distance(vMir))*.5/cRad));         // balls
+               case 1: return lx.hsb(lxh(),100,c1c(1 - v.distance(p)*.5/cRad));                                                        // ball
                case 2: vMir.set(mMax.x/2,0,mMax.z/2);
-                               return lx.hsb(0,0,c1c(1 - CalcCone(p,v,vMir) * max(.02,.45-pSize.Val())));      // spot
+                               return lx.hsb(lxh(),100,c1c(1 - CalcCone(p,v,vMir) * max(.02,.45-pSize.Val())));        // spot
                }
                return lx.hsb(0,0,0);
        }
 }
 //----------------------------------------------------------------------------------------------------------------------------------
 public class NDat {
-       float   xz, yz, zz, hue, sat, speed, angle, den;
+       float   xz, yz, zz, hue, speed, angle, den;
        float   xoff,yoff,zoff;
        float   sinAngle, cosAngle;
        boolean isActive;
        NDat              () { isActive=false; }
        boolean Active() { return isActive; }
-       void    set     (float _hue, float _sat, float _xz, float _yz, float _zz, float _den, float _speed, float _angle) {
+       void    set     (float _hue, float _xz, float _yz, float _zz, float _den, float _speed, float _angle) {
                isActive = true;
-               hue=_hue; sat=_sat; xz=_xz; yz=_yz; zz =_zz; den=_den; speed=_speed; angle=_angle;
+               hue=_hue; xz=_xz; yz=_yz; zz =_zz; den=_den; speed=_speed; angle=_angle;
                xoff = random(100e3); yoff = random(100e3); zoff = random(100e3);
        }
 }
@@ -52,7 +52,7 @@ public class Noise extends DPat
        int                     CurAnim, iSymm;
        int             XSym=1,YSym=2,RadSym=3;
        float           zTime , zTheta=0, zSin, zCos, rtime, ttime, transAdd;
-       DParam          pSpeed , pDensity;
+       DParam          pSpeed , pDensity, pSharp;
        Pick            pChoose, pSymm;
        int                     _ND = 4;
        NDat            N[] = new NDat[_ND];
@@ -61,6 +61,7 @@ public class Noise extends DPat
                super(glucose);
                pSpeed          = addParam("Fast"       , .55);
                pDensity        = addParam("Dens"        , .5);
+               pSharp          = addParam("Shrp"        ,  0);
                pSymm           = addPick("Symmetry" , 0, 3, new String[] {"None", "X", "Y", "Radial"}  );
                pChoose         = addPick("Animation", 6, 7, new String[] {"Drip", "Cloud", "Rain", "Fire", "Machine", "Spark","VWave", "Wave"} );
                for (int i=0; i<_ND; i++) N[i] = new NDat();
@@ -83,20 +84,20 @@ public class Noise extends DPat
                        for (int i=0; i<_ND; i++) { N[i].isActive = false; }
                        
                        switch(CurAnim) {
-                       //                          hue sat xz  yz  zz  den mph angle
-                       case 0: N[0].set(0  ,0  ,75 ,75 ,150,45 ,3  ,0  ); pSharp.set(1 ); break;       // drip
-                       case 1: N[0].set(0  ,0  ,100,100,200,45 ,3  ,180); pSharp.set(0 ); break;       // clouds
-                       case 2: N[0].set(0  ,0  ,2  ,400,2  ,20 ,3  ,0  ); pSharp.set(.5); break;       // rain
-                       case 3: N[0].set(40 ,1  ,100,100,200,10 ,1  ,180); 
-                                       N[1].set(0  ,1  ,100,100,200,10 ,5  ,180); pSharp.set(0 ); break;       // fire 1
-                       case 4: N[0].set(0  ,1  ,40 ,40 ,40 ,15 ,2.5,180);
-                                       N[1].set(20 ,1  ,40 ,40 ,40 ,15 ,4  ,0  );
-                                       N[2].set(40 ,1  ,40 ,40 ,40 ,15 ,2  ,90 );
-                                       N[3].set(60 ,1  ,40 ,40 ,40 ,15 ,3  ,-90); pSharp.set(.5); break; // machine
-                       case 5: N[0].set(0  ,1  ,400,100,2  ,15 ,3  ,90 );
-                                       N[1].set(20 ,1  ,400,100,2  ,15 ,2.5,0  );
-                                       N[2].set(40 ,1  ,100,100,2  ,15 ,2  ,180);
-                                       N[3].set(60 ,1  ,100,100,2  ,15 ,1.5,270); pSharp.set(.5); break; // spark
+                       //                          hue xz yz zz den mph angle
+                       case 0: N[0].set(0  ,75 ,75 ,150,45 ,3  ,0  ); pSharp.set(1 ); break;   // drip
+                       case 1: N[0].set(0  ,100,100,200,45 ,3  ,180); pSharp.set(0 ); break;   // clouds
+                       case 2: N[0].set(0  ,2  ,400,2  ,20 ,3  ,0  ); pSharp.set(.5); break;   // rain
+                       case 3: N[0].set(40 ,100,100,200,10 ,1  ,180); 
+                                       N[1].set(0  ,100,100,200,10 ,5  ,180); pSharp.set(0 ); break;   // fire 1
+                       case 4: N[0].set(0  ,40 ,40 ,40 ,15 ,2.5,180);
+                                       N[1].set(20 ,40 ,40 ,40 ,15 ,4  ,0  );
+                                       N[2].set(40 ,40 ,40 ,40 ,15 ,2  ,90 );
+                                       N[3].set(60 ,40 ,40 ,40 ,15 ,3  ,-90); pSharp.set(.5); break; // machine
+                       case 5: N[0].set(0  ,400,100,2  ,15 ,3  ,90 );
+                                       N[1].set(20 ,400,100,2  ,15 ,2.5,0  );
+                                       N[2].set(40 ,100,100,2  ,15 ,2  ,180);
+                                       N[3].set(60 ,100,100,2  ,15 ,1.5,270); pSharp.set(.5); break; // spark
                        }
 
                        DG.UpdateLights();
@@ -111,15 +112,15 @@ public class Noise extends DPat
        color CalcPoint(xyz P) {
                color c = 0;
                P.RotateZ(mCtr, zSin, zCos);
-               
+
                if (CurAnim == 6 || CurAnim == 7) {
                        P.setNorm();
-                       return lx.hsb(0,0, 100 * (
+                       return lx.hsb(lxh(),100, 100 * (
                                                        constrain(1-50*(1-pDensity.Val())*abs(P.y-sin(zTime*10  + P.x*(300))*.5 - .5),0,1) + 
                        (CurAnim == 7 ? constrain(1-50*(1-pDensity.Val())*abs(P.x-sin(zTime*10  + P.y*(300))*.5 - .5),0,1) : 0))
                        );
                }                       
-                       
+
                if (iSymm == XSym && P.x > mMax.x/2) P.x = mMax.x-P.x;
                if (iSymm == YSym && P.y > mMax.y/2) P.y = mMax.y-P.y;
 
@@ -127,14 +128,14 @@ public class Noise extends DPat
                        NDat  n     = N[i];
                        float zx    = zTime * n.speed * n.sinAngle,
                                  zy    = zTime * n.speed * n.cosAngle;
-                       
+
                        float b     = (iSymm==RadSym ? noise(zTime*n.speed+n.xoff-Dist(P,mCtr)/n.xz)
                                                                                 : noise(P.x/n.xz+zx+n.xoff,P.y/n.yz+zy+n.yoff,P.z/n.zz+n.zoff))
                                                        *1.8;
 
                        b +=    n.den/100 -.4 + pDensity.Val() -1;
                        b +=    transAdd;
-                       c =     blendColor(c,color(n.hue,100*n.sat,c1c(b)),ADD);
+                       c =     blendColor(c,lx.hsb(lxh()+n.hue,100,c1c(b)),ADD);
                }
                return c;
        }
@@ -166,12 +167,12 @@ public class Play extends DPat
        float   zTheta=0;
        ArrayList<rWave> waves = new ArrayList<rWave>(10);
 
-       rAngle  a1 = new rAngle(), a2 = new rAngle(),
-                       a3 = new rAngle(), a4 = new rAngle();
-       xyz             cPrev   = new xyz(), cRand      = new xyz(),
-                       cMid    = new xyz(), V          = new xyz(),
-                       Theta   = new xyz(), TSin       = new xyz(),
-                       TCos    = new xyz(), cMidNorm = new xyz(),
+       rAngle  a1              = new rAngle(), a2              = new rAngle(),
+                       a3              = new rAngle(), a4              = new rAngle();
+       xyz             cPrev   = new xyz(), cRand              = new xyz(),
+                       cMid    = new xyz(), V                  = new xyz(),
+                       Theta   = new xyz(), TSin               = new xyz(),
+                       TCos    = new xyz(), cMidNorm   = new xyz(),
                        Pn              = new xyz();
        float   LastBeat=3, LastMeasure=3;
        int             CurRandTempo = 1, CurRandTPat = 1;
@@ -303,7 +304,7 @@ public class Play extends DPat
                                                distToSeg(Px.x, Px.y, a1.getX(70),a1.getY(70), mCtr.x, mCtr.y),
                                                distToSeg(Px.x, Px.y, a2.getX(40),a2.getY(40), mCtr.x, mCtr.y));
                                        d = constrain(30*(rad*40-d),0,100);
-                                       return lx.hsb(0,max(0,150-d), d); // clock
+                                       return lx.hsb(lxh(),100, d); // clock
 
                case 8:         r = amp*200 * map(bnc,0,1,1,sin(PI*t));
                                        d = min(
@@ -312,7 +313,7 @@ public class Play extends DPat
                                                distToSeg(Px.x, Px.y, a3.getX(r),a3.getY(r), a1.getX(r),a1.getY(r))                             // triangle
                                                );
                                        d = constrain(30*(rad*40-d),0,100);
-                                       return lx.hsb(0,max(0,150-d), d); // clock
+                                       return lx.hsb(lxh(),100, d); // clock
 
                case 9:         r = amp*200 * map(bnc,0,1,1,sin(PI*t));
                                        d = min(
@@ -322,17 +323,17 @@ public class Play extends DPat
                                                distToSeg(Px.x, Px.y, a4.getX(r),a4.getY(r), a1.getX(r),a1.getY(r))                             // quad
                                        );
                                        d = constrain(30*(rad*40-d),0,100);
-                                       return lx.hsb(0,max(0,150-d), d); // clock
+                                       return lx.hsb(lxh(),100, d); // clock
 
                case 10:
                                        r = map(bnc,0,1,a1.r,amp*200*sin(PI*t));
-                                       return lx.hsb(0,0,c1c(.9+2*rad - dist(Px.x,Px.y,a1.getX(r),a1.getY(r))*.03) );          // sphere
+                                       return lx.hsb(lxh(),100,c1c(.9+2*rad - dist(Px.x,Px.y,a1.getX(r),a1.getY(r))*.03) );            // sphere
 
                case 11:
                                        Px.z=mCtr.z; cMid.z=mCtr.z;
-                                       return lx.hsb(0,0,c1c(1 - CalcCone(Px,cMid,mCtr) * 0.02 > .5?1:0));                             // cone
+                                       return lx.hsb(lxh(),100,c1c(1 - CalcCone(Px,cMid,mCtr) * 0.02 > .5?1:0));                               // cone
 
-               case 12:        return lx.hsb(100 + noise(Pn.x,Pn.y,Pn.z + (NoiseMove+50000)/1000.)*200,
+               case 12:        return lx.hsb(lxh() + noise(Pn.x,Pn.y,Pn.z + (NoiseMove+50000)/1000.)*200,
                                                85,c1c(Pn.y < noise(Pn.x + NoiseMove/2000.,Pn.z)*(1+amp)-amp/2.-.1 ? 1 : 0));   // noise
 
                case 13:        float y=0; for (rWave w : waves) y += .5*w.val(Pn.x);
@@ -342,9 +343,7 @@ public class Play extends DPat
                default:        return lx.hsb(0,0,0);
                }
 
-               return lx.hsb(0,
-                               150-c1c(1 - V.distance(Pn)/rad),
-                               c1c(1 - V.distance(Pn)/rad));
+               return lx.hsb(lxh(), 100, c1c(1 - V.distance(Pn)/rad));
        }
 }
 //----------------------------------------------------------------------------------------------------------------------------------
@@ -436,13 +435,14 @@ class Worms extends SCPattern {
        private BasicParameter pConfusion = new BasicParameter("CONF", .1);
        private BasicParameter pEQ        = new BasicParameter("EQ"  ,  0);
        private BasicParameter pSpawn     = new BasicParameter("DIR" ,  0);
+       private BasicParameter pColor     = new BasicParameter("CLR" ,  .1);
 
        int     zMidLat = 82;
        float   nConfusion;
        private final Click moveChase = new Click(1000);
 
        xyz     middle;
-       int     AnimNum() { return floor(pSpawn.getValuef()*(4-.01)); }
+       int     AnimNum() { return floor(pSpawn.getValuef()*(4-.01));   }
        float   randX() { return random(model.xMax-model.xMin)+model.xMin; }
        float   randY() { return random(model.yMax-model.yMin)+model.yMin; }
        xyz     randEdge() { 
@@ -456,7 +456,8 @@ class Worms extends SCPattern {
            addParameter(pBeat);    addParameter(pSpeed);
            addParameter(pBlur);    addParameter(pWorms);
            addParameter(pEQ);      addParameter(pConfusion);
-               addParameter(pSpawn);
+               addParameter(pSpawn);   addParameter(pColor);
+
            middle = new xyz(model.cx, model.cy, 71);
                if (lattice == null) lattice = new dLattice();
                for (int i=0; i<numCursors; i++) { dCursor c = new dCursor(); reset(c); cur.add(c); }
@@ -471,23 +472,24 @@ class Worms extends SCPattern {
                }
        }
 
+       float getClr() { return lx.getBaseHuef() + random(pColor.getValuef()*300); }
        void reset(dCursor c) {
                switch(AnimNum()) {
-                       case 0: c.clr = lx.hsb(135,100,100);                    // middle to edges
+                       case 0: c.clr = lx.hsb(getClr(),100,100);                       // middle to edges
                                        c.setDest(lattice.getClosest(randEdge()).v, nConfusion);
                                        c.setCur (lattice.getClosest(middle));
                                        break;
 
-                       case 1: c.clr = lx.hsb(135,0,100);                              // top to bottom
+                       case 1: c.clr = lx.hsb(getClr(),100,100);                               // top to bottom
                                        float xLin = randX();
                                        c.setDest(lattice.getClosest(new xyz(xLin, 0         , zMidLat)).v, nConfusion);
                                        c.setCur (lattice.getClosest(new xyz(xLin, model.yMax, zMidLat)));
                                        break;
 
-                       case 2: c.clr = lx.hsb(300,0,100); break;               // chase a point around
+                       case 2: c.clr = lx.hsb(getClr(),100,100); break;                // chase a point around
 
                        case 3: boolean bLeft = random(2)<1;
-                                       c.clr = lx.hsb(135+random(120),100,100);                                // sideways
+                                       c.clr = lx.hsb(getClr()+random(120),100,100);                           // sideways
                                        float yLin = randX();
                                        c.setDest(lattice.getClosest(new xyz(bLeft ? 0 : model.xMax,yLin,zMidLat)).v, nConfusion);
                                        c.setCur (lattice.getClosest(new xyz(bLeft ? model.xMax : 0,yLin,zMidLat)));
@@ -501,7 +503,7 @@ class Worms extends SCPattern {
                xyz dest = new xyz(randX(), randY(), zMidLat);
                for (int i=0; i<numCursors; i++) {
                        cur.get(i).setDest(lattice.getClosest(dest).v, nConfusion);
-                       cur.get(i).clr = lx.hsb(0,100,100);     // chase a point around
+                       cur.get(i).clr = lx.hsb(getClr()+75,100,100);   // chase a point around
                }
        }
 
@@ -518,8 +520,8 @@ class Worms extends SCPattern {
 
                if (pBlur.getValuef() < 1) {    // trails
                        for (int i=0,s=model.points.size(); i<s; i++) {
-                               color c = colors[i]; float b = brightness(c); 
-                               if (b>0) colors[i] = color(hue(c), saturation(c), (float)(b-100*deltaMs/(pBlur.getValuef()*TrailTime)));
+                               color c = colors[i]; float b = lx.b(c); 
+                               if (b>0) colors[i] = lx.hsb(lx.h(c), lx.s(c), constrain((float)(b-100*deltaMs/(pBlur.getValuef()*TrailTime)),0,100));
                        }
                }
 
index 6f4b0008485891d1a75ddbb05170d6c4e99cbc64..37dc95602bde719d0feb50af636474b39d38bb36 100644 (file)
@@ -118,7 +118,7 @@ public class DGlobals {
 
        
        float           Sliders[]               = new float [] {1,0,0,0,0,0,0,0};
-       String          SliderText[]    = new String[] {"Level", "SpinHue", "Spark", "Xwave", "Ywave", "Trails", "Quant", "??", "??"};
+       String          SliderText[]    = new String[] {"Level", "??", "Spark", "Xwave", "Ywave", "??", "??", "??", "??"};
        
        void            SetNoteOn       (int row, int col, int clr){ if (APCOut != null) APCOut.sendNoteOn              (col, row, clr);        }
        void            SetNoteOff      (int row, int col, int clr){ if (APCOut != null) APCOut.sendNoteOff             (col, row, clr);        }
@@ -129,12 +129,9 @@ public class DGlobals {
        DParam          GetParam(int i)                                         { return (DParam) CurPat.params.get(i); }
 
        float           _Level          ()                                              { return Sliders[0]; }
-       float           _SpinHue        ()                                              { return Sliders[1]; }
        float           _Spark          ()                                              { return Sliders[2]; }
        float           _XWave          ()                                              { return Sliders[3]; }
        float           _YWave          ()                                              { return Sliders[4]; }
-       float           _Trails         ()                                              { return Sliders[5]; }
-       float           _Quantize       ()                                              { return Sliders[6]; }
 
        void            Init            () {
                if (bInit) return; bInit=true;
@@ -159,7 +156,7 @@ public class DGlobals {
                String Text1="", Text2="";
                for (int i=0; i<CurPat.bools.size(); i++) if (GetBool(i).b) Text1 += " " + GetBool(i).tag       + "   ";
                for (int i=0; i<CurPat.picks.size(); i++) Text1 += GetPick(i).tag + ": " + GetPick(i).CurDesc() + "   ";
-               for (int i=0; i<8; i++)                                   Text2 += SliderText[i]  + ": " + round(100*Sliders[i])  + "   ";
+               for (int i=0; i<5; i++)                                   Text2 += SliderText[i]  + ": " + round(100*Sliders[i])  + "   ";
                uiDebugText.setText(Text1, Text2);
        }
 
@@ -205,7 +202,6 @@ public class DPat extends SCPattern
        ArrayList       params          = new ArrayList();
        ArrayList       bools           = new ArrayList();
        int                     nMaxRow         = 53;
-       float           zSpinHue        = 0;
        float           LastQuant       = -1, LastJog = -1;
        float[]         xWaveNz, yWaveNz;
        int             nPoint  , nPoints;
@@ -213,9 +209,10 @@ public class DPat extends SCPattern
        xyz                     modmin;
 
        float           NoiseMove       = random(10000);
-       DParam          pRotX, pRotY, pRotZ, pSpin, pSharp, pSaturate, pTransX, pTransY;
-       
-       DBool           pXsym, pYsym, pRsym, pXdup, pXtrip, pJog, pKey, pInvert;
+       DParam          pBlank, pBlank2, pRotX, pRotY, pRotZ, pSpin, pTransX, pTransY;
+
+       DBool           pXsym, pYsym, pRsym, pXdup, pXtrip, pJog, pKey;
+       float           lxh             ()                                                      { return lx.getBaseHuef();                                      }
        float           Dist     (xyz a, xyz b)                         { return dist(a.x,a.y,a.z,b.x,b.y,b.z);         }
        int                     c1c              (float a)                                      { return round(100*constrain(a,0,1));           }
        float           interpWv(float i, float[] vals)         { return interp(i-floor(i), vals[floor(i)], vals[ceil(i)]); }
@@ -225,7 +222,7 @@ public class DPat extends SCPattern
 
        void            StartPattern()                                          {                                                               }
        void            StartRun(double deltaMs)                        {                                                               }
-       color           CalcPoint(xyz p)                                        { return lx.hsb(0,0,0);                         }
+       color           CalcPoint(xyz p)                                        { return lx.hsb(0,0,0);                 }
        boolean         IsActive()                                                      { return this == DG.CurPat;                                                                                             }
        boolean         IsFocused()                                                     { return midiEngine != null && midiEngine.getFocusedDeck() != null &&
                                                                                                                         this == midiEngine.getFocusedDeck().getActivePattern();                }
@@ -250,8 +247,8 @@ public class DPat extends SCPattern
        DPat(GLucose glucose) {
                super(glucose);
 
-               pSharp          =       addParam("Shrp",  0);
-               pSaturate       =       addParam("Sat" , .5);
+               pBlank          =       addParam("",  0);
+               pBlank2         =       addParam("" , .5);
                pTransX         =       addParam("TrnX", .5);
                pTransY         =       addParam("TrnY", .5);
                pRotX           =       addParam("RotX", .5);
@@ -264,9 +261,8 @@ public class DPat extends SCPattern
                pYsym           =       new DBool("Y-SYM", false, 49, 1);       bools.add(pYsym );
                pRsym           =       new DBool("R-SYM", false, 49, 2);       bools.add(pRsym );
                pXdup           =       new DBool("X-DUP", false, 49, 3);       bools.add(pXdup );
-               pJog            =       new DBool("JOG"  ,false, 49,  4);       bools.add(pJog  );
-               pKey            =       new DBool("KBD"  ,false, 49,  5);       bools.add(pKey  );
-               pInvert         =       new DBool("INVRT",false, 49,  6);       bools.add(pInvert);
+               pJog            =       new DBool("JOG"  , false, 49, 4);       bools.add(pJog  );
+               pKey            =       new DBool("KBD"  , false, 49, 5);       bools.add(pKey  );
 
                modmin          =       new xyz(model.xMin, model.yMin, model.zMin);
                mMax            =       new xyz(model.xMax, model.yMax, model.zMax); mMax.subtract(modmin);
@@ -285,21 +281,12 @@ public class DPat extends SCPattern
                UpdateState();
                NoiseMove       += deltaMs; NoiseMove = NoiseMove % 1e7;
                StartRun                (deltaMs);
-               zSpinHue                += DG._SpinHue ()*deltaMs*.05; zSpinHue = zSpinHue % 5000.;
                xyz P                   = new xyz(), tP = new xyz(), pSave = new xyz();
                xyz pTrans              = new xyz(pTransX.Val()*200-100, pTransY.Val()*100-50,0);
-               float fSharp    = 1/(1.0001-pSharp.Val());
-               float fQuant    = DG._Quantize ();
-               float fSaturate = pSaturate.Val();
                
                DG.SetText();
                nPoint  = 0;
 
-               if (fQuant > 0) {
-                       float tRamp     = (lx.tempo.rampf() % (1./pow(2,floor((1-fQuant) * 4))));
-                       float f = LastQuant; LastQuant = tRamp; if (tRamp > f) return;
-               }
-       
                if (pJog.b) {
                        float tRamp     = (lx.tempo.rampf() % .25);
                        if (tRamp < LastJog) xyzJog.set(randctr(mMax.x*.2), randctr(mMax.y*.2), randctr(mMax.z*.2));
@@ -313,7 +300,7 @@ public class DPat extends SCPattern
 
                if (xWv > 0) for (int i=0; i<ceil(mMax.y)+1; i++)
                        xWaveNz[i] = xWv * (noise(i/(mMax.y*.3)-(1e3+NoiseMove)/1500.) - .5) * (mMax.x/2.);
-                       
+
                for (Point p : model.points) { nPoint++;
                        P.set(p);
                        P.subtract(modmin);
@@ -331,37 +318,29 @@ public class DPat extends SCPattern
                        if (pRsym.b)    { tP.set(mMax.x-P.x,mMax.y-P.y,mMax.z-P.z);             cNew = blendColor(cNew, CalcPoint(tP), ADD);    }
                        if (pXdup.b)    { tP.set((P.x+mMax.x*.5)%mMax.x,P.y,P.z);               cNew = blendColor(cNew, CalcPoint(tP), ADD);    }
 
-                       float                                                           s =     lx.s(cNew) + 100*(fSaturate*2-1);
+                       float                                                           s =     lx.s(cNew);
                        float                                                           b = lx.b(cNew)/100.;
-                       if (pSharp.Val()>0)                             b = b < .5 ? pow(b,fSharp) : 1-pow(1-b,fSharp);
-                       if (DG._Trails()>0 && fQuant == 0)      b = max(b, (float) (lx.b(cOld)/100. - (1-DG._Trails()) * deltaMs/200.));
                        if (DG.bSustain == true)                        b = max(b, (float) (lx.b(cOld)/100.));
 
-                       if (pInvert.b)  { b = 1-b; s = 1-s; }
-
-                       colors[p.index] = lx.hsb(
-                               (lx.h(cNew) + zSpinHue) % 360,
-                               s,
-                               100 *  b * DG._Level()
-                       );
-
-//                     colors[p.index] = lx.hsb(0,0, p.x >= modmin.x && p.y >= modmin.y && p.z >= modmin.z &&
-//                             p.x <= modmin.x+mMax.x && p.y <= modmin.y+mMax.y && p.z <= modmin.z+mMax.z ? 100 : 0); 
+                       colors[p.index] = lx.hsb(lx.h(cNew), s, 100 *  b * DG._Level());
                }
        }
 }
 //----------------------------------------------------------------------------------------------------------------------------------
 class dTurn { 
        dVertex v; 
-       int pos0, pos1; 
+       int pos0, pos1;
        dTurn(int _pos0, dVertex _v, int _pos1) { v = _v; pos0 = _pos0; pos1 = _pos1; }
 }
 
 class dVertex {
-       dVertex c0, c1, opp, same;
+       dVertex c0, c1,                 // connections on the cube
+                       opp, same;              // opp - same strip, opp direction
+                                                       // same - same strut, diff strip, dir
        dTurn   t0, t1;
        dStrip  s;
-       int     dir, ci;
+       int     dir, ci;        // dir -- 1 or -1.
+                                               // ci  -- color index
 
        dVertex(dStrip _s, Point _p) { s = _s; ci  = _p.index; }
        Point   getPoint(int i)          { return s.s.points.get(dir>0 ? i : 15-i);  }
@@ -378,23 +357,23 @@ class dStrip  {
 //----------------------------------------------------------------------------------------------------------------------------------
 float PointDist(Point p1, Point p2) { return dist(p1.x,p1.y,p1.z,p2.x,p2.y,p2.z); }
 
-class dPixel   { dVertex v; int pos; dPixel(dVertex _v, int _pos) { v=_v; pos=_pos; }}
+class dPixel   { dVertex v; int pos; dPixel(dVertex _v, int _pos) { v=_v; pos=_pos; } }
 class dLattice {
        private         int iTowerStrips=0;
 
        dStrip[]        DS = new dStrip[glucose.model.strips.size()];
-       int[][]         DQ = new int[NumBackTowers][MaxCubeHeight*2];
-       dStrip  GetStrip (int row, int col, int off) { 
-               return (!btwn(off,0,15) || !btwn(row,0,MaxCubeHeight*2-1) || !btwn(col,0,NumBackTowers-1) || DQ[col][row]<0) ? null : 
-                               DS[DQ[col][row]+off]; 
-       }
+       //int[][]       DQ = new int[NumBackTowers][MaxCubeHeight*2];
+       //dStrip  GetStrip (int row, int col, int off) { 
+       //      return (!btwn(off,0,15) || !btwn(row,0,MaxCubeHeight*2-1) || !btwn(col,0,NumBackTowers-1) || DQ[col][row]<0) ? null : 
+       //                      DS[DQ[col][row]+off]; 
+       //}
 
        void    addTurn(dVertex v0, int pos0, dVertex v1, int pos1) {   dTurn t = new dTurn(pos0, v1, pos1); if (v0.t0 == null) v0.t0=t; else v0.t1=t; }
        float   Dist2    (Strip s1, int pos1, Strip s2, int pos2)       {       return PointDist(s1.points.get(pos1), s2.points.get(pos2)); }
-       boolean SameSame (Strip s1, Strip s2)                                           {       return max(Dist2(s1, 0, s2, 0), Dist2(s1,15, s2,15)) < 5 ;      }
-       boolean SameOpp  (Strip s1, Strip s2)                                           {       return max(Dist2(s1, 0, s2,15), Dist2(s1,15, s2,0 )) < 5 ;      }
-       boolean SameBar  (Strip s1, Strip s2)                                           {       return SameSame(s1,s2) || SameOpp(s1,s2);                                       }
        float   PD2      (Point p1, float x, float y, float z)          {       return dist(p1.x,p1.y,p1.z,x,y,z); }
+       boolean SameSame (Strip s1, Strip s2)                                           {       return max(Dist2(s1, 0, s2, 0), Dist2(s1,15, s2,15)) < 5 ;      }       // same strut, same direction
+       boolean SameOpp  (Strip s1, Strip s2)                                           {       return max(Dist2(s1, 0, s2,15), Dist2(s1,15, s2,0 )) < 5 ;      }       // same strut, opp direction
+       boolean SameBar  (Strip s1, Strip s2)                                           {       return SameSame(s1,s2) || SameOpp(s1,s2);                                       }       // 2 strips on same strut
        void    AddJoint (dVertex v1, dVertex v2) {
                // should probably replace parallel but further with the new one
                if (v1.c0 != null && SameBar(v2.s.s, v1.c0.s.s)) return;
@@ -419,7 +398,7 @@ class dLattice {
 
        dLattice() {
                lattice=this;
-               for (int i=0;i<NumBackTowers;i++) for (int j=0;j<MaxCubeHeight*2;j++) DQ[i][j]=-1;
+               //for (int i=0;i<NumBackTowers;i++) for (int j=0;j<MaxCubeHeight*2;j++) DQ[i][j]=-1;
 
                int   col = 0, row = -2, i=-1;
                for (Strip strip : glucose.model.strips  ) { i++;
@@ -430,8 +409,8 @@ class dLattice {
                        s.v0 = new dVertex(s,strip.points.get(0 ));
                        s.v1 = new dVertex(s,strip.points.get(15));
                        s.v0.setOpp(s.v1); s.v1.setOpp(s.v0);
-                       if (col < NumBackTowers) DQ[col][row] = 16*floor((iTowerStrips-1)/16);
-                       else s.row=-1;
+                       //if (col < NumBackTowers) DQ[col][row] = 16*floor((iTowerStrips-1)/16);
+                       //else s.row=-1;
                }
 
                for (int j=0; j<iTowerStrips; j++) { for (int k=j+1; k<iTowerStrips; k++) { 
index 649d61cc4594c71e29e1960704854bb3241e3363..7a556d5d0f7850d5a463f7ba7f890365e664b828 100644 (file)
@@ -1195,38 +1195,98 @@ class Traktor extends SCPattern {
 
 class ColorFuckerEffect extends SCEffect {
   
-  BasicParameter hueShift = new BasicParameter("HSHFT", 0);
-  BasicParameter sat = new BasicParameter("SAT", 1);  
-  BasicParameter bright = new BasicParameter("BRT", 1);
+  final BasicParameter level = new BasicParameter("BRT", 1);
+  final BasicParameter desat = new BasicParameter("DSAT", 0);
+  final BasicParameter sharp = new BasicParameter("SHARP", 0);
+  final BasicParameter soft = new BasicParameter("SOFT", 0);
+  final BasicParameter mono = new BasicParameter("MONO", 0);
+  final BasicParameter invert = new BasicParameter("INVERT", 0);
+  final BasicParameter hueShift = new BasicParameter("HSHFT", 0);
+  
   float[] hsb = new float[3];
   
   ColorFuckerEffect(GLucose glucose) {
     super(glucose);
+    addParameter(level);
+    addParameter(desat);
+    addParameter(sharp);
+    addParameter(soft);
+    addParameter(mono);
+    addParameter(invert);
     addParameter(hueShift);
-    addParameter(bright);
-    addParameter(sat);    
   }
   
   public void doApply(int[] colors) {
     if (!enabled) {
       return;
     }
-    float bMod = bright.getValuef();
-    float sMod = sat.getValuef();
+    float bMod = level.getValuef();
+    float sMod = 1 - desat.getValuef();
     float hMod = hueShift.getValuef();
-    if (bMod < 1 || sMod < 1 || hMod > 0) {    
+    float fSharp = 1/(1.0001-sharp.getValuef());
+    float fSoft = soft.getValuef();
+    boolean mon = mono.getValuef() > 0.5;
+    boolean ivt = invert.getValuef() > 0.5;
+    if (bMod < 1 || sMod < 1 || hMod > 0 || fSharp > 0 || ivt || mon || fSoft > 0) {
       for (int i = 0; i < colors.length; ++i) {
         lx.RGBtoHSB(colors[i], hsb);
+        if (mon) {
+          hsb[0] = lx.getBaseHuef() / 360.;
+        }
+        if (ivt) {
+          hsb[2] = 1 - hsb[2];
+        }
+        if (fSharp > 0) {
+          hsb[2] = hsb[2] < .5 ? pow(hsb[2],fSharp) : 1-pow(1-hsb[2],fSharp);
+        }
+        if (fSoft > 0) {
+          if (hsb[2] > 0.5) {
+            hsb[2] = lerp(hsb[2], 0.5 + 2 * (hsb[2]-0.5)*(hsb[2]-0.5), fSoft);
+          } else {
+            hsb[2] = lerp(hsb[2], 0.5 * sqrt(2*hsb[2]), fSoft);
+          }
+        }
         colors[i] = lx.hsb(
-          (360. * hsb[0] + hueShift.getValuef()*360.) % 360,
-          100. * hsb[1] * sat.getValuef(),
-          100. * hsb[2] * bright.getValuef()
+          (360. * hsb[0] + hMod*360.) % 360,
+          100. * hsb[1] * sMod,
+          100. * hsb[2] * bMod
         );
       }
     }
   }
 }
 
+class QuantizeEffect extends SCEffect {
+  
+  color[] quantizedFrame;
+  float lastQuant;
+  final BasicParameter amount = new BasicParameter("AMT", 0);
+  
+  QuantizeEffect(GLucose glucose) {
+    super(glucose);
+    quantizedFrame = new color[glucose.lx.total];
+    lastQuant = 0;
+  } 
+  
+  public void doApply(int[] colors) {
+    float fQuant = amount.getValuef();
+    if (fQuant > 0) {
+      float tRamp = (lx.tempo.rampf() % (1./pow(2,floor((1-fQuant) * 4))));
+      float f = lastQuant;
+      lastQuant = tRamp;
+      if (tRamp > f) {
+        for (int i = 0; i < colors.length; ++i) {
+          colors[i] = quantizedFrame[i];
+        }
+        return;
+      }
+    }
+    for (int i = 0; i < colors.length; ++i) {
+      quantizedFrame[i] = colors[i];
+    }
+  }
+}
+
 class BlurEffect extends SCEffect {
   
   final LXParameter amount = new BasicParameter("AMT", 0);
index 805c32697d4075cde744d0f73a8c4e226926a33a..9faf3ec45d2babd96a24089d549e86c370d96a90 100644 (file)
@@ -129,15 +129,18 @@ LXTransition[] transitions(GLucose glucose) {
 }
 
 // Handles to globally triggerable effects 
-BoomEffect     EFF_boom;
+BoomEffect EFF_boom;
 FlashEffect EFF_flash;
+ColorFuckerEffect EFF_colorFucker;
+BlurEffect EFF_blur;
+QuantizeEffect EFF_quantize;
 
 LXEffect[] effects(GLucose glucose) {
   return new LXEffect[] {
-    EFF_flash  = new FlashEffect(lx),
-    EFF_boom   = new BoomEffect(glucose),
-    new BlurEffect(glucose),
-    new DesaturationEffect(lx),
-    new ColorFuckerEffect(glucose),
+    EFF_flash = new FlashEffect(lx),
+    EFF_boom = new BoomEffect(glucose),
+    (EFF_blur = new BlurEffect(glucose)).enable(),
+    (EFF_quantize = new QuantizeEffect(glucose)).enable(),
+    (EFF_colorFucker =  new ColorFuckerEffect(glucose)).enable(),
   };
 }
index 07934ccc461198f2a7577229c07752ba08dba2c5..9d6e2740a4aea94a54cd807202b86949403b6a98 100644 (file)
@@ -52,7 +52,6 @@ LXPattern[] patterns;
 MappingTool mappingTool;
 PandaDriver[] pandaBoards;
 MidiEngine midiEngine;
-GridController gridController;
 
 // Display configuration mode
 boolean mappingMode = false;
@@ -100,6 +99,7 @@ LXPattern[] _rightPatterns(GLucose glucose) {
   }
   return rightPatterns;
 }
+  
 
 void logTime(String evt) {
   int now = millis();
index b0b8fc4ca9bd46e650c168881601edbf5478162e..a584ef9097d72a69543336def3fc6ef872620b3f 100644 (file)
--- a/_MIDI.pde
+++ b/_MIDI.pde
@@ -332,7 +332,7 @@ public class APC40MidiInput extends GenericDeviceMidiInput {
   private LXEffect releaseEffect = null;
   
   APC40MidiInput(MidiEngine midiEngine, MidiInputDevice d) {
-    super(midiEngine, d);
+    super(midiEngine, d);    
   }
 
   private class GridPosition {
@@ -370,11 +370,39 @@ public class APC40MidiInput extends GenericDeviceMidiInput {
   }
 
   protected void handleControllerChange(rwmidi.Controller cc) {
+    int channel = cc.getChannel();
     int number = cc.getCC();
+    float value = cc.getValue() / 127.;
     switch (number) {
+      
+    case 7:
+     switch (channel) {
+       case 0:
+         EFF_colorFucker.hueShift.setValue(value);
+         break;
+       case 1:
+         EFF_colorFucker.desat.setValue(value);
+         break;
+       case 2:
+         EFF_colorFucker.sharp.setValue(value);
+         break;
+       case 3:
+         EFF_blur.amount.setValue(value);
+         break;
+       case 4:
+         EFF_quantize.amount.setValue(value);
+         break;
+     }
+     break;
+     
+    // Master bright
+    case 14:
+      EFF_colorFucker.level.setValue(value);
+      break;
+
     // Crossfader
     case 15:
-      lx.engine.getDeck(1).getCrossfader().setValue(cc.getValue() / 127.);
+      lx.engine.getDeck(1).getCrossfader().setValue(value);
       break;
     }
     
@@ -387,7 +415,7 @@ public class APC40MidiInput extends GenericDeviceMidiInput {
     if (parameterIndex >= 0) {
       List<LXParameter> parameters = midiEngine.getFocusedPattern().getParameters();
       if (parameterIndex < parameters.size()) {
-        parameters.get(parameterIndex).setValue(cc.getValue() / 127.);
+        parameters.get(parameterIndex).setValue(value);
       }
     }
     
@@ -395,7 +423,7 @@ public class APC40MidiInput extends GenericDeviceMidiInput {
       int effectIndex = number - 20;
       List<LXParameter> parameters = glucose.getSelectedEffect().getParameters();
       if (effectIndex < parameters.size()) {
-        parameters.get(effectIndex).setValue(cc.getValue() / 127.);
+        parameters.get(effectIndex).setValue(value);
       }
     }
   }
@@ -407,9 +435,24 @@ public class APC40MidiInput extends GenericDeviceMidiInput {
   }
 
   protected void handleNoteOn(Note note) {
-    int nPitch = note.getPitch(), nChan = note.getChannel();
+    int nPitch = note.getPitch();
+    int nChan = note.getChannel();
     switch (nPitch) {
-               
+    
+    case 49: // SOLO/CUE
+      switch (nChan) {
+        case 4:
+          EFF_colorFucker.mono.setValue(1);
+          break;
+        case 5:
+          EFF_colorFucker.invert.setValue(1);
+          break;
+        case 6:
+          lx.cycleBaseHue(60000);
+          break;
+      }
+      break;
+      
     case 82: // scene 1
       EFF_boom.trigger();
       break;
@@ -479,8 +522,25 @@ public class APC40MidiInput extends GenericDeviceMidiInput {
   }
 
   protected void handleNoteOff(Note note) {
-    int nPitch = note.getPitch(), nChan = note.getChannel();
+    int nPitch = note.getPitch();
+    int nChan = note.getChannel();
+
     switch (nPitch) {
+      
+    case 49: // SOLO/CUE
+      switch (nChan) {
+        case 4:
+          EFF_colorFucker.mono.setValue(0);
+          break;
+        case 5:
+          EFF_colorFucker.invert.setValue(0);
+          break;
+        case 6:
+          lx.setBaseHue(lx.getBaseHue());
+          break;
+      }
+      break;
+      
     case 90: // SEND C
       long tapDelta = millis() - tap1;
       if (lbtwn(tapDelta,5000,300*1000)) {     // hackish tapping mechanism
@@ -578,6 +638,9 @@ class APC40MidiOutput implements LXParameter.Listener, GridOutput {
     }
     resetParameters();
     midiEngine.grid.addOutput(this);
+
+    lx.cycleBaseHue(60000);
+    output.sendNoteOn(6, 49, 127);
   }
 
   private void resetParameters() {
index 15b440bc6342474f4893d0f7fc260684dd3d691b..7d288ef8916a31979033c229926bc344f62c486c 100644 (file)
@@ -73,9 +73,9 @@ public Model buildModel() {
   
   // Single cubes can be constructed directly here if you need them
   Cube[] singleCubes = new Cube[] {
-    // new Cube(15, int( Cube.EDGE_HEIGHT), 39, 0, 10, 0,  WRL),     // Back left channel behind speaker
+     //new Cube(15, int( Cube.EDGE_HEIGHT), 39, 0, 10, 0,  WRL),     // Back left channel behind speaker
      //new Cube(x, y, z, rx, ry, rz, wiring),
-    new Cube(0,0,0,0,-135,0, WRR),
+     //new Cube(0,0,0,0,-135,0, WRR),
   };
 
   // The bass box!