dpat updates
authorbb3dan <gitdan@citopia.com>
Fri, 27 Sep 2013 21:52:08 +0000 (17:52 -0400)
committerbb3dan <gitdan@citopia.com>
Fri, 27 Sep 2013 21:52:12 +0000 (17:52 -0400)
DanHorwitz.pde
DanUtil.pde

index a8c013618783f5cd8f62bb934c9268b51a0b9238..0f987bf66706dd86557ccb0cd954b42ca615cff8 100755 (executable)
@@ -61,7 +61,7 @@ public class Noise extends DPat
                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", 1, 5, new String[] {"Drip", "Cloud", "Rain", "Fire", "Machine", "Spark"} );\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
@@ -111,6 +111,14 @@ public class Noise extends DPat
                color c = 0;\r
                P.RotateZ(mCtr, zSin, zCos);\r
                \r
+               if (CurAnim == 6 || CurAnim == 7) {\r
+                       P.setNorm();\r
+                       return color(0,0, 100 * (\r
+                                                       constrain(1-50*(1-pDensity.Val())*abs(P.y-sin(zTime*10  + P.x*(300))*.5 - .5),0,1) + \r
+                       (CurAnim == 7 ? constrain(1-50*(1-pDensity.Val())*abs(P.x-sin(zTime*10  + P.y*(300))*.5 - .5),0,1) : 0))\r
+                       );\r
+               }                       \r
+                       \r
                if (iSymm == XSym && P.x > mMax.x/2) P.x = mMax.x-P.x;\r
                if (iSymm == YSym && P.y > mMax.y/2) P.y = mMax.y-P.y;\r
 \r
@@ -149,11 +157,15 @@ public class Play extends DPat
                void    set()                   {       prvA    = dstA;         dstA    = random(2*PI);         prvA = fixAngle(prvA, dstA);\r
                                                                        prvR    = dstR;         dstR    = random(mCtr.y);                                                                       }\r
        }\r
+\r
        int             nBeats  =       0;\r
        DParam  pAmp, pRadius, pBounce;\r
        DParam  pRotX, pRotY, pRotZ;\r
 \r
        float   t,amp,rad,bnc;\r
+       \r
+       ArrayList<rWave> waves = new ArrayList<rWave>(10);\r
+       \r
        rAngle  a1 = new rAngle(), a2 = new rAngle(),\r
                        a3 = new rAngle(), a4 = new rAngle();\r
        xyz             cPrev   = new xyz(), cRand      = new xyz(),\r
@@ -177,17 +189,32 @@ public class Play extends DPat
                pBounce         = addParam("Bnc"        , .2    );\r
            pAmp                = addParam("Amp"        , .2    );\r
                pTempoMult      = addPick ("TMult"      , 0 , 5         , new String[] {"1x", "2x", "4x", "8x", "16x", "Rand"   }       );\r
