More DPat Fixes
authorbb3dan <gitdan@citopia.com>
Tue, 24 Sep 2013 21:28:34 +0000 (17:28 -0400)
committerbb3dan <gitdan@citopia.com>
Tue, 24 Sep 2013 21:28:34 +0000 (17:28 -0400)
- Picks are now documented in the debug text
- APC knobs now sync up with code when you switch patterns

DanHorwitz.pde
DanUtil.pde

index 51b22cd22ee015a122e71b4f86d69c042aadd9a3..e8780db26473ad44a31197f7bb9c7a6efd08e98a 100755 (executable)
@@ -14,7 +14,7 @@ public class Pong extends DPat {
                addModulator(y  = new SinLFO(cRad, ydMax - cRad, 0)).trigger(); y.modulateDurationBy(dy);\r
                addModulator(z  = new SinLFO(cRad, zdMax - cRad, 0)).trigger(); z.modulateDurationBy(dz);\r
            pSize       = addParam      ("Size"                 , 0.4   );\r
-           pChoose = addPick   ("Animiation"   , 0     , 3     );\r
+           pChoose = addPick   ("Animiation"   , 0     , 3, new String[] {"Pong", "Ball", "Cone"}      );\r
        }\r
 \r
        void    StartRun(double deltaMs)        { cRad = xdMax*pSize.Val()/6; }\r
@@ -51,9 +51,10 @@ public class Noise extends DPat
 \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, 4);    pChoose         = addPick("Animation", 1, 6);\r
