final changes
authorbb3dan <gitdan@citopia.com>
Sat, 28 Sep 2013 00:22:12 +0000 (20:22 -0400)
committerbb3dan <gitdan@citopia.com>
Sat, 28 Sep 2013 00:22:12 +0000 (20:22 -0400)
DanHorwitz.pde
DanUtil.pde
_MIDI.pde

index 0f987bf66706dd86557ccb0cd954b42ca615cff8..6c46e69b415213113408ff16a07b740136a0db48 100755 (executable)
@@ -51,24 +51,24 @@ public class Noise extends DPat
        int                     CurAnim, iSymm;\r
        int             XSym=1,YSym=2,RadSym=3;\r
        float           zTime , zTheta=0, zSin, zCos, rtime, ttime, transAdd;\r
-       DParam          pSpeed , pDensity, pRotZ;\r
+       DParam          pSpeed , pDensity;\r
        Pick            pChoose, pSymm;\r
        int                     _ND = 4;\r
        NDat            N[] = new NDat[_ND];\r
 \r
        Noise(GLucose glucose) {\r
                super(glucose);\r
-               pRotZ   = addParam("RotZ"        , .5 );        pSpeed          = addParam("Fast", .55);\r
-               pDensity= addParam("Dens"        , .5);\r
-               pSymm   = addPick("Symmetry" , 0, 3, new String[] {"None", "X", "Y", "Radial"}  );\r
-               pChoose = addPick("Animation", 6, 7, new String[] {"Drip", "Cloud", "Rain", "Fire", "Machine", "Spark","VWave", "Wave"} );\r
+               pSpeed          = addParam("Fast"       , .55);\r
+               pDensity        = addParam("Dens"        , .5);\r
+               pSymm           = addPick("Symmetry" , 0, 3, new String[] {"None", "X", "Y", "Radial"}  );\r
+               pChoose         = addPick("Animation", 6, 7, new String[] {"Drip", "Cloud", "Rain", "Fire", "Machine", "Spark","VWave", "Wave"} );\r
                for (int i=0; i<_ND; i++) N[i] = new NDat();\r
        }\r
 \r
        void StartPattern() { zTime = random(500); zTheta=0; rtime = 0; ttime = 0; transAdd=0; }\r
        void StartRun(double deltaMs) {\r
                zTime   += deltaMs*(pSpeed.Val()-.5)*.002       ;\r
-               zTheta  += deltaMs*(pRotZ .Val()-.5)*.01        ;\r
+               zTheta  += deltaMs*(pSpin .Val()-.5)*.01        ;\r
                rtime   += deltaMs;\r
                iSymm    = pSymm.Cur();\r
                transAdd = 1*(1 - constrain(rtime - ttime,0,1000)/1000);\r
@@ -77,8 +77,8 @@ public class Noise extends DPat
 \r
                if (pChoose.Cur() != CurAnim) {\r
                        CurAnim = pChoose.Cur(); ttime = rtime;\r
-                       pRotZ           .reset();       zTheta          = 0;\r
-                       pDensity        .reset();       pSpeed          .reset();       \r
+                       pSpin           .reset();       zTheta          = 0;\r
+                       pDensity        .reset();       pSpeed          .reset();\r
                        for (int i=0; i<_ND; i++) { N[i].isActive = false; }\r
                        \r
                        switch(CurAnim) {\r
@@ -160,7 +160,6 @@ public class Play extends DPat
 \r
        int             nBeats  =       0;\r
        DParam  pAmp, pRadius, pBounce;\r
-       DParam  pRotX, pRotY, pRotZ;\r
 \r
        float   t,amp,rad,bnc;\r
        \r
@@ -176,15 +175,11 @@ public class Play extends DPat
        float   LastBeat=3, LastMeasure=3;\r
        int             CurRandTempo = 1, CurRandTPat = 1;\r
 \r
-\r
-       Pick    pTimePattern, pTempoMult, pShape, pForm;\r
+       Pick    pTimePattern, pTempoMult, pShape;\r
        int             RandCube;\r
 \r
        Play(GLucose glucose) {\r
                super(glucose);\r
-               pRotX           = addParam("RotX", .5);\r
-               pRotY           = addParam("RotY", .5);\r
-               pRotZ           = addParam("RotZ", .5);\r
            pRadius             = addParam("Rad"        , .1    );\r
                pBounce         = addParam("Bnc"        , .2    );\r
            pAmp                = addParam("Amp"        , .2    );\r
@@ -193,7 +188,6 @@ public class Play extends DPat
                                                                                                                                        "Pyramid", "Wings", "W2", "Clock",\r
                                                                                                                                        "Triangle", "Quad", "Sphere", "Cone",\r
                                                                                                                                        "Noise", "Wave", "?", "?"}                                              );\r
-               pForm           = addPick ("Form"       , 2 , 2         , new String[] {"Bar", "Volume", "Fade"}                                                                                                );\r
        }\r
 \r
        public class rWave {\r
@@ -245,15 +239,19 @@ public class Play extends DPat
                        w.move(deltaMs); if (w.bDone) waves.remove(i); else i++;\r
                }\r
 \r
-               if (t<LastBeat) {\r
-                       cPrev.set(cRand); cRand.setRand();\r
-                       a1.set(); a2.set(); a3.set(); a4.set();\r
+               if ((t<LastBeat && !pKey.b) || DG.KeyPressed>-1) {\r
                        waves.add(new rWave(\r
-                                               random(1),              // location\r
+                                               pKey.b ? map(DG.KeyPressed,0,7,0,1) : random(1),                // location\r
                                                bnc*10,                 // bounciness\r
                                                7,                              // velocity\r
                                                2*(1-amp)));    // dampiness\r
+                       DG.KeyPressed=-1;\r
                        if (waves.size() > 5) waves.remove(0);\r
+               }\r
+               \r
+               if (t<LastBeat) {\r
+                       cPrev.set(cRand); cRand.setRand();\r
+                       a1.set(); a2.set(); a3.set(); a4.set();\r
                } LastBeat = t;\r
 \r
                switch (nTPat) {\r
@@ -332,13 +330,7 @@ public class Play extends DPat
                default:        return color(0,0,0);\r
                }\r
 \r
-               switch (pForm.Cur()) {\r
-                       case 0:         return color(0,0,c1c(1 - V.distance(Pn)/rad > .5?1:0));\r
-                       case 1:         return color(0,0,c1c(Pn.y < V.y ?1:0));\r
-                       case 2:         return color(0,0,c1c(1 - V.distance(Pn)/rad));\r
-\r
-                       default:        return color(0,0,c1c(Pn.y < V.y ?1:0));\r
-               }\r
+               return color(0,0,c1c(1 - V.distance(Pn)/rad));\r
        }\r
 }\r
 //----------------------------------------------------------------------------------------------------------------------------------\r