-               pTimePattern= addPick ("TPat"   , 6 , 7         , new String[] {"Bounce", "Sin", "Roll", "Quant", "Accel", "Deccel", "Slide", "Rand"}   );\r             pShape          = addPick ("Shape"      , 13, 15        , new String[] {"Line", "Tap", "V", "RandV",\r
+               pTimePattern= addPick ("TPat"   , 6 , 7         , new String[] {"Bounce", "Sin", "Roll", "Quant", "Accel", "Deccel", "Slide", "Rand"}   );\r             pShape          = addPick ("Shape"      , , 15        , new String[] {"Line", "Tap", "V", "RandV",\r
                                                                                                                                        "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
+               float v0, a0, x0, t,damp,a;\r
+               boolean bDone=false;\r
+               final float len=8;\r
+               rWave(float _x0, float _a0, float _v0, float _damp) { x0=_x0*len; a0=_a0; v0=_v0; t=0; damp = _damp; }\r
+               void move(double deltaMs) {\r
+                       t += deltaMs*.001;\r
+                       if (t>4) bDone=true;\r
+               }\r
+               float val(float _x) {\r
+                       _x*=len;\r
+                       float dist = t*v0 - abs(_x-x0);\r
+                       if (dist<0) { a=1; return 0; }\r
+                       a  = a0*exp(-dist*damp) * exp(-abs(_x-x0)/(.2*len)); // * max(0,1-t/dur)\r
+                       return  -a*sin(dist);\r
+               }\r
+       }\r
 \r
-float zTime = random(1000);\r
        void StartRun(double deltaMs) {\r
-               zTime += deltaMs*.001; zTime = zTime % 1000.;\r
                t       = lx.tempo.rampf();\r
                amp = pAmp.Val();\r
                rad     = pRadius.getValuef();\r
@@ -213,9 +240,20 @@ float zTime = random(1000);
                        case 4:         t = (t*16.)%1.;                                         break;\r
                }\r
 \r
+               int i=0; while (i< waves.size()) {\r
+                       rWave w = waves.get(i);\r
+                       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
+                       waves.add(new rWave(\r
+                                               random(1),              // location\r
+                                               bnc*10,                 // bounciness\r
+                                               7,                              // velocity\r
+                                               2*(1-amp)));    // dampiness\r
+                       if (waves.size() > 5) waves.remove(0);\r
                } LastBeat = t;\r
 \r
                switch (nTPat) {\r
@@ -230,7 +268,6 @@ float zTime = random(1000);
                \r
                cMid.set                (cPrev);        cMid.interpolate        (t,cRand);\r
                cMidNorm.set    (cMid);         cMidNorm.setNorm();\r
-\r
                a1.move(); a2.move(); a3.move(); a4.move();\r
        }\r
 \r
@@ -288,14 +325,10 @@ float zTime = random(1000);
                case 12:        return color(100 + noise(Pn.x,Pn.y,Pn.z + (NoiseMove+50000)/1000.)*200,\r
                                                85,c1c(Pn.y < noise(Pn.x + NoiseMove/2000.,Pn.z)*(1+amp)-amp/2.-.1 ? 1 : 0));   // noise\r
 \r
-               case 13:        V.set(Pn.x, map(\r
-                                                                       sin( zTime*3.7  + Pn.x*2.0*PI)\r
-                                                               +       sin( zTime*4.2  + Pn.x*1.7*PI)\r
-                                                               +       sin( -zTime*4.7  + Pn.x*2.1*PI)\r
-                                                               +       sin( -zTime*5.2  + Pn.x*1.5*PI)\r
-                                                               ,-2,2,.2,.8), Pn.z); break;\r
-                                               \r
-                                               \r
+               case 13:        float y=0; for (rWave w : waves) y += .5*w.val(Pn.x);\r
+                                       V.set(Pn.x, .7+y, Pn.z);\r
+                                       break;\r
+\r
                default:        return color(0,0,0);\r
                }\r
 \r
index f6b3a815814e66af1cdfc4882eb9cecfc30c6005..9ae6f1994e01cfdc4298ad8c2ca8b0d872d77ff9 100644 (file)
@@ -114,6 +114,7 @@ public class DGlobals {
        MidiInput       APCIn                   = null,         OxygenIn                = null;
        DPat            CurPat                  = null;
 
+       
        float           Sliders[]               = new float [] {1,0,0,0,0,0,0,0};
        String          SliderText[]    = new String[] {"Level", "SpinHue", "Spark", "Xwave", "Ywave", "Trails", "??", "??", "??"};
        
@@ -154,7 +155,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<5; i++)                                   Text2 += SliderText[i]  + ": " + round(100*Sliders[i])  + "   ";
+               for (int i=0; i<8; i++)                                   Text2 += SliderText[i]  + ": " + round(100*Sliders[i])  + "   ";
                uiDebugText.setText(Text1, Text2);
        }
 
@@ -190,7 +191,7 @@ public class DGlobals {
 //----------------------------------------------------------------------------------------------------------------------------------
 public class DPat extends SCPattern
 {
-       ArrayList       picks           = new ArrayList();
+       ArrayList       picks           = new ArrayList(); // should be ArrayList<Pick> picks = new ArrayList<Pick>();
        ArrayList       params          = new ArrayList();
        ArrayList       bools           = new ArrayList();
        int                     nMaxRow         = 53;