+               pRotZ   = addParam("RotZ"        , .5 );        pSpeed          = addParam("Fast", .55);\r
+               pDensity= addParam("Dens"        , .5);\r
+               pSymm   = addPick("Symmetry" , 0, 4, new String[] {"None", "X", "Y", "Radial"}  );\r
+               pChoose = addPick("Animation", 1, 6, new String[] {"Drip", "Cloud", "Rain", "Fire", "Machine", "Spark"} );\r
        }\r
 \r
        void StartRun(double deltaMs) {\r
@@ -122,15 +123,16 @@ public class Play extends DPat
 \r
        Play(GLucose glucose) {\r
                super(glucose);\r
-           pAmp                = addParam("Amp" , .2);\r
                pRotX           = addParam("RotX", .5);\r
                pRotY           = addParam("RotY", .5);\r
                pRotZ           = addParam("RotZ", .5);\r
-           pRad                = addParam("Rad" , .1           );\r
-               pTimePattern= addPick ("TimePattern", 0 , 5             );\r
-               pTempoMult      = addPick ("TimeMult"   , 0 , 6         );\r
-               pShape          = addPick ("Shape"              , 0 , 16        );\r
-               pForm           = addPick ("Form"               , 0 , 3         );\r
+           pAmp                = addParam("Amp" , .2);\r
+           pRad                = addParam("Rad"        , .1            );\r
+               pTempoMult      = addPick ("TMult"      , 0 , 6         , new String[] {"1x", "2x", "4x", "8x", "16x", "Rand"   }       );\r
+               pTimePattern= addPick ("TPat"   , 0 , 5         , new String[] {"Bounce", "?", "Roll", "Quant", "Accel" }       );\r
+               pShape          = addPick ("Shape"      , 0 , 10        , new String[] {"Line", "Tap", "V", "RandV", "Pyramid",\r
+                                                                                                                                       "Wings", "W2", "Sphere", "Cone", "Noise" }      );\r
+               pForm           = addPick ("Form"       , 0 , 3         , new String[] {"Bar", "Volume", "Fade"                                 }       );\r
        }\r
 \r
        float   t,a;\r
@@ -147,7 +149,7 @@ public class Play extends DPat
                TCos    .set(cos(Theta.x), cos(Theta.y), cos(Theta.z));\r
 \r
                if (t<LastMeasure) { CurRandTempo = int(random(4)); } LastMeasure = t;\r
-               \r
+\r
                switch (pTempoMult.Cur()) {\r
                        case 0:         t = t;                                                          break;\r
                        case 1:         t = (t*2. )%1.;                                         break;\r
@@ -167,8 +169,9 @@ public class Play extends DPat
                        case 4:         t = t*t*t;                                                      break;\r
                }\r
 \r
-               cMid            = cPrev.interpolate(t,cCur);\r
-               cMidNorm        = cMid.setNorm();\r
+               \r
+               cMid                            = cPrev.interpolate(t,cCur);\r
+               cMidNorm                        = cMid.setNorm();\r
        }\r
 \r
        color CalcPoint(xyz Px) {\r
index 16e19359ed4c2412fd2e54621b1f84c2c2a2f397..cb40292cd3e84c4f86c07bd5709a06aeda249141 100644 (file)
@@ -7,14 +7,15 @@ boolean btwn  (int            a,int    b,int          c)              { return a >= b && a <= c;      }
 boolean btwn  (double  a,double b,double       c)              { return a >= b && a <= c;      }
 
 public class Pick {
-       Pick    (String label, int _Def, int _Max)      { NumPicks=_Max; Default = _Def; tag=label;     }
+       Pick    (String label, int _Def, int _Max,      String d[])     { NumPicks=_Max; Default = _Def; tag=label; Desc = d; }
        int             Cur()                                                           { return (CurRow-StartRow)*NumApcCols + CurCol;         }
        int     NumPicks, Default, CurRow, CurCol, StartRow, EndRow;
-       String  tag;
+       String  Desc[]  ;       
+       String  tag             ;
 }
 //----------------------------------------------------------------------------------------------------------------------------------
 public class _DhP extends BasicParameter {
-       double  dflt;   
+       double  dflt;
        _DhP    (String label, double value)            { super(label,value); dflt=value;               }
        void    Set                     (double value)                  { super.updateValue(value);                             }
        void    reset           ()                                              { super.updateValue(dflt);                              }
@@ -55,7 +56,6 @@ public class xyz {    float x,y,z;
                if (t.y != 0) { z = z*tcos.y - x*tsin.y; x = z*tsin.y + x*tcos.y; }
                if (t.z != 0) { x = x*tcos.z - y*tsin.z; y = x*tsin.z + y*tcos.z; }
                                          { x += o.x; y += o.y; z += o.z; }
-
        }
 
        xyz             setRand ()                                              { return new xyz ( random(xdMax), random(ydMax), random(zdMax));                }
@@ -79,7 +79,9 @@ public class DGlobals {
 
        int     mapRow   (int a)                                        { return btwn(a,53,57) ? a-53 : a;                      }
        int     unmapRow (int a)                                        { return btwn(a,0 , 4) ? a+53 : a;                      }
+
        void    SetLight (int row, int col, int clr){ if (APCOut != null) APCOut.sendNoteOn(col, unmapRow(row), clr); }
+       void    SetKnob  (int cc , int chan,int val){ if (APCOut != null) APCOut.sendController(cc , chan                 , val); }
 
        float   _Trails         ()                                              { return Sliders[0]; }
        float   _Dim            ()                                              { return Sliders[1]; }
@@ -109,11 +111,12 @@ public class DGlobals {
                Text1  += " ZSym:  " + (_ZSym ? "ON" : "OFF") + "    ";
                Text1  += " RSym:  " + (_RSym ? "ON" : "OFF") + "    ";
                for (int i=0; i<CurPat.picks.size(); i++) {
-                       Pick P = (Pick)CurPat.picks.get(i); Text1 += P.tag + ": " + P.Cur() + "    ";
+                       Pick P = (Pick)CurPat.picks.get(i); Text1 += P.tag + ": " + P.Desc[P.Cur()] + "    ";
                }
 
                Text2  = "SLIDERS: ";
-               for (int i=0; i<8; i++) if (SliderText[i] != "") { Text2 += SliderText[i] + ": " + Sliders[i] + "     "; }
+               for (int i=0; i<8; i++) if (SliderText[i] != "") {
+                       Text2 += SliderText[i] + ": " + int(100*Sliders[i]) + "     "; }
 
                uiDebugText.setText(Text1, Text2);
        }
@@ -138,6 +141,8 @@ public class DGlobals {
 
        void    UpdateLights() {
                for (int i=0; i<NumApcRows      ; i++) for (int j=0; j<NumApcCols; j++) SetLight(i, j, 0);
+               for (int i=48;i< 56             ; i++) SetKnob(0, i, 0);
+               for (int i=16;i< 20             ; i++) SetKnob(0, i, 0);
                for (int i=0; i<CurPat.picks.size()     ; i++) {
                        Pick P = (Pick)CurPat.picks.get(i); SetLight(P.CurRow, P.CurCol, 3);
                }
@@ -145,6 +150,11 @@ public class DGlobals {
                SetLight(83, 0, _YSym ? 3 : 0);
                SetLight(84, 0, _ZSym ? 3 : 0);
                SetLight(85, 0, _RSym ? 3 : 0);
+               
+               for (int i=0; i<CurPat.paramlist.size(); i++) {
+                       _DhP Param = (_DhP)CurPat.paramlist.get(i);
+                       SetKnob ( 0, i<=55 ? 48+i : 16 + i - 8, int(Param.Val()*127) );
+               }
        }
        
        double Tap1 = 0;
@@ -180,7 +190,7 @@ public class DGlobals {
                                if (!btwn((row-P.StartRow)*NumApcCols + col,0,P.NumPicks-1)     ) continue;
                                P.CurRow=row; P.CurCol=col; return;
                        }
-                       println(row + " " + col);                       
+                       //println(row + " " + col); 
                }
        }
 }
@@ -192,13 +202,12 @@ public class DPat extends SCPattern
        int                     nMaxRow         = 0;
        float           zSpinHue        = 0;
        int             nPoint  , nPoints;
-       xyz                     xyzHalf          = new xyz(.5,.5,.5),
-                               xyzdMax,
-                               xyzMid;
+       xyz                     xyzHalf         = new xyz(.5,.5,.5),
+                               xyzdMax         = new xyz(),
+                               xyzMid          = new xyz();
        
        float           NoiseMove       = random(10000);
-       _DhP            pSharp;
-
+       _DhP            pSharp, pRotX, pRotY, pRotZ;
        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 int(100*constrain(a,0,1));                     }
        float           CalcCone (xyz v1, xyz v2, xyz c)        { return degrees( acos ( v1.minus(c).dot(v2.minus(c)) /
@@ -215,8 +224,8 @@ public class DPat extends SCPattern
                paramlist.add(P); return P;
        }
                
-       Pick addPick(String name, int def, int nmax) {
-               Pick P          = new Pick(name, def, nmax); 
+       Pick addPick(String name, int def, int nmax, String[] desc) {
+               Pick P          = new Pick(name, def, nmax, desc); 
                P.StartRow      = nMaxRow;
                P.EndRow        = P.StartRow + int((nmax-1) / NumApcCols);
                nMaxRow         = P.EndRow + 1;
@@ -229,7 +238,7 @@ public class DPat extends SCPattern
        DPat(GLucose glucose) {
                super(glucose);
                DG.Init();
-               pSharp          =  addParam("Shrp", 0);
+               pSharp          =  addParam("Shrp"      ,  0);
                nPoints         =  model.points.size();
                xdMax           =  model.xMax;
                ydMax           =  model.yMax;
@@ -246,7 +255,7 @@ public class DPat extends SCPattern
                xyz P                   = new xyz();
                float modhue    = DG._ModHue  ()==0 ? 0 : DG._ModHue  ()*360;
                float fSharp    = 1/(1.01-pSharp.Val());
-               
+
                DG.SetText();
                nPoint  = 0;
                for (Point p : model.points)    { nPoint++;