index 9ae6f1994e01cfdc4298ad8c2ca8b0d872d77ff9..9bc52185541638b619efa11955527ccd8f34eb4c 100644 (file)
@@ -113,10 +113,11 @@ public class DGlobals {
        MidiOutput      APCOut                  = null;
        MidiInput       APCIn                   = null,         OxygenIn                = null;
        DPat            CurPat                  = null;
+       int                     KeyPressed              = -1;
 
        
        float           Sliders[]               = new float [] {1,0,0,0,0,0,0,0};
-       String          SliderText[]    = new String[] {"Level", "SpinHue", "Spark", "Xwave", "Ywave", "Trails", "??", "??", "??"};
+       String          SliderText[]    = new String[] {"Level", "SpinHue", "Spark", "Xwave", "Ywave", "Trails", "Quant", "??", "??"};
        
        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);        }
@@ -126,12 +127,13 @@ public class DGlobals {
        Pick            GetPick (int i)                                         { return (Pick) CurPat.picks .get(i); }
        DParam          GetParam(int i)                                         { return (DParam) CurPat.params.get(i); }
 
-       float           _Dim            ()                                              { return Sliders[0]; }
+       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;
@@ -185,7 +187,8 @@ public class DGlobals {
                int row = note.getPitch(), col = note.getChannel();
                for (int i=0; i<CurPat.picks.size(); i++) if (GetPick(i).set(row, col))           return;
                for (int i=0; i<CurPat.bools.size(); i++) if (GetBool(i).set(row, col, true)) return;
-               //println("row: " + row + "  col:   " + col);
+               if (row == 52) { KeyPressed = col; return; }
+               println("row: " + row + "  col:   " + col);
        }
 }
 //----------------------------------------------------------------------------------------------------------------------------------
@@ -201,10 +204,11 @@ public class DPat extends SCPattern
        int             nPoint  , nPoints;
        xyz                     xyzJog = new xyz(), vT1 = new xyz(), vT2 = new xyz();
        xyz                     modmin;
-       
+
        float           NoiseMove       = random(10000);
-       DParam          pSharp, pQuantize, pSaturate;
-       DBool           pXsym, pYsym, pRsym, pXdup, pXtrip, pJog;
+       DParam          pRotX, pRotY, pRotZ, pSpin, pSharp, pSaturate, pTransX, pTransY;
+       
+       DBool           pXsym, pYsym, pRsym, pXdup, pXtrip, pJog, pKey;
        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)]); }
@@ -227,6 +231,7 @@ public class DPat extends SCPattern
                super.addParameter(P);
                params.add(P); return P;
        }
+
        Pick addPick(String name, int def, int _max, String[] desc) {
                Pick P          = new Pick(name, def, _max+1, nMaxRow, desc); 
                nMaxRow         = P.EndRow + 1;
@@ -236,15 +241,23 @@ public class DPat extends SCPattern
 
        DPat(GLucose glucose) {
                super(glucose);
-               pSharp          =       addParam("Shrp",  0 );
-               pQuantize       =       addParam("Qunt",  0 );
-               pSaturate       =       addParam("Sat" ,  .5);
+
+               pSharp          =       addParam("Shrp",  0);
+               pSaturate       =       addParam("Sat" , .5);
+               pTransX         =       addParam("TrnX", .5);
+               pTransY         =       addParam("TrnY", .5);
+               pRotX           =       addParam("RotX", .5);
+               pRotY           =       addParam("RotY", .5);
+               pRotZ           =       addParam("RotZ", .5);
+               pSpin           =       addParam("Spin", .5);
+
                nPoints         =       model.points.size();
                pXsym           =       new DBool("X-SYM", false, 49, 0);       bools.add(pXsym );
                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("JOGGER",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);
                mCtr            =       new xyz(mMax); mCtr.scale(.5);
@@ -264,13 +277,14 @@ public class DPat extends SCPattern
                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    = pQuantize.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;
@@ -293,6 +307,7 @@ public class DPat extends SCPattern
                for (Point p : model.points) { nPoint++;
                        P.set(p);
                        P.subtract(modmin);
+                       P.subtract(pTrans);
                        if (sprk > 0) { P.y += sprk*randctr(50); P.x += sprk*randctr(50); P.z += sprk*randctr(50); }
                        if (yWv > 0)    P.y += interpWv(p.x-modmin.x, yWaveNz);
                        if (xWv > 0)    P.x += interpWv(p.y-modmin.y, xWaveNz);
@@ -313,7 +328,7 @@ public class DPat extends SCPattern
                        colors[p.index] = color(
                                (hue(cNew) + zSpinHue) % 360,
                                saturation(cNew) + 100*(fSaturate*2-1),
-                               100 *  b * DG._Dim()
+                               100 *  b * DG._Level()
                        );
 
 //                     colors[p.index] = color(0,0, p.fx >= modmin.x && p.fy >= modmin.y && p.fz >= modmin.z &&
index 623b2c0ef7ff68462dacfc35fed84f1966eaccf7..68cc8328e7a7ff013ec29267bf8964592a7888c4 100644 (file)
--- a/_MIDI.pde
+++ b/_MIDI.pde
@@ -363,12 +363,17 @@ public class APC40MidiInput extends SCMidiInput {
        case 83:        EFF_flash       .trigger();                             break;  // Flash
                
        case 90:        lx.tempo.trigger(); Tap1 = getNow();    break;  // dan's dirty tapping mechanism
+
+    case 91: // play
+    case 95: // bank
+      midiEngine.setFocusedDeck(0);
+      break;
+
+    case 93: // rec
     case 94: // right bank
       midiEngine.setFocusedDeck(1);
       break;
-    case 95: // left bank
-      midiEngine.setFocusedDeck(0);
-      break;
+
     case 96: // up bank
       if (shiftOn) {
         glucose.incrementSelectedEffectBy(1);
@@ -398,8 +403,7 @@ public class APC40MidiInput extends SCMidiInput {
       lx.tempo.setBpm(lx.tempo.bpm() - (shiftOn ? 1 : .1));
       break;
 
-    case 91: // play
-    case 93: // rec
+    case 62: // Detail View
       releaseEffect = glucose.getSelectedEffect(); 
       if (releaseEffect.isMomentary()) {
         releaseEffect.enable();
@@ -408,7 +412,7 @@ public class APC40MidiInput extends SCMidiInput {
       }
       break;
 
-    case 92: // stop
+    case 63: // rec quantize
       glucose.getSelectedEffect().disable();
       break;
     }
@@ -426,14 +430,15 @@ public class APC40MidiInput extends SCMidiInput {
                }
                break;
 
-    case 93: // rec
+
+    case 63: // rec quantize
       if (releaseEffect != null) {
         if (releaseEffect.isMomentary()) {
           releaseEffect.disable();
         }
       }
       break;
-               
+
     case 98: // shift
       shiftOn = false;
        break;