-class SineSphere extends SCPattern {
+class SineSphere extends DPat {
float modelrad = sqrt((model.xMax)*(model.xMax) + (model.yMax)*(model.yMax) + (model.zMax)*(model.zMax));
private final SinLFO rs = new SinLFO(0, 180, 5000);
private final SinLFO noisey = new SinLFO(modelrad/8.0, modelrad/4.0, 2300);
spherys[2] = new Sphery(.75*model.xMax, model.yMax/2, model.zMax/2, modelrad/20, modelrad/10, 2000);
}
- public void run(int deltaMs) {
- float rsv = rs.getValuef();
- float noiseyv = noisey.getValuef();
- float bandv = band.getValuef();
-
- spherys[1].run(deltaMs);
- spherys[2].run(deltaMs);
+
+ float rsv, noiseyv, bandv;
+
+ public void StartRun(int deltaMs) {
+ rsv = rs.getValuef();
+ noiseyv = noisey.getValuef();
+ bandv = band.getValuef();
- for (Point p: model.points) {
-
+ spherys[1].run(deltaMs);
+ spherys[2].run(deltaMs);
+ }
+
+
+ color CalcPoint(xyz Px) {
+
color c = 0;
- c = blendColor(c, spherys[2].spheryvalue(p.fx, p.fy, p.fz, .75*model.xMax, model.yMax/2, model.zMax/2), ADD);
- c = blendColor(c, spherys[1].spheryvalue(p.fx, p.fy, p.fz, model.xMax/4, model.yMax/4, model.zMax/2), ADD);
- float distfromcenter = dist(p.fx, p.fy, p.fz, model.xMax/2, model.yMax/2, model.zMax/2);
+ c = blendColor(c, spherys[2].spheryvalue(Px.x, Px.y, Px.z, .75*model.xMax, model.yMax/2, model.zMax/2), ADD);
+ c = blendColor(c, spherys[1].spheryvalue(Px.x, Px.y, Px.z, model.xMax/4, model.yMax/4, model.zMax/2), ADD);
+ float distfromcenter = dist(Px.x, Px.y, Px.z, model.xMax/2, model.yMax/2, model.zMax/2);
int distint = floor(distfromcenter);
c = blendColor(c, color(
- constrain( p.fx , 0, 360),
+ constrain( Px.x , 0, 360),
constrain( distfromcenter, 20, 80),
max(0, 100 - 10*abs(distfromcenter - noiseyv ) )
),
ADD);
-
- colors[p.index]=c;
+ return c;
}
- }
-}
+ }
+
}
}
-}
\ No newline at end of file
+}
-//----------------------------------------------------------------------------------------------------------------------------------
-static MidiOutput midiout;
-int nNumRows = 6, nNumCols = 8;
-boolean btwn (int a,int b,int c) { return a >= b && a <= c; }
-
-public class _P extends BasicParameter {
- _P(String label, double value) { super(label,value); }
- void updateValue (double value) { super.updateValue(value); }
- float Val () { return getValuef(); }
-}
-
-public class Pick {
- Pick (String label, int _Def, int _Max) { Picks=_Max; Default = _Def; tag=label; }
- int Cur() { return (CurCol-StartCol)*nNumRows + CurRow; }
- int Picks, Default, CurRow, CurCol, StartCol, EndCol;
- String tag;
-}
-//----------------------------------------------------------------------------------------------------------------------------------
-float xMax,yMax,zMax;
-public class xyz { float x,y,z;
- xyz() {x=y=z=0;}
- xyz(Point p ) {x=p.fx ; y=p.fy; z=p.fz;}
- xyz(float _x,float _y,float _z) {x=_x ; y=_y ; z=_z ;}
- void set(float _x,float _y,float _z) {x=_x ; y=_y ; z=_z ;}
- float distance(xyz b) {return dist(x,y,z,b.x,b.y,b.z); }
- float dot (xyz b) {return x*b.x + y*b.y + z*b.z; }
- xyz minus (xyz b) {return new xyz(x-b.x,y-b.y,z-b.z); }
- xyz plus (xyz b) {return new xyz(x+b.x,y+b.y,z+b.z); }
- xyz plus (float b) {return new xyz(x+b ,y+b ,z+b ); }
- xyz over (xyz b) {return new xyz(x/b.x,y/b.y,z/b.z); }
- xyz times (float b) {return new xyz(x*b ,y*b ,z*b ); }
-
- xyz RotateX (xyz o, float a) { return new xyz ( x,
- cos(a)*(y-o.y) - sin(a)*(z-o.z) + o.y,
- sin(a)*(y-o.y) + cos(a)*(z-o.z) + o.z); }
-
- xyz RotateY (xyz o, float a) { return new xyz ( cos(a)*(x-o.x) - sin(a)*(z-o.z) + o.x,
- y,
- sin(a)*(x-o.x) + cos(a)*(z-o.z) + o.z); }
-
- xyz RotateZ (xyz o, float a) { return new xyz ( cos(a)*(x-o.x) - sin(a)*(y-o.y) + o.x,
- sin(a)*(x-o.x) + cos(a)*(y-o.y) + o.y,
- z ); }
-
-
- xyz setRand () { return new xyz ( random(xMax), random(yMax), random(zMax)); }
- xyz setNorm () { return new xyz ( x / xMax, y / yMax, z / zMax); }
-
-
- float interp (float a, float b, float c) { return (1-a)*b + a*c; }
- xyz interpolate(float i, xyz d) { return new xyz ( interp(i,x,d.x), interp(i,y,d.y), interp(i,z,d.z)); }
-}
-//----------------------------------------------------------------------------------------------------------------------------------
-public class hsb { float h,s,b;
- hsb(color c) { h=hue(c); s=saturation(c); b=brightness(c); }
- color Out() { return color(h%360.,constrain(s,0,100),constrain(b,0,100)); }
-}
-
-public class DPat extends SCPattern
-{
- float zSpinHue;
- xyz xyzMax, xyz0, xyzMid, xyzHalf;
-
- ArrayList picks = new ArrayList();
- int nMaxCol = 0;
- boolean bIsActive = false;
- float Dist (xyz a, xyz b) { return dist(a.x,a.y,a.z,b.x,b.y,b.z); }
- float c1c (float a) { return 100*constrain(a,0,1); }
- int mapRow (int a) { return a == 52 ? 5 : btwn(a,53,57) ? a-53 : a; }
- int unmapRow (int a) { return a == 5 ? 52 : btwn(a,0 , 4) ? a+53 : a; }
- void SetLight (int row, int col, int clr){ if (midiout != null) midiout.sendNoteOn(col, unmapRow(row), clr); }
- void keypad (int row, int col) {}
- void onInactive() { bIsActive=false; }
- void onActive () { bIsActive=true;
- zSpinHue = 0;
- for (int i=0; i<nNumRows ; i++) for (int j=0; j<nNumCols; j++) SetLight(i, j, 0);
- for (int i=0; i<picks.size(); i++) UpdateLights((Pick)picks.get(i));
- }
- void StartRun(int deltaMs) {}
- color CalcPoint(Point p) { return color(0,0,0); }
- float CalcCone (xyz v1, xyz v2, xyz c) {
- return degrees( acos ( v1.minus(c).dot(v2.minus(c)) / (sqrt(v1.minus(c).dot(v1.minus(c))) * sqrt(v2.minus(c).dot(v2.minus(c))) ) ));
- }
-
-
- void run(int deltaMs) {
- StartRun(deltaMs);
- zSpinHue += s_SpinHue ()*deltaMs*.05;
- for (Point p : model.points) {
- hsb cOld = new hsb(colors[p.index]);
- hsb cNew = new hsb (CalcPoint(p));
- if (s_Trails ()>0) cNew.b = max(cNew.b,cOld.b - (1-s_Trails()) * deltaMs);
- if (s_Dim ()>0) cNew.b *= 1-s_Dim ();
- if (s_Saturate ()>0) cNew.s += s_Saturate()*100;
- if (s_SpinHue ()>0) cNew.h += zSpinHue;
- if (s_ModHue ()>0) cNew.h += s_ModHue()*360;
- colors[p.index] = cNew.Out();
- }
- }
-
- void controllerChangeReceived(rwmidi.Controller cc) {
- if (cc.getCC() == 7 && btwn(cc.getChannel(),0,7)) Sliders[cc.getChannel()] = 1.*cc.getValue()/127.;
- }
-
- float Sliders[] = new float[] {0,0,0,0,0,0,0,0};
- float s_Trails () { return Sliders[0]; }
- float s_Dim () { return Sliders[1]; }
- float s_Saturate () { return Sliders[2]; }
- float s_SpinHue () { return Sliders[3]; }
- float s_ModHue () { return Sliders[4]; }
-
- DPat(GLucose glucose) {
- super(glucose);
- xMax = model.xMax; yMax = model.yMax; zMax = model.zMax;
- xyzMax = new xyz(xMax,yMax,zMax);
- xyzMid = new xyz(xMax/2, yMax/2, zMax/2);
- xyzHalf = new xyz(.5,.5,.5);
- xyz0 = new xyz(0,0,0);
- for (MidiInputDevice input : RWMidi.getInputDevices ()) { if (input.toString().contains("APC")) input .createInput (this);}
- for (MidiOutputDevice output : RWMidi.getOutputDevices()) {
- if (midiout == null && output.toString().contains("APC")) midiout = output.createOutput();
- }
- }
-
- void UpdateLights(Pick P) {
- if (P==null) return;
- for (int i=0; i<nNumRows; i++) for (int j=P.StartCol; j<=P.EndCol; j++) SetLight(i, j, 0);
- SetLight(P.CurRow, P.CurCol, 3);
- }
-
- Pick GetPick(int row, int col) {
- for (int i=0; i<picks.size(); i++) { Pick P = (Pick)picks.get(i);
- if (!btwn(col,P.StartCol,P.EndCol) ) continue;
- if (!btwn(row,0,nNumRows-1) ) continue;
- if (!btwn((col-P.StartCol)*nNumRows + row,0,P.Picks-1) ) continue;
- return P;
- }
- return null;
- }
-
- void noteOffReceived(Note note) { if (!bIsActive) return;
- int row = mapRow(note.getPitch()), col = note.getChannel();
- UpdateLights(GetPick(row,col));
- }
-
- void noteOnReceived (Note note) { if (!bIsActive) return;
- int row = mapRow(note.getPitch()), col = note.getChannel();
- Pick P = GetPick(row,col);
- if (P != null) { P.CurRow=row; P.CurCol=col;} else keypad(row, col);
- }
-
- Pick addPick(String name, int def, int nmax) {
- Pick P = new Pick(name, def, nmax);
- P.StartCol = nMaxCol;
- P.EndCol = P.StartCol + int((nmax-1) / nNumRows);
- nMaxCol = P.EndCol + 1;
- P.CurRow = def % nNumRows;
- P.CurCol = P.StartCol + def/nNumRows;
- picks.add(P);
- return P;
- }
-}
-//----------------------------------------------------------------------------------------------------------------------------------
-public class Pong extends DPat {
- SinLFO x,y,z,dx,dy,dz;
- float cRad; _P pSize;
- Pick pChoose;
-
- Pong(GLucose glucose) {
- super(glucose);
- cRad = xMax/15;
- addModulator(dx = new SinLFO(6000, 500, 30000 )).trigger();
- addModulator(dy = new SinLFO(3000, 500, 22472 )).trigger();
- addModulator(dz = new SinLFO(1000, 500, 18420 )).trigger();
- addModulator(x = new SinLFO(cRad, xMax - cRad, 0)).trigger(); x.modulateDurationBy(dx);
- addModulator(y = new SinLFO(cRad, yMax - cRad, 0)).trigger(); y.modulateDurationBy(dy);
- addModulator(z = new SinLFO(cRad, zMax - cRad, 0)).trigger(); z.modulateDurationBy(dz);
- addParameter(pSize = new _P("Size", 0.4 ));
- pChoose = addPick("Anim", 0 , 3);
- }
-
- color Calc(xyz p, xyz v) {
- switch(pChoose.Cur()) {
- case 0: return color(0,0,c1c(1 - min(v.distance(p), v.distance(xyzMax.minus(p)))*.5/cRad)); // balls
- case 1: return color(0,0,c1c(1 - v.distance(p)*.5/cRad)); // ball
- case 2: return color(0,0,c1c(1 - CalcCone(p,v,new xyz(xMax/2,0,zMax/2)) * max(.02,.45-pSize.Val()))); // spot
- }
- return color(0,0,0);
- }
-
- void StartRun(int deltaMs) { cRad = xMax*pSize.Val()/6; }
- color CalcPoint(Point p) { return Calc(new xyz(p), new xyz(x.getValuef(), y.getValuef(), z.getValuef())); }
-}
-//----------------------------------------------------------------------------------------------------------------------------------
-public class NDat {
- float xz, yz, zz, hue, sat, speed, angle, den, sharp;
- float xoff,yoff,zoff;
- NDat (float _hue, float _sat, float _xz, float _yz, float _zz, float _sharp, float _den, float _speed, float _angle) {
- hue=_hue; sat=_sat; xz=_xz; yz=_yz; zz =_zz; sharp=_sharp; den=_den; speed=_speed; angle=_angle;
- xoff = random(100e3); yoff = random(100e3); zoff = random(100e3);
- }
-}
-
-public class Noise extends DPat
-{
- int CurAnim = -1, numAnims = 6;
- float zTime = random(10000), zSpin=0;
- float rtime = 0, ttime = 0, transAdd=0;
- int XSym=1,YSym=2,XyzSym=3,RadSym=4;
-
- ArrayList noises = new ArrayList();
- _P pSpeed, pSharp, pDensity, pSpin;
- Pick pChoose, pSymm;
-
- Noise(GLucose glucose) {
- super(glucose);
- addParameter(pSpin = new _P("Spin", .5 )); addParameter(pSpeed = new _P("Fast" , .55));
- addParameter(pSharp = new _P("Shrp", .5 )); addParameter(pDensity = new _P("Dens" , .5 ));
- pSymm = addPick("Symm", 0, 5);
- pChoose = addPick("Anim", 0, 6);
- }
-
- void StartRun(int deltaMs) {
- zTime += deltaMs*(pSpeed.Val()-.5)*.002 ;
- zSpin += deltaMs*(pSpin .Val()-.5)*.01 ;
- rtime += deltaMs;
- transAdd = 1*(1 - constrain(rtime - ttime,0,1000)/1000);
-
- if (pChoose.Cur() != CurAnim) {
- noises.clear(); CurAnim = pChoose.Cur(); ttime = rtime;
- switch(CurAnim) {
- // hue sat xz yz zz srhp den mph angle
- case 0: noises.add(new NDat(0 ,0 ,75 ,75 ,150,1 ,45 ,3 ,0 )); break; // drip
- case 1: noises.add(new NDat(0 ,0 ,100,100,200,0 ,45 ,3 ,180)); break; // clouds
- case 2: noises.add(new NDat(0 ,0 ,2 ,400,2 ,.5 ,40 ,3 ,0 )); break; // rain
- case 3: noises.add(new NDat(40 ,100,100,100,200,0 ,30 ,1 ,180));
- noises.add(new NDat(0 ,100,100,100,200,0 ,30 ,5 ,180)); break; // fire 1
- case 4: noises.add(new NDat(0 ,100,40 ,40 ,40 ,.5 ,35 ,2.5,180));
- noises.add(new NDat(20 ,100,40 ,40 ,40 ,.5 ,35 ,4 ,0 ));
- noises.add(new NDat(40 ,100,40 ,40 ,40 ,.5 ,35 ,2 ,90 ));
- noises.add(new NDat(60 ,100,40 ,40 ,40 ,.5 ,35 ,3 ,-90)); break; // machine
- case 5: noises.add(new NDat(0 ,100,400,100,2 ,.5 ,35 ,3 ,225));
- noises.add(new NDat(20 ,100,400,100,2 ,.5 ,35 ,2.5,45 ));
- noises.add(new NDat(40 ,400,100,100,2 ,.5 ,35 ,2 ,135));
- noises.add(new NDat(60 ,400,100,100,2 ,.5 ,35 ,1.5,-45)); break; // spark
- }
- }
- }
-
- color CalcPoint(Point p) {
- color c = color(0,0,0);
- int symm = pSymm.Cur();
- for (int i=0;i<noises.size(); i++) {
- xyz v = new xyz(p).RotateZ(xyzMid,zSpin);
-
- if ((symm == XSym || symm == XyzSym) && v.x > xMax/2) v.x = xMax-v.x;
- if ((symm == YSym || symm == XyzSym) && v.y > yMax/2) v.y = yMax-v.y;
- if (( symm == XyzSym) && v.z > zMax/2) v.z = zMax-v.z;
-
- NDat n = (NDat) noises.get(i);
- float deg = radians(n.angle + (symm==XyzSym?45:0));
- float zx = zTime * n.speed * sin(deg),
- zy = zTime * n.speed * cos(deg),
- sharp = 1/constrain(2-n.sharp - 2*pSharp.Val(),0,1);
-
- float b = (symm==RadSym ? noise(zTime*n.speed+n.xoff-Dist(v,xyzMid)/n.xz)
- : noise(v.x/n.xz+zx+n.xoff,v.y/n.yz+zy+n.yoff,v.z/n.zz+n.zoff))
- *1.8-.4 + n.den/100 + pDensity.Val() -1;
-
- b += n.den/100 + pDensity.Val() -1;
- b = b < .5 ? pow(b,sharp) : 1-pow(1-b,sharp);
- b += transAdd;
- c = blendColor(c,color(n.hue,n.sat,c1c(b)),ADD);
- }
- return c;
- }
-}
-//----------------------------------------------------------------------------------------------------------------------------------
-public class Play extends DPat
-{
- int nBeats = 0;
- _P pAmp, pRotX, pRotY, pRotZ, pRad;
- Pick pTimePattern, pTempoMult, pShape;
-
- Play(GLucose glucose) {
- super(glucose);
- addParameter(pAmp = new _P("Amp" , .2 ));
- addParameter(pRotX = new _P("RotX", 0 ));
- addParameter(pRotY = new _P("RotY", 0 ));
- addParameter(pRotZ = new _P("RotZ", 0 ));
- addParameter(pRad = new _P("Rad" , .1 ));
-
- pTimePattern = addPick("TPat", 0 , 5 );
- pTempoMult = addPick("TMul", 5 , 6 );
- pShape = addPick("Shap", 8 , 10 );
-
- lx.tempo.setBpm(30);
- }
-
- float t,a;
- xyz cPrev = new xyz(), cCur = new xyz(), cMid = new xyz(), cMidNorm;
- float LastBeat=3, LastMeasure=3;
- int CurRandTempo = 1;
-
- void StartRun(int deltaMs) {
- t = lx.tempo.rampf();
- a = pAmp.Val();
-
- if (t<LastMeasure) { CurRandTempo = int(random(4)); } LastMeasure = t;
-
- switch (pTempoMult.Cur()) {
- case 0: t = t; break;
- case 1: t = (t*2. )%1.; break;
- case 2: t = (t*4. )%1.; break;
- case 3: t = (t*8. )%1.; break;
- case 4: t = (t*16.)%1.; break;
- case 5: t = (t*pow(2,CurRandTempo))%1.; break;
- }
-
- if (t<LastBeat) { cPrev = cCur; cCur = cCur.setRand(); } LastBeat = t;
-
- switch (pTimePattern.Cur()) {
- case 0: t = sin(PI*t); break;
- case 1: t = norm(sin(2*PI*(t+PI/2)),-1,1); break;
- case 2: t = t; break;
- case 3: t = constrain(int(t*8)/7.,0,1); break;
- case 4: t = t*t*t; break;
- }
-
- cMid = cPrev.interpolate(t,cCur);
- cMidNorm = cMid.setNorm();
- }
-
- color CalcPoint(Point p) {
- xyz V = new xyz(0,0,0);
- xyz P = new xyz(p).setNorm(). RotateX(xyzHalf,pRotX.Val()*PI*2).
- RotateY(xyzHalf,pRotY.Val()*PI*2).
- RotateZ(xyzHalf,pRotZ.Val()*PI*2);
- xyz Px = new xyz(p);
-
- float mp = min(P.x, P.z);
- float yt = map(t,0,1,.5-a/2,.5+a/2);
- switch (pShape.Cur()) {
-
- case 0: V = new xyz(P.x, yt , P.z); break; // bouncing line
- case 1: V = new xyz(P.x, map(cos(PI*t * P.x),-1,1,0,1) , P.z); break; // top tap
- case 2: V = new xyz(P.x, a*map(P.x<.5?P.x:1-P.x,0,.5 ,0,t-.5)+.5, P.z); break; // V shape
- case 3: V = new xyz(P.x, P.x < cMidNorm.x ? map(P.x,0,cMidNorm.x, .5,yt) :
- map(P.x,cMidNorm.x,1, yt,.5), P.z); break; // Random V shape
-
- case 4: V = new xyz(P.x, .5*(P.x < cMidNorm.x ? map(P.x,0,cMidNorm.x, .5,yt) :
- map(P.x,cMidNorm.x,1, yt,.5)) +
- .5*(P.z < cMidNorm.z ? map(P.z,0,cMidNorm.z, .5,yt) :
- map(P.z,cMidNorm.z,1, yt,.5)), P.z); break; // Random Pyramid shape
-
- case 5: V = new xyz(P.x, a*map((P.x-.5)*(P.x-.5),0,.25,0,t-.5)+.5, P.z); break; // wings
- case 6: V = new xyz(P.x, a*map((mp -.5)*(mp -.5),0,.25,0,t-.5)+.5, P.z); break; // wings
-
-
- case 7: V = new xyz(cMid.x,cMid.y,cMid.z);
- return color(0,0,c1c(1 - (V.distance(Px) > (pRad.getValuef()+.1)*100?1:0)) ); // sphere
-
- case 8: V = new xyz(cMid.x,cMid.y,cMid.z);
- return color(0,0,c1c(1 - CalcCone(Px,V,xyzMid) * 0.02 > .5?1:0)); // cone
-
- }
-
- return color(0,0,c1c(1 - V.distance(P)/pRad.getValuef() > .5?1:0));
- }
-}
-//----------------------------------------------------------------------------------------------------------------------------------
\ No newline at end of file
+//----------------------------------------------------------------------------------------------------------------------------------\r
+public class Pong extends DPat {\r
+ SinLFO x,y,z,dx,dy,dz; \r
+ float cRad; _DhP pSize;\r
+ Pick pChoose;\r
+\r
+ Pong(GLucose glucose) {\r
+ super(glucose);\r
+ cRad = xdMax/15;\r
+ addModulator(dx = new SinLFO(6000, 500, 30000 )).trigger();\r
+ addModulator(dy = new SinLFO(3000, 500, 22472 )).trigger();\r
+ addModulator(dz = new SinLFO(1000, 500, 18420 )).trigger();\r
+ addModulator(x = new SinLFO(cRad, xdMax - cRad, 0)).trigger(); x.modulateDurationBy(dx);\r
+ 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
+ }\r
+\r
+ void StartRun(int deltaMs) { cRad = xdMax*pSize.Val()/6; }\r
+ color CalcPoint(xyz p) {\r
+ xyz v = new xyz(x.getValuef(), y.getValuef(), z.getValuef());\r
+ switch(pChoose.Cur()) {\r
+ case 0: return color(0,0,c1c(1 - min(v.distance(p), v.distance(xyzdMax.minus(p)))*.5/cRad)); // balls\r
+ case 1: return color(0,0,c1c(1 - v.distance(p)*.5/cRad)); // ball\r
+ case 2: return color(0,0,c1c(1 - CalcCone(p,v,new xyz(xdMax/2,0,zdMax/2)) * max(.02,.45-pSize.Val()))); // spot\r
+ }\r
+ return color(0,0,0);\r
+ } \r
+}\r
+//----------------------------------------------------------------------------------------------------------------------------------\r
+public class NDat {\r
+ float xz, yz, zz, hue, sat, speed, angle, den;\r
+ float xoff,yoff,zoff;\r
+ NDat (float _hue, float _sat, float _xz, float _yz, float _zz, float _den, float _speed, float _angle) {\r
+ hue=_hue; sat=_sat; xz=_xz; yz=_yz; zz =_zz; den=_den; speed=_speed; angle=_angle;\r
+ xoff = random(100e3); yoff = random(100e3); zoff = random(100e3);\r
+ }\r
+}\r
+\r
+public class Noise extends DPat\r
+{\r
+ int CurAnim = -1, numAnims = 6;\r
+ float zTime = random(10000), zTheta=0;\r
+ float rtime = 0, ttime = 0, transAdd=0;\r
+ int XSym=1,YSym=2,RadSym=3;\r
+ int iSymm;\r
+ ArrayList noises = new ArrayList();\r
+ _DhP pSpeed , pDensity, pRotZ;\r
+ Pick pChoose, pSymm;\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, 4); pChoose = addPick("Animation", 1, 6);\r
+ }\r
+\r
+ void StartRun(int deltaMs) {\r
+ zTime += deltaMs*(pSpeed.Val()-.5)*.002 ;\r
+ zTheta += deltaMs*(pRotZ .Val()-.5)*.01 ;\r
+ rtime += deltaMs;\r
+ iSymm = pSymm.Cur();\r
+ transAdd = 1*(1 - constrain(rtime - ttime,0,1000)/1000);\r
+\r
+ if (pChoose.Cur() != CurAnim) {\r
+ noises.clear(); CurAnim = pChoose.Cur(); ttime = rtime;\r
+ switch(CurAnim) {\r
+ // hue sat xz yz zz den mph angle\r
+ case 0: noises.add(new NDat(0 ,0 ,75 ,75 ,150,45 ,3 ,0 )); pSharp.Set(1 ); break; // drip\r
+ case 1: noises.add(new NDat(0 ,0 ,100,100,200,45 ,3 ,180)); pSharp.Set(0 ); break; // clouds\r
+ case 2: noises.add(new NDat(0 ,0 ,2 ,400,2 ,20 ,3 ,0 )); pSharp.Set(.5); break; // rain\r
+ case 3: noises.add(new NDat(40 ,1 ,100,100,200,10 ,1 ,180)); \r
+ noises.add(new NDat(0 ,1 ,100,100,200,10 ,5 ,180)); pSharp.Set(0 ); break; // fire 1\r
+ case 4: noises.add(new NDat(0 ,1 ,40 ,40 ,40 ,15 ,2.5,180));\r
+ noises.add(new NDat(20 ,1 ,40 ,40 ,40 ,15 ,4 ,0 ));\r
+ noises.add(new NDat(40 ,1 ,40 ,40 ,40 ,15 ,2 ,90 ));\r
+ noises.add(new NDat(60 ,1 ,40 ,40 ,40 ,15 ,3 ,-90)); pSharp.Set(.5); break; // machine\r
+ case 5: noises.add(new NDat(0 ,1 ,400,100,2 ,15 ,3 ,90 ));\r
+ noises.add(new NDat(20 ,1 ,400,100,2 ,15 ,2.5,0 ));\r
+ noises.add(new NDat(40 ,1 ,100,100,2 ,15 ,2 ,180));\r
+ noises.add(new NDat(60 ,1 ,100,100,2 ,15 ,1.5,270)); pSharp.Set(.5); break; // spark\r
+ }\r
+ }\r
+\r
+ }\r
+\r
+ color CalcPoint(xyz P) {\r
+ color c = 0;\r
+ xyz v = P.RotateZ(xyzMid,zTheta);\r
+ if (iSymm == XSym && v.x > xdMax/2) v.x = xdMax-v.x;\r
+ if (iSymm == YSym && v.y > ydMax/2) v.y = ydMax-v.y;\r
+\r
+ for (int i=0;i<noises.size(); i++) {\r
+ NDat n = (NDat) noises.get(i);\r
+ float zx = zTime * n.speed * sin(radians(n.angle)),\r
+ zy = zTime * n.speed * cos(radians(n.angle));\r
+ \r
+ float b = (iSymm==RadSym ? noise(zTime*n.speed+n.xoff-Dist(v,xyzMid)/n.xz)\r
+ : noise(v.x/n.xz+zx+n.xoff,v.y/n.yz+zy+n.yoff,v.z/n.zz+n.zoff))\r
+ *1.8;\r
+\r
+ b += n.den/100 -.4 + pDensity.Val() -1;\r
+ b += transAdd;\r
+ c = blendColor(c,color(n.hue,100*n.sat,c1c(b)),ADD);\r
+ }\r
+ return c;\r
+ }\r
+}\r
+//----------------------------------------------------------------------------------------------------------------------------------\r
+public class Play extends DPat\r
+{\r
+ int nBeats = 0;\r
+ _DhP pAmp, pRad;\r
+ _DhP pRotX, pRotY, pRotZ;\r
+ xyz Theta = new xyz();\r
+ Pick pTimePattern, pTempoMult, pShape, pForm;\r
+ int RandCube;\r
+\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
+ }\r
+\r
+ float t,a;\r
+ xyz cPrev = new xyz(), cCur = new xyz(), cMid = new xyz(), cMidNorm;\r
+ float LastBeat=3, LastMeasure=3;\r
+ int CurRandTempo = 1;\r
+\r
+ void StartRun(int deltaMs) {\r
+ t = lx.tempo.rampf();\r
+ a = pAmp.Val();\r
+\r
+ Theta.x = pRotX.ZeroOrOne() ? 0 :(pRotX.Val()-.5)*10;\r
+ Theta.y = pRotY.ZeroOrOne() ? 0 :(pRotY.Val()-.5)*10;\r
+ Theta.z = pRotZ.ZeroOrOne() ? 0 :(pRotZ.Val()-.5)*10;\r
+\r
+ if (t<LastMeasure) { CurRandTempo = int(random(4)); } LastMeasure = t;\r
+ \r
+ switch (pTempoMult.Cur()) {\r
+ case 0: t = t; break;\r
+ case 1: t = (t*2. )%1.; break;\r
+ case 2: t = (t*4. )%1.; break;\r
+ case 3: t = (t*8. )%1.; break;\r
+ case 4: t = (t*16.)%1.; break;\r
+ case 5: t = (t*pow(2,CurRandTempo))%1.; break;\r
+ }\r
+\r
+ if (t<LastBeat) { cPrev = cCur; cCur = cCur.setRand(); } LastBeat = t;\r
+\r
+ switch (pTimePattern.Cur()) {\r
+ case 0: t = sin(PI*t); break;\r
+ case 1: t = norm(sin(2*PI*(t+PI/2)),-1,1); break;\r
+ case 2: t = t; break;\r
+ case 3: t = constrain(int(t*8)/7.,0,1); break;\r
+ case 4: t = t*t*t; break;\r
+ }\r
+\r
+ cMid = cPrev.interpolate(t,cCur);\r
+ cMidNorm = cMid.setNorm();\r
+ }\r
+\r
+ color CalcPoint(xyz Px) {\r
+ xyz V = new xyz();\r
+ xyz P = Px.setNorm();\r
+ if (Theta.x>0) P = P.RotateZ(xyzHalf, Theta.x);\r
+ if (Theta.y>0) P = P.RotateZ(xyzHalf, Theta.y);\r
+ if (Theta.z>0) P = P.RotateZ(xyzHalf, Theta.z);\r
+\r
+ float mp = min(P.x, P.z);\r
+ float yt = map(t,0,1,.5-a/2,.5+a/2);\r
+\r
+ switch (pShape.Cur()) {\r
+ case 0: V = new xyz(P.x, yt , P.z); break; // bouncing line\r
+ case 1: V = new xyz(P.x, map(cos(PI*t * P.x),-1,1,0,1) , P.z); break; // top tap\r
+ case 2: V = new xyz(P.x, a*map(P.x<.5?P.x:1-P.x,0,.5 ,0,t-.5)+.5, P.z); break; // V shape\r
+ case 3: V = new xyz(P.x, P.x < cMidNorm.x ? map(P.x,0,cMidNorm.x, .5,yt) :\r
+ map(P.x,cMidNorm.x,1, yt,.5), P.z); break; // Random V shape\r
+\r
+ case 4: V = new xyz(P.x, .5*(P.x < cMidNorm.x ? map(P.x,0,cMidNorm.x, .5,yt) :\r
+ map(P.x,cMidNorm.x,1, yt,.5)) +\r
+ .5*(P.z < cMidNorm.z ? map(P.z,0,cMidNorm.z, .5,yt) :\r
+ map(P.z,cMidNorm.z,1, yt,.5)), P.z); break; // Random Pyramid shape\r
+ \r
+ case 5: V = new xyz(P.x, a*map((P.x-.5)*(P.x-.5),0,.25,0,t-.5)+.5, P.z); break; // wings\r
+ case 6: V = new xyz(P.x, a*map((mp -.5)*(mp -.5),0,.25,0,t-.5)+.5, P.z); break; // wings\r
+\r
+ case 7: V = new xyz(cMid.x,cMid.y,cMid.z);\r
+ return color(0,0,c1c(1 - (V.distance(Px) > (pRad.getValuef()+.1)*150?1:0)) ); // sphere\r
+\r
+ case 8: V = new xyz(cMid.x,cMid.y,cMid.z);\r
+ return color(0,0,c1c(1 - CalcCone(Px,V,xyzMid) * 0.02 > .5?1:0)); // cone\r
+\r
+ case 9: return color(100 + noise(P.x,P.y,P.z + (NoiseMove+50000)/1000.)*200,\r
+ 85,c1c(P.y < noise(P.x + NoiseMove/2000.,P.z)*(1+a)-a/2.-.1 ? 1 : 0)); //\r
+ }\r
+\r
+\r
+ switch (pForm.Cur()) {\r
+ case 0: return color(0,0,c1c(1 - V.distance(P)/pRad.getValuef() > .5?1:0));\r
+ case 1: return color(0,0,c1c(P.y < V.y ?1:0));\r
+ case 2: return color(0,0,c1c(1 - V.distance(P)/pRad.getValuef()));\r
+\r
+ default: return color(0,0,c1c(P.y < V.y ?1:0));\r
+ }\r
+ }\r
+}\r
+//----------------------------------------------------------------------------------------------------------------------------------\r
--- /dev/null
+class GenericController {
+ GenericController(){}
+ public void RotateKnob(int type, int num, float val){
+ LXParameter p = null;
+ if(type==0) {
+ p = glucose.patternKnobs.get(num);
+ if(p!=null) { p.setValue(val); }
+ }
+ if(type==1) {
+ p = glucose.transitionKnobs.get(num);
+ if(p!=null) { p.setValue(val); }
+ }
+ if(type==2) {
+ p = glucose.effectKnobs.get(num);
+ if(p!=null) { p.setValue(val); }
+ }
+ }
+}
+
+class MidiController extends GenericController {
+ MidiController() {
+ super();
+ }
+}
+//PApplet xparent; // be sure to set
+
+
+
+OscP5 listener;
+// Setup OSC
+//listener = new OscP5(this,7022);
+
+//boolean[] noteState = new boolean[16];
+//
+//void controllerChangeReceived(rwmidi.Controller cc) {
+// if (debugMode) {
+// println("CC: " + cc.toString());
+// }
+// if(cc.getCC()==1){
+// for(int i=0; i<16; i++){
+// if(noteState[i] && i<8) { LXParameter p = glucose.patternKnobs.get(i); p.setValue(cc.getValue()/127.0); }
+// else if(noteState[i] && i<12) { LXParameter p = glucose.transitionKnobs.get(i-8); p.setValue(cc.getValue()/127.0); }
+// else if(noteState[i] && i<16) { LXParameter p = glucose.effectKnobs.get(i-12); p.setValue(cc.getValue()/127.0); }
+// }
+// }
+//}
+//
+//void noteOnReceived(Note note) {
+// if (debugMode) {
+// println("Note On: " + note.toString());
+// }
+// int pitch = note.getPitch();
+// if(pitch>=36 && pitch <36+16){
+// noteState[pitch-36]=true;
+// }
+//}
+//
+//void noteOffReceived(Note note) {
+// if (debugMode) {
+// println("Note Off: " + note.toString());
+// }
+// int pitch = note.getPitch();
+// if(pitch>=36 && pitch <36+16){
+// noteState[pitch-36]=false;
+// }
+//}
+//
+//void oscEvent(OscMessage theOscMessage) {
+// println(theOscMessage);
+// LXPattern currentPattern = lx.getPattern();
+// if (currentPattern instanceof OSCPattern) {
+// ((OSCPattern)currentPattern).oscEvent(theOscMessage);
+// }
+//}
+//
+
+
+class ObjectMuckerEffect extends SCEffect {
+ ObjectMuckerEffect(GLucose glucose) {
+ super(glucose);
+ }
+ public void doApply(int[] colors){
+ /*for(Strip s: model.strips){
+ for(int i=0; i<s.points.size(); i++){
+ int index = s.points.get(i).index;
+ color c = colors[index];
+ colors[index] = color((i*22.5), saturation(c), brightness(c));
+ }
+ }*/
+ }
+}
+
+class BlendFrames extends SCEffect {
+ int fcount;
+ int frames[][];
+ int maxfbuf;
+ int blendfactor;
+ BlendFrames(GLucose glucose) {
+ super(glucose);
+ maxfbuf = 30;
+ blendfactor=30;
+ fcount=0;
+ frames = new int[maxfbuf][];
+ for(int i=0; i<maxfbuf; i++){
+ frames[i] = new int[model.points.size()];
+ }
+ }
+ public void doApply(int[] colors) {
+ if(fcount<maxfbuf){
+ for(int i=0; i<colors.length; i++){
+ frames[(maxfbuf-1)-fcount][i]=colors[i];
+ }
+ fcount++;
+ return;
+ } else {
+ for(int i=maxfbuf-1; i>0; i--){
+ frames[i] = frames[i-1];
+ }
+ frames[0] = new int[model.points.size()];
+
+ for(int i=0; i<colors.length; i++){
+ int r,g,b;
+ r=g=b=0;
+ for(int j=0; j<blendfactor; j++){
+ if(j==0) { frames[0][i] = colors[i]; }
+ r += ((frames[j][i] >> 16) & 0xFF);
+ g += ((frames[j][i] >> 8) & 0xFF);
+ b += ((frames[j][i] >> 0) & 0xFF);
+ }
+ r/=blendfactor;
+ g/=blendfactor;
+ b/=blendfactor;
+ colorMode(ARGB);
+ colors[i] = (0xFF << 24) | (r << 16) | (g << 8) | b;
+ colorMode(HSB);
+ }
+
+ }
+ }
+}
+
+
+import netP5.*;
+import oscP5.*;
+
+
+
+abstract class OSCPattern extends SCPattern {
+ public OSCPattern(GLucose glucose){super(glucose);}
+ public abstract void oscEvent(OscMessage msg);
+}
+
+class Ball {
+ public int lastSeen;
+ public float x,y;
+ public Ball(){
+ x=y=lastSeen=0;
+ }
+}
+
+class OSC_Balls extends OSCPattern {
+ Ball[] balls;
+ public OSC_Balls(GLucose glucose){
+ super(glucose);
+ balls = new Ball[20];
+ for(int i=0; i<balls.length; i++) { balls[i] = new Ball(); }
+ }
+ void oscEvent(OscMessage msg){
+ String pattern[] = split(msg.addrPattern(), "/");
+ int ballnum = int(pattern[3]);
+ balls[ballnum].lastSeen=millis();
+ balls[ballnum].x = msg.get(0).floatValue();
+ balls[ballnum].y = msg.get(1).floatValue();
+ }
+
+ void run(int deltaMs){
+ for(Point p: model.points){ colors[p.index]=0; }
+ for(int i=1; i<balls.length; i++){
+ if(millis() - balls[i].lastSeen < 1000) {
+ for(Point p: model.points){
+ int x = int(balls[i].x * 255.0);
+ int y = int(balls[i].y * 127.0);
+ if(p.x < x+4 && p.x > x-4 && p.y < y+4 && p.y > y-4) { colors[p.index] = #FF0000; }
+ }
+ }
+ }
+ }
+}
+
+import processing.serial.*;
+
+
+/*class ScreenScrape extends SCPattern {
+ PImage pret;
+ ScreenShot ss;
+ public ScreenScrape(GLucose glucose) {
+ super(glucose);
+ System.loadLibrary("ScreenShot");
+ pret = new PImage(8, 128, ARGB);
+ ss = new ScreenShot();
+ }
+ void run(int deltaMs){
+ int x=(1366/2)+516;
+ int y=768-516;
+ int w=8;
+ int h=128;
+ pret.pixels = ss.getScreenShotJNI2(x, y, w, h);
+ //for(int i=0; i<px.length; i++){ pret.pixels[i] = px[i]; }
+ //println(pret.get(10,10));
+ for(Point p: model.points){
+ colors[p.index] = pret.get((int(p.x)/8)*8, 128-int(p.y));
+ }
+ }
+}*/
+
+List<LXParameter> gparams;
+
+class DualBlender extends SCEffect {
+ int lastSeen;
+ BasicParameter p1 = new BasicParameter("p1", 0);
+ BasicParameter p2 = new BasicParameter("p2", 0);
+ BasicParameter p3 = new BasicParameter("p3", 0);
+ BasicParameter p4 = new BasicParameter("p4", 0);
+ BasicParameter p5 = new BasicParameter("p5", 0);
+ BasicParameter p6 = new BasicParameter("p6", 0);
+ BasicParameter p7 = new BasicParameter("p7", 0);
+ BasicParameter p8 = new BasicParameter("p8", 0);
+ DualBlender(GLucose glucose){
+ super(glucose);
+ gparams = gplay.getParameters();
+ addParameter(p1);
+ addParameter(p2);
+ addParameter(p3);
+ addParameter(p4);
+ addParameter(p5);
+ addParameter(p6);
+ addParameter(p7);
+ addParameter(p8);
+
+ lastSeen=millis();
+ }
+
+ void onParameterChanged(LXParameter p){
+ if(p==p1) { gparams.get(0).setValue(p.getValuef()); }
+ if(p==p2) { gparams.get(1).setValue(p.getValuef()); }
+ if(p==p3) { gparams.get(2).setValue(p.getValuef()); }
+ if(p==p4) { gparams.get(3).setValue(p.getValuef()); }
+ if(p==p5) { gparams.get(4).setValue(p.getValuef()); }
+ if(p==p6) { gparams.get(5).setValue(p.getValuef()); }
+ if(p==p7) { gparams.get(6).setValue(p.getValuef()); }
+ if(p==p8) { gparams.get(7).setValue(p.getValuef()); }
+ }
+
+ void doApply(int[] colors){
+ if(doDual==true){
+ //gplay.onActive();
+ gplay.go(millis()-lastSeen);
+ lastSeen=millis();
+ int[] pcolors = gplay.getColors();
+ for(int i=0; i<colors.length; i++){
+ colors[i]=blendColor(colors[i],pcolors[i], MULTIPLY);
+ }
+ } else {}//gplay.onInactive(); }
+ }
+
+
+}
+
--- /dev/null
+//----------------------------------------------------------------------------------------------------------------------------------
+static MidiOutput midiout;
+int nNumRows = 5, nNumCols = 8;
+float xdMax,ydMax,zdMax;
+String DanTextLine1 = "", DanTextLine2 = "";
+
+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; }
+ int Cur() { return (CurRow-StartRow)*nNumCols + CurCol; }
+ int NumPicks, Default, CurRow, CurCol, StartRow, EndRow;
+ String tag;
+}
+//----------------------------------------------------------------------------------------------------------------------------------
+public class _DhP extends BasicParameter {
+ double dflt;
+ _DhP (String label, double value) { super(label,value); dflt=value; }
+ void Set (double value) { super.updateValue(value); }
+ void reset () { super.updateValue(dflt); }
+ float Val () { return getValuef(); }
+ boolean ZeroOrOne () { return Val()==0 || Val() == 1; }
+}
+
+public class IndexNums {
+ int point ;//, cube , tower , face , strip ;
+ int nPoints ;//, nCubes, nTowers, nFaces, nStrips ;
+// boolean isHoriz;
+ void reset() { point=0;}//cube=tower=face=strip=0; }
+}
+IndexNums iCur = new IndexNums();
+//----------------------------------------------------------------------------------------------------------------------------------
+public class xyz { float x,y,z;
+ xyz() {x=y=z=0;}
+ xyz(Point p ) {x=p.fx ; y=p.fy; z=p.fz;}
+ xyz(float _x,float _y,float _z) {x=_x ; y=_y ; z=_z ;}
+ void set(float _x,float _y,float _z) {x=_x ; y=_y ; z=_z ;}
+ float distance(xyz b) {return dist(x,y,z,b.x,b.y,b.z); }
+ float dot (xyz b) {return x*b.x + y*b.y + z*b.z; }
+ xyz minus (xyz b) {return new xyz(x-b.x,y-b.y,z-b.z); }
+ xyz plus (xyz b) {return new xyz(x+b.x,y+b.y,z+b.z); }
+ xyz plus (float b) {return new xyz(x+b ,y+b ,z+b ); }
+ xyz over (xyz b) {return new xyz(x/b.x,y/b.y,z/b.z); }
+ xyz times (float b) {return new xyz(x*b ,y*b ,z*b ); }
+
+ xyz RotateX (xyz o, float a) { return new xyz ( x,
+ cos(a)*(y-o.y) - sin(a)*(z-o.z) + o.y,
+ sin(a)*(y-o.y) + cos(a)*(z-o.z) + o.z); }
+
+ xyz RotateY (xyz o, float a) { return new xyz ( cos(a)*(x-o.x) - sin(a)*(z-o.z) + o.x,
+ y,
+ sin(a)*(x-o.x) + cos(a)*(z-o.z) + o.z); }
+
+ xyz RotateZ (xyz o, float a) { return new xyz ( cos(a)*(x-o.x) - sin(a)*(y-o.y) + o.x,
+ sin(a)*(x-o.x) + cos(a)*(y-o.y) + o.y,
+ z ); }
+
+ xyz setRand () { return new xyz ( random(xdMax), random(ydMax), random(zdMax)); }
+ xyz setNorm () { return new xyz ( x / xdMax, y / ydMax, z / zdMax); }
+
+ float interp (float a, float b, float c) { return (1-a)*b + a*c; }
+ xyz interpolate(float i, xyz d) { return new xyz ( interp(i,x,d.x), interp(i,y,d.y), interp(i,z,d.z)); }
+}
+//----------------------------------------------------------------------------------------------------------------------------------
+public class DPat extends SCPattern
+{
+ float zSpinHue;
+ xyz xyzdMax, xyz0, xyzMid, xyzHalf;
+ PFont itemFont = createFont("Lucida Grande", 11);
+ ArrayList picklist = new ArrayList();
+ ArrayList paramlist = new ArrayList();
+ int nMaxRow = 0;
+ boolean bIsActive = false;
+ float NoiseMove = random(10000);
+
+ 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)); }
+ 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 (midiout != null) midiout.sendNoteOn(col, unmapRow(row), clr); }
+ void keypad (int row, int col) { println(row + " " + col); }
+ void onInactive() { bIsActive=false; DanTextLine1 = ""; DanTextLine2 = "";}
+ void onActive () { bIsActive=true;
+ zSpinHue = 0;
+ for (int i=0; i<paramlist.size(); i++) ((_DhP)paramlist.get(i)).reset();
+ while (lx.tempo.bpm() > 40) lx.tempo.setBpm(lx.tempo.bpm()/2);
+ UpdateLights();
+ }
+ void StartRun(int deltaMs) { }
+ color CalcPoint(xyz p) { return color(0,0,0); }
+ float CalcCone (xyz v1, xyz v2, xyz c) {
+ return degrees( acos ( v1.minus(c).dot(v2.minus(c)) / (sqrt(v1.minus(c).dot(v1.minus(c))) * sqrt(v2.minus(c).dot(v2.minus(c))) ) ));
+ }
+
+ void AddDanText() {
+ DanTextLine1 = "APC40: ";
+ for (int i=0; i<picklist.size() ; i++) { Pick P = (Pick)picklist.get(i); DanTextLine1 += P.tag + ": " + P.Cur() + " "; }
+ DanTextLine1 += " X-Symm: " + (_XSym ? "ON" : "OFF") + " ";
+ DanTextLine1 += " Y-Symm: " + (_YSym ? "ON" : "OFF") + " ";
+ DanTextLine1 += " Z-Symm: " + (_ZSym ? "ON" : "OFF") + " ";
+ DanTextLine1 += " Rad-Sym: " + (_RadSym ? "ON" : "OFF") + " ";
+// DanTextLine1 += " Horiz: " + (_Horiz ? "ON" : "OFF") + " ";
+// DanTextLine1 += " Vert: " + (_Vert ? "ON" : "OFF") + " ";
+
+ DanTextLine2 = "SLIDERS: ";
+ for (int i=0; i<8; i++) if (SliderText[i] != "") { DanTextLine2 += SliderText[i] + ": " + Sliders[i] + " "; }
+ }
+
+ void run(int deltaMs) {
+ NoiseMove += deltaMs;
+ xdMax = model.xMax;
+ ydMax = model.yMax;
+ zdMax = model.zMax;
+ xyzdMax = new xyz(xdMax,ydMax,zdMax);
+ xyzMid = new xyz(xdMax/2, ydMax/2, zdMax/2);
+ StartRun (deltaMs);
+ zSpinHue += s_SpinHue ()*deltaMs*.05;
+ float fSharp = 1/(1.01-pSharp.Val());
+ AddDanText();
+ iCur.reset(); iCur.nPoints = model.points.size();
+// iCur.nTowers = model.towers.size(); iCur.nCubes = model.cubes .size();
+// iCur.nFaces = model.faces .size(); iCur.nStrips = model.strips.size();
+
+// for (Tower t : model.towers) { iCur.tower++;
+// for (Cube c : t.cubes) { iCur.cube ++;
+// for (Face f : c.faces) { iCur.face ++;
+// for (Strip s : f.strips) { iCur.strip++; iCur.isHoriz= (iCur.strip % 2 == 1 || iCur.strip < 5) ? true : false;
+ for (Point p : model.points) { iCur.point++;
+ xyz P = new xyz(p);
+
+ if (s_Spark () > 0) P.y += s_Spark () * (noise(P.x,P.y+NoiseMove/30 ,P.z)*ydMax - ydMax/2.);
+ if (s_Wiggle() > 0) P.y += s_Wiggle() * (noise(P.x/(xdMax*.3)-NoiseMove/1500.) - .5) * (ydMax/2.);
+
+ color cOld = colors[p.index];
+ color cNew = CalcPoint(P);
+
+// if (_Horiz && !iCur.isHoriz) { colors[p.index] = 0; continue; }
+// if (_Vert && iCur.isHoriz) { colors[p.index] = 0; continue; }
+ if (_XSym) cNew = blendColor(cNew, CalcPoint(new xyz(xdMax-P.x,P.y,P.z)), ADD);
+ if (_YSym) cNew = blendColor(cNew, CalcPoint(new xyz(P.x,ydMax-P.y,P.z)), ADD);
+ if (_ZSym) cNew = blendColor(cNew, CalcPoint(new xyz(P.x,P.y,zdMax-P.z)), ADD);
+
+ float b = brightness(cNew)/100.;
+ b = b < .5 ? pow(b,fSharp) : 1-pow(1-b,fSharp);
+
+ float modhue = s_ModHue ()>0 ? s_ModHue ()*360:0;
+
+ float noizhue = s_NoiseHue()>0 ? s_NoiseHue()*360*noise( P.x/(xdMax*.3)+NoiseMove/3000.,
+ P.y/(ydMax*.3)+NoiseMove/4000.,
+ P.z/(zdMax*.3)+NoiseMove/5000.) : 0;
+
+ cNew = color( (hue(cNew) + modhue + zSpinHue - noizhue) % 360,
+ saturation(cNew) + 100*s_Saturate(),
+ 100 * (s_Trails()==0 ? b : max(b, brightness(cOld)/100. - (1-s_Trails()) * deltaMs/200.))
+ * (s_Dim ()==0 ? 1 : 1-s_Dim())
+ );
+
+ colors[p.index] = cNew;
+ }
+// }}}}
+ }
+
+ void controllerChangeReceived(rwmidi.Controller cc) {
+ if (cc.getCC() == 7 && btwn(cc.getChannel(),0,7)) Sliders[cc.getChannel()] = 1.*cc.getValue()/127.;
+ }
+
+ public float Sliders[] = new float[] {0,0,0,0,0,0,0,0};
+ String SliderText[]= new String[] {"Trails", "Dim", "Saturate", "SpinHue", "Hue", "NoiseHue", "Spark", "Wiggle"};
+ float s_Trails () { return Sliders[0]; }
+ float s_Dim () { return Sliders[1]; }
+ float s_Saturate () { return Sliders[2]; }
+ float s_SpinHue () { return Sliders[3]; }
+ float s_ModHue () { return Sliders[4]; }
+ float s_NoiseHue () { return Sliders[5]; }
+ float s_Spark () { return Sliders[6]; }
+ float s_Wiggle () { return Sliders[7]; }
+ _DhP pSharp;
+
+ DPat(GLucose glucose) {
+ super(glucose);
+ xyzHalf = new xyz(.5,.5,.5);
+ xyz0 = new xyz(0,0,0);
+ pSharp = addParam("Shrp", 0);
+
+ for (MidiInputDevice input : RWMidi.getInputDevices ()) { if (input.toString().contains("APC")) input .createInput (this);}
+ for (MidiOutputDevice output : RWMidi.getOutputDevices()) {
+ if (midiout == null && output.toString().contains("APC")) midiout = output.createOutput();
+ }
+ }
+
+ void UpdateLights() {
+ for (int i=0; i<nNumRows ; i++) for (int j=0; j<nNumCols; j++) SetLight(i, j, 0);
+ for (int i=0; i<picklist.size() ; i++) {
+ Pick P = (Pick)picklist.get(i); SetLight(P.CurRow, P.CurCol, 3);
+ }
+ SetLight(82, 0, _XSym ? 3 : 0);
+ SetLight(83, 0, _YSym ? 3 : 0);
+ SetLight(84, 0, _ZSym ? 3 : 0);
+ SetLight(85, 0, _RadSym ? 3 : 0);
+// SetLight(86, 0, _Horiz ? 3 : 0);
+// SetLight(87, 0, _Vert ? 3 : 0);
+ }
+
+ Pick GetPick(int row, int col) {
+ for (int i=0; i<picklist.size(); i++) { Pick P = (Pick)picklist.get(i);
+ if (!btwn(row,P.StartRow,P.EndRow) ) continue;
+ if (!btwn(col,0,nNumCols-1) ) continue;
+ if (!btwn((row-P.StartRow)*nNumCols + col,0,P.NumPicks-1) ) continue;
+ return P;
+ }
+ return null;
+ }
+
+ double Tap1 = 0;
+ double getNow() { return millis() + 1000*second() + 60*1000*minute() + 3600*1000*hour(); }
+
+ void noteOffReceived(Note note) { if (!bIsActive) return;
+ int row = mapRow(note.getPitch()), col = note.getChannel();
+
+ if (row == 50 && col == 0 && btwn(getNow() - Tap1,5000,300*1000)) { // hackish tapping mechanism
+ double bpm = 32.*60000./(getNow()-Tap1);
+ while (bpm < 20) bpm*=2;
+ while (bpm > 40) bpm/=2;
+ lx.tempo.setBpm(bpm); lx.tempo.trigger(); Tap1=0; println("Tap Set - " + bpm + " bpm");
+ }
+
+ UpdateLights();
+ }
+
+ boolean _XSym=false, _YSym=false, _ZSym=false, _RadSym=false; //, _Horiz=false, _Vert=false;
+
+ void noteOnReceived (Note note) { if (!bIsActive) return;
+ int row = mapRow(note.getPitch()), col = note.getChannel();
+ Pick P = GetPick(row,col);
+ if (P != null) { P.CurRow=row; P.CurCol=col; }
+ else if (row == 50 && col == 0) { lx.tempo.trigger(); Tap1 = getNow(); }
+ else if (row == 82 && col == 0) _XSym = !_XSym ;
+ else if (row == 83 && col == 0) _YSym = !_YSym ;
+ else if (row == 84 && col == 0) _ZSym = !_ZSym ;
+ else if (row == 85 && col == 0) _RadSym = !_RadSym ;
+ else keypad(row, col) ;
+ }
+
+ _DhP addParam(String label, double value) {
+ _DhP P = new _DhP(label, value);
+ super.addParameter(P);
+ paramlist.add(P); return P;
+ }
+
+ Pick addPick(String name, int def, int nmax) {
+ Pick P = new Pick(name, def, nmax);
+ P.StartRow = nMaxRow;
+ P.EndRow = P.StartRow + int((nmax-1) / nNumCols);
+ nMaxRow = P.EndRow + 1;
+ P.CurCol = def % nNumCols;
+ P.CurRow = P.StartRow + def/nNumCols;
+ picklist.add(P);
+ return P;
+ }
+}
+//----------------------------------------------------------------------------------------------------------------------------------\r
--- /dev/null
+color BLACK = color(0, 0, 0);
+
+class Gimbal extends SCPattern {
+
+ private final boolean DEBUG_MANUAL_ABG = false;
+ private final int MAXIMUM_BEATS_PER_REVOLUTION = 100;
+
+ private boolean first_run = true;
+ private final Projection projection;
+ private final BasicParameter beatsPerRevolutionParam = new BasicParameter("SLOW", 20./MAXIMUM_BEATS_PER_REVOLUTION);
+ private final BasicParameter hueDeltaParam = new BasicParameter("HUED", 60./360);
+ private final BasicParameter fadeFromCoreParam = new BasicParameter("FADE", 1);
+ private final BasicParameter girthParam = new BasicParameter("GRTH", .18);
+ private final BasicParameter ringExtendParam = new BasicParameter("XTND", 1);
+ private final BasicParameter relativeSpeedParam = new BasicParameter("RLSP", .83);
+ private final BasicParameter sizeParam = new BasicParameter("SIZE", .9);
+
+ private final BasicParameter aP = new BasicParameter("a", 0);
+ private final BasicParameter bP = new BasicParameter("b", 0);
+ private final BasicParameter gP = new BasicParameter("g", 0);
+
+ Gimbal(GLucose glucose) {
+ super(glucose);
+ projection = new Projection(model);
+ addParameter(beatsPerRevolutionParam);
+ addParameter(hueDeltaParam);
+ addParameter(fadeFromCoreParam);
+ addParameter(girthParam);
+ addParameter(ringExtendParam);
+ addParameter(relativeSpeedParam);
+ addParameter(sizeParam);
+
+ if (DEBUG_MANUAL_ABG) {
+ addParameter(aP);
+ addParameter(bP);
+ addParameter(gP);
+ }
+ }
+
+ float a = 0, b = 0, g = 0;
+
+ public void run(int deltaMs) {
+
+ if (DEBUG_MANUAL_ABG) {
+ a = aP.getValuef() * (2 * PI);
+ b = bP.getValuef() * (2 * PI);
+ g = gP.getValuef() * (2 * PI);
+ } else {
+ float relativeSpeed = relativeSpeedParam.getValuef();
+ float time = millis() / 1000.f;
+
+ int beatsPerRevolution = (int) (beatsPerRevolutionParam.getValuef() * MAXIMUM_BEATS_PER_REVOLUTION) + 1;
+ float radiansPerMs = 2 * PI // radians / revolution
+ / beatsPerRevolution // beats / revolution
+ * lx.tempo.bpmf() // BPM beats / min
+ / 60 // sec / min
+ / 1000; // ms / sec
+
+ a += deltaMs * radiansPerMs * pow(relativeSpeed, 0);
+ b += deltaMs * radiansPerMs * pow(relativeSpeed, 1);
+ g += deltaMs * radiansPerMs * pow(relativeSpeed, 2);
+ a %= 2 * PI;
+ b %= 2 * PI;
+ g %= 2 * PI;
+ }
+
+ float hue = lx.getBaseHuef();
+ float hue_delta = hueDeltaParam.getValuef() * 360;
+
+ float radius1 = model.xMax / 2 * sizeParam.getValuef();
+ float radius2 = ((model.xMax + model.yMax) / 2) / 2 * sizeParam.getValuef();
+ float radius3 = model.yMax / 2 * sizeParam.getValuef();
+ float girth = model.xMax * girthParam.getValuef();
+ Ring ring1 = new Ring((hue + hue_delta * 0) % 360, radius1, girth);
+ Ring ring2 = new Ring((hue + hue_delta * 1) % 360, radius2, girth);
+ Ring ring3 = new Ring((hue + hue_delta * 2) % 360, radius3, girth);
+
+ projection.reset(model)
+ // Translate so the center of the car is the origin
+ .translateCenter(model, 0, 0, 0);
+
+ for (Coord c : projection) {
+ //if (first_run) println(c.x + "," + c.y + "," + c.z);
+
+ rotate3d(c, a, 0, 0);
+ rotate3d(c, PI/4, PI/4, PI/4);
+ color color1 = ring1.colorFor(c);
+
+ rotate3d(c, 0, b, 0);
+ color color2 = ring2.colorFor(c);
+
+ rotate3d(c, 0, 0, g);
+ color color3 = ring3.colorFor(c);
+
+ colors[c.index] = specialBlend(color1, color2, color3);
+ }
+
+ first_run = false;
+ }
+
+ class Ring {
+
+ float hue;
+ float radius, girth;
+
+ public Ring(float hue, float radius, float girth) {
+ this.hue = hue;
+ this.radius = radius;
+ this.girth = girth;
+ }
+
+ public color colorFor(Coord c) {
+ float theta = atan2(c.y, c.x);
+ float nearest_circle_x = cos(theta) * radius;
+ float nearest_circle_y = sin(theta) * radius;
+ float nearest_circle_z = 0;
+
+ float distance_to_circle
+ = sqrt(pow(nearest_circle_x - c.x, 2)
+ + pow(nearest_circle_y - c.y, 2)
+ + pow(nearest_circle_z - c.z * ringExtendParam.getValuef(), 2));
+
+ float xy_distance = sqrt(c.x*c.x + c.y*c.y);
+ return color(this.hue, 100, (1 - distance_to_circle / girth * fadeFromCoreParam.getValuef()) * 100);
+ }
+
+ }
+
+}
+
+
+
+
+
+
+class Zebra extends SCPattern {
+
+ private final Projection projection;
+ SinLFO angleM = new SinLFO(0, PI * 2, 30000);
+
+/*
+ SinLFO x, y, z, dx, dy, dz;
+ float cRad;
+ _P size;
+ */
+
+ Zebra(GLucose glucose) {
+ super(glucose);
+ projection = new Projection(model);
+
+ addModulator(angleM).trigger();
+ }
+
+ color colorFor(Coord c) {
+ float hue = lx.getBaseHuef();
+
+
+
+
+/* SLIDE ALONG
+ c.x = c.x + millis() / 100.f;
+ */
+
+
+
+ int stripe_count = 12;
+ float stripe_width = model.xMax / (float)stripe_count;
+ if (Math.floor((c.x) / stripe_width) % 2 == 0) {
+ return color(hue, 100, 100);
+ } else {
+ return color((hue + 90) % 360, 100, 100);
+ }
+
+
+ /* OCTANTS
+
+ if ((isPositiveBit(c.x) + isPositiveBit(c.y) + isPositiveBit(c.z)) % 2 == 0) {
+ return color(lx.getBaseHuef(), 100, 100);
+ } else {
+ return color(0, 0, 0);
+ }
+ */
+ }
+
+ int isPositiveBit(float f) {
+ return f > 0 ? 1 : 0;
+ }
+
+ public void run(int deltaMs) {
+ float a = (millis() / 1000.f) % (2 * PI);
+ float b = (millis() / 1200.f) % (2 * PI);
+ float g = (millis() / 1600.f) % (2 * PI);
+
+ projection.reset(model)
+ // Translate so the center of the car is the origin
+ .translateCenter(model, 0, 0, 0);
+
+ for (Coord c : projection) {
+// rotate3d(c, a, b, g);
+ colors[c.index] = colorFor(c);
+ }
+
+ first_run = false;
+ }
+
+
+ // Utility!
+ boolean first_run = true;
+ private void log(String s) {
+ if (first_run) {
+ println(s);
+ }
+ }
+
+
+}
+
+void rotate3d(Coord c, float a /* roll */, float b /* pitch */, float g /* yaw */) {
+ float cosa = cos(a);
+ float cosb = cos(b);
+ float cosg = cos(g);
+ float sina = sin(a);
+ float sinb = sin(b);
+ float sing = sin(g);
+
+ float a1 = cosa*cosb;
+ float a2 = cosa*sinb*sing - sina*cosg;
+ float a3 = cosa*sinb*cosg + sina*sing;
+ float b1 = sina*cosb;
+ float b2 = sina*sinb*sing + cosa*cosg;
+ float b3 = sina*sinb*cosg - cosa*sing;
+ float c1 = -sinb;
+ float c2 = cosb*sing;
+ float c3 = cosb*cosg;
+
+ float[] cArray = { c.x, c.y, c.z };
+ c.x = dotProduct(new float[] {a1, a2, a3}, cArray);
+ c.y = dotProduct(new float[] {b1, b2, b3}, cArray);
+ c.z = dotProduct(new float[] {c1, c2, c3}, cArray);
+}
+
+float dotProduct(float[] a, float[] b) {
+ float ret = 0;
+ for (int i = 0 ; i < a.length; ++i) {
+ ret += a[i] * b[i];
+ }
+ return ret;
+}
+
+color specialBlend(color c1, color c2, color c3) {
+ float h1 = hue(c1);
+ float h2 = hue(c2);
+ float h3 = hue(c3);
+
+ // force h1 < h2 < h3
+ while (h2 < h1) {
+ h2 += 360;
+ }
+ while (h3 < h2) {
+ h3 += 360;
+ }
+
+ float s1 = saturation(c1);
+ float s2 = saturation(c2);
+ float s3 = saturation(c3);
+
+ float b1 = brightness(c1);
+ float b2 = brightness(c2);
+ float b3 = brightness(c3);
+ float relative_b1 = b1 / (b1 + b2 + b3);
+ float relative_b2 = b2 / (b1 + b2 + b3);
+ float relative_b3 = b3 / (b1 + b2 + b3);
+
+ return color(
+ (h1 * relative_b1 + h2 * relative_b1 + h3 * relative_b3) % 360,
+ s1 * relative_b1 + s2 * relative_b2 + s3 * relative_b3,
+ max(max(b1, b2), b3)
+ );
+}
+
* If you're an artist, create a new tab in the Processing environment with
* your name. Implement your classes there, and add them to the list below.
*/
+LXPattern gplay;
LXPattern[] patterns(GLucose glucose) {
return new LXPattern[] {
+
+ new Gimbal(glucose),
+
+ // DMK
// Slee
new Swarm(glucose),
+ //new ScreenScrape(glucose),
new SpaceTime(glucose),
new ShiftingPlane(glucose),
new AskewPlanes(glucose),
new CubeEQ(glucose).setEligible(false),
new PianoKeyPattern(glucose).setEligible(false),
- // Dan
- new Pong(glucose),
+ // DanH
new Noise(glucose),
+ gplay=new Play(glucose), // XXX do this properly
+ new Pong(glucose),
// Alex G
new SineSphere(glucose),
return new LXEffect[] {
new FlashEffect(lx),
new BoomEffect(glucose),
- new DesaturationEffect(lx),
- new ColorFuckerEffect(glucose),
+ //new DesaturationEffect(lx),
+ //new ColorFuckerEffect(glucose),
+ new DualBlender(glucose),
};
}
-
println("Hit the 'p' key to toggle Panda Board output");
}
+boolean[] noteState = new boolean[16];
+
void controllerChangeReceived(rwmidi.Controller cc) {
if (debugMode) {
println("CC: " + cc.toString());
}
+ //println(cc.getInput().getName());
+ int c = cc.getCC();
+ if(c==1){
+ for(int i=0; i<16; i++){
+ if(noteState[i] && i<8) { LXParameter p = glucose.patternKnobs.get(i); p.setValue(cc.getValue()/127.0); }
+ else if(noteState[i] && i<16) { try { LXParameter p = gparams.get(i-8); p.setValue(cc.getValue()/127.0); } catch(Exception e) {} }
+ }
+ }
+ if(c==2){
+ for(int i=0; i<16; i++){
+ //sif(noteState[i] && i<8) { println( gplay.Sliders ); }
+ //else if(noteState[i] && i<16) { try { LXParameter p = gparams.get(i-8); p.setValue(cc.getValue()/127.0); } catch(Exception e) {} }
+ }
+ }
+
+
+ //if(c>=16 || c<16+8){
+ // LXParameter p = gparams.get(c-16);
+ // p.setValue(c/127.0);
+ //}
}
+
void noteOnReceived(Note note) {
if (debugMode) {
println("Note On: " + note.toString());
}
+ int pitch = note.getPitch();
+ if(pitch>=36 && pitch <36+16){
+ noteState[pitch-36]=true;
+ }
}
void noteOffReceived(Note note) {
if (debugMode) {
println("Note Off: " + note.toString());
}
+ int pitch = note.getPitch();
+ if(pitch>=36 && pitch <36+16){
+ noteState[pitch-36]=false;
+ }
}
+
void logTime(String evt) {
int now = millis();
println(evt + ": " + (now - lastMillis) + "ms");
// TODO(mcslee): move into GLucose engine
for (PandaDriver p : pandaBoards) {
- p.send(colors);
+ p.sendNow(colors);
}
}
void drawBassBox(BassBox b) {
+ /*
float in = .15;
noStroke();
box(0, BassBox.EDGE_HEIGHT - in*2, Cube.CHANNEL_WIDTH-in);
translate(BassBox.EDGE_WIDTH-2*in, 0, 0);
box(0, BassBox.EDGE_HEIGHT - in*2, Cube.CHANNEL_WIDTH-in);
- popMatrix();
+ popMatrix();*/
}
ui.drawHelpTip();
}
ui.drawFPS();
+ ui.drawDanText();
}
boolean uiOn = true;
int restoreToIndex = -1;
+boolean doDual = false;
void keyPressed() {
if (mappingMode) {
mappingTool.keyPressed();
}
switch (key) {
+ case 'w':
+ doDual = !doDual;
+ break;
case '-':
case '_':
frameRate(--targetFramerate);
eyeZ = midZ + eyeR*cos(eyeA);
}
}
-
// The cubes automatically increment their y-position by Cube.EDGE_HEIGHT.
TowerMapping[] towerCubes = new TowerMapping[] {
- // DJ booth, from left to right
+
+
+ //back left cubes: temp Channel 1
+ new TowerMapping(0, Cube.EDGE_HEIGHT, 72, new CubeMapping[] {
+ new CubeMapping(0, 14, -45 , WRL),
+ new CubeMapping(18, -12, -20, WFL),
+ new CubeMapping(5, 9, 45, WRR),
+
+
+ }),
+ //back left cube tower: Channel 2
+ new TowerMapping(0, Cube.EDGE_HEIGHT, 70, new CubeMapping[] {
+ new CubeMapping(18, -2.5, 45, WRL),
+ new CubeMapping(15, -6, 45, WFR),
+ new CubeMapping(-6 , 7, 5, WRR),
+ new CubeMapping(18, 11, -5, WFL)
+
+ }),
+
+ //second from left back tower: Channel 3
+ new TowerMapping(31, Cube.EDGE_HEIGHT, 73.5, new CubeMapping[] {
+ new CubeMapping( 12.5, 5.5 , 10 , WRR),
+ new CubeMapping( 16.5, 2.5 , 30, WRR),
+ new CubeMapping( 16.5, 3, 10, WRR),
+ new CubeMapping(.5, 4.5, -10 , WFL)
+ } ),
+
+ //center tower, Channel 4
+ new TowerMapping(106, Cube.EDGE_HEIGHT, 84, new CubeMapping[] {
+ new CubeMapping( -3.5, -2, 10, WFL),
+ new CubeMapping( -11, 5, 30, WFR),
+ new CubeMapping( 13.5, 2, 15, WRR),
+ new CubeMapping(20.75, -4, 35 , WRL)
+ } ),
+
+ //second from back right tower, Channel 5
+
+ new TowerMapping(160, Cube.EDGE_HEIGHT, 78, new CubeMapping[] {
+ new CubeMapping( -31.5, -.5 , 5 , WFR),
+ new CubeMapping( 7, -.5, 60, WRL),
+ new CubeMapping( -5.5, -3, 0, WFR),
+ new CubeMapping(22 , 2 , 30 , WRL)
+ }),
+
+
+ //back right cubes: temp Channel 6
+ new TowerMapping(201, Cube.EDGE_HEIGHT, 72, new CubeMapping[] {
+ new CubeMapping(7.5, 6, 25, WRL),
+ new CubeMapping(-4.5, -0.5, 18, WFR),
+ new CubeMapping(8.5, .5, 30, WRL),
+ new CubeMapping(-7, -14, 10, WFR)
+
+ }),
+
+
+
+
+
+ //tower to the right of BASS BOX
+ new TowerMapping (192, Cube.EDGE_HEIGHT, 40, new CubeMapping[] {
+ new CubeMapping(-6, 4, -10, WRL),
+ new CubeMapping(5 ,5 , 5, WFR ),
+ new CubeMapping(-2, .5 , -3, WFL),
+ new CubeMapping(-10, 5.5 , -20, WRR )
+ }),
+
+ //end right tower in middle, right of previous tower
+ new TowerMapping (214, Cube.EDGE_HEIGHT, 37, new CubeMapping[] {
+ new CubeMapping(10,0 , 50, WRR),
+ new CubeMapping(5 ,5 , 65, WFL)
+ }),
+// // DJ booth, from back left to back right
+
+ new TowerMapping(BBX, BBY, BBZ, new CubeMapping[] {
+ new CubeMapping(3, 28, 3, WFL),
+ new CubeMapping(-2, 11.5, 10, WFR),
+ new CubeMapping(10.5, 4.5, 40, WFR)
+
+
+ }),
+
+
+
new TowerMapping(BBX, BBY, BBZ, new CubeMapping[] {
new CubeMapping(-7.25, 7.5, -25, WFR),
new CubeMapping(7.5, -15.75, 12, WRL),
+
+
}),
new TowerMapping(BBX, BBY, BBZ, new CubeMapping[] {
new CubeMapping(19.625, 5.375, -22, WFR),
new CubeMapping(78.75, 3.75, -28, WRR),
new CubeMapping(8, -15, 10, WRR),
}),
- new TowerMapping(BBX, BBY, BBZ, new CubeMapping[] {
+
+ // next two are right DJ channel
+
+ new TowerMapping(BBX, BBY, BBZ, new CubeMapping[] {
+ new CubeMapping(105, 20.5, 20, WRR),
+ new CubeMapping(6, -6, 30, WFR),
+ }),
+
+ new TowerMapping(BBX, BBY, BBZ, new CubeMapping[] {
new CubeMapping(104.75, 0, -27, WRL),
new CubeMapping(8, -15, 10, WFL),
}),
+
};
// Single cubes can be constructed directly here if you need them
Cube[] singleCubes = new Cube[] {
+ //back left channel behind speaker
+ new Cube(15, int( Cube.EDGE_HEIGHT), 39, 0, 10, 0, WRL),
+ new Cube(-6, int(Cube.EDGE_HEIGHT), 47, 0, 20, 0, WFR),
+ new Cube(0, int(2*Cube.EDGE_HEIGHT), 46, 0, 40, 0, WRR),
+
+ // Top left Channel Above DJ booth
+ new Cube(33, int(4.5*Cube.EDGE_HEIGHT ), 28, 0, 10, 0, WRR),
+ new Cube(35, int(5*Cube.EDGE_HEIGHT ), 52, 0, 10, 0, WRR),
+ new Cube(56, int(5*Cube.EDGE_HEIGHT ), 69, 0, 10, 0, WFL),
+ new Cube(76, int(5*Cube.EDGE_HEIGHT ), 61, 0, -45, 0, WRL),
+
+ //next channel to the right, same height
+ new Cube(85, int(5*Cube.EDGE_HEIGHT ), 77, 0, 20, 0, WRL),
+ new Cube(92, int(6*Cube.EDGE_HEIGHT ), 63, 0,20, 0, WRR),
+ new Cube(86, int(6*Cube.EDGE_HEIGHT ), 47, 0, -45, 0, WRL),
+ new Cube(123, int(6*Cube.EDGE_HEIGHT ), 31, 0, 20, 0, WFR),
+
+ // next channel to right, same height
+ new Cube(111, int(5*Cube.EDGE_HEIGHT ), 79, 0, 30, 0, WRL),
+ new Cube(125, int(6*Cube.EDGE_HEIGHT ), 76, 0,27, 0, WRL),
+ new Cube(144, int(5*Cube.EDGE_HEIGHT ), 44, 0, 45, 0, WRR),
+ new Cube(134, int(5*Cube.EDGE_HEIGHT ), 42, 0, 45, 0, WRL),
+
+ //next channel to right
+ new Cube(185, int(4*Cube.EDGE_HEIGHT ), 73, 0, -45, 0, WRR),
+ new Cube(170, int(5*Cube.EDGE_HEIGHT ), 58, 0,40, 0, WRL),
+ new Cube(158, int(6*Cube.EDGE_HEIGHT ), 34, 0, 40, 0, WFR),
+ new Cube(130, int(6*Cube.EDGE_HEIGHT ), 10, 0, -5, 30, WRL),
+
+ //next channel highest to the right
+ new Cube(203, int(5*Cube.EDGE_HEIGHT ), 55, 0, 35, 0, WRR),
+ new Cube(174, int(5*Cube.EDGE_HEIGHT ), 32, 0,35, 0, WFR),
+ new Cube(178, int(6.5*Cube.EDGE_HEIGHT ), 16, 0, 20 , 30, WRL),
+ new Cube(212, int(6.5*Cube.EDGE_HEIGHT ), 23, 0, 20 ,30, WRR),
+
+ //last channel
+ new Cube(204, int(5*Cube.EDGE_HEIGHT ), 28, 0, 25, 0, WFR),
+ new Cube(185, int(6*Cube.EDGE_HEIGHT ), 38, 0,40, 0, WRR),
+
// new Cube(x, y, z, rx, ry, rz, wiring),
};
// The bass box!
- BassBox bassBox = new BassBox(BBX, 0, BBZ);
-
+ //BassBox bassBox = new BassBox(BBX, 0, BBZ);
+ //test for Alex, should be commented out
+
// The speakers!
- List<Speaker> speakers = Arrays.asList(new Speaker[] {
+ //List<Speaker> speakers = Arrays.asList(new Speaker[] {
// each speaker parameter is x, y, z, rotation, the left speaker comes first
- new Speaker(-12, 6, 0, 15),
- new Speaker(TRAILER_WIDTH - Speaker.EDGE_WIDTH + 8, 6, 3, -15)
- });
+ // new Speaker(-12, 6, 0, 15),
+ // new Speaker(TRAILER_WIDTH - Speaker.EDGE_WIDTH + 8, 6, 3, -15)
+ // });
//////////////////////////////////////////////////////////////////////
// BENEATH HERE SHOULD NOT REQUIRE ANY MODIFICATION!!!! //
cubes[cubeIndex++] = cube;
}
- return new Model(towerList, cubes, bassBox, speakers);
+ return new Model(towerList, cubes, null, null);
}
/**
return new PandaMapping[] {
new PandaMapping(
- "10.200.1.29", new ChannelMapping[] {
- new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }),
- new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }),
- new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }),
- new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }),
- new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }),
- new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }),
- new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }),
- new ChannelMapping(ChannelMapping.MODE_BASS),
- new ChannelMapping(ChannelMapping.MODE_STRUTS_AND_FLOOR),
- new ChannelMapping(ChannelMapping.MODE_SPEAKER, LEFT_SPEAKER),
- new ChannelMapping(ChannelMapping.MODE_SPEAKER, RIGHT_SPEAKER),
- new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }),
- new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }),
- new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }),
- new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }),
- new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }),
+ // 8 maps to: 3, 4, 7, 8, 13, 14, 15, 16. So if it's J4,
+ "10.200.1.30", new ChannelMapping[] {
+ new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 52, 53, 54, 55}), //30 J3
+ new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 64, 65, 66, 67}), //30 J4 //ORIG
+ new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1,2,3,7 }), //30 J7
+ new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 39, 40, 38, 37}), //30 J8
+ new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 16, 17, 18, 19 }), //30 J13
+ new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 20, 21, 22, 23}), //30 J14
+ new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 24, 25, 26, 27 }), // 30 J15
+ new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 28, 29 }), // 30 J16
}),
-
+ new PandaMapping(
+ "10.200.1.29", new ChannelMapping[] {
+ new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 68, 65, 66, 67 }), //29 J3
+ new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 30,31 }), //29 J4
+ new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 20, 21, 22, 23 }), // 29 J7
+ new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 60, 61 , 62, 63 }), //29 J8 //XXX
+ new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 17, 18, 19, 20 }), //29 J13 //XX //bassbox
+ new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 24, 25, 26, 27}), //29 J14
+ new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 41,42,43,44 }), //29 J15
+ new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 16, 17,18,19 }), //29 J16
+ }),
new PandaMapping(
"10.200.1.28", new ChannelMapping[] {
- new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }),
- new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }),
- new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }),
- new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }),
- new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }),
- new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }),
- new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }),
- new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }),
- new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }),
- new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }),
- new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }),
- new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }),
- new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }),
- new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }),
- new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }),
- new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }),
- }),
- };
+ new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 56, 57, 58, 59 }), //28 J3
+ new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 64, 69 }), //28 J4
+ new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 48, 49, 50, 51 }), //28 J7
+ new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 13, 14 , 15, 16 }), //28 J8
+ new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 8,9,10,11 }), //28 J13
+ new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 35,36,34,33}), //28 J14
+ new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 12, 13, 14, 15 }), //28 J15
+ new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 30, 31, 32, 48 }), //28 J16
+ }),
+ };
+
}
+
+
class TowerMapping {
public final float x, y, z;
public final CubeMapping[] cubeMappings;
class PandaMapping {
// How many channels are on the panda board
- public final static int CHANNELS_PER_BOARD = 16;
+ public final static int CHANNELS_PER_BOARD = 8;
// How many total pixels on the whole board
public final static int PIXELS_PER_BOARD = ChannelMapping.PIXELS_PER_CHANNEL * CHANNELS_PER_BOARD;
}
int speakerIndex = rawObjectIndices[0];
if (speakerIndex < 0 || speakerIndex >= glucose.model.speakers.size()) {
- throw new RuntimeException("Invalid speaker channel mapping: " + speakerIndex);
+ //throw new RuntimeException("Invalid speaker channel mapping: " + speakerIndex);
}
} else if ((mode == MODE_STRUTS_AND_FLOOR) || (mode == MODE_BASS) || (mode == MODE_NULL)) {
if (rawObjectIndices.length > 0) {
- throw new RuntimeException("Bass/floor/null mappings cannot specify object indices");
+ //throw new RuntimeException("Bass/floor/null mappings cannot specify object indices");
}
} else if (mode == MODE_CUBES) {
for (int rawCubeIndex : rawObjectIndices) {
}
}
}
-
text("Tap 'u' to restore UI", width-4, height-6);
}
+ public void drawDanText() {
+ textFont(itemFont);
+ textAlign(LEFT);
+ fill(#FFFFFF);
+ text(DanTextLine1, 4, height-50);
+ text(DanTextLine2, 4, height-30);
+ }
+
public void drawFPS() {
textFont(titleFont);
textAlign(LEFT);
public void draw() {
drawLogoAndBackground();
+
int yPos = 0;
firstMappingY = yPos + lineHeight + 6;
yPos = drawObjectList(yPos, "MAPPING MODE", mappingModes, mappingModes, mappingModeStateMethod);
import netP5.*;
import oscP5.*;
+//import hypermedia.net.*;
+
+
+
+
/**
* DOUBLE BLACK DIAMOND DOUBLE BLACK DIAMOND
*
* This class implements the output function to the Panda Boards. It
* will be moved into GLucose once stabilized.
*/
-public static class PandaDriver {
+public static class PandaDriver extends Thread{
+ int lastSeen;
+ void start(){super.start();}
+ void run(){
+ while(true){
+ if(queue.size()>0) {
+ for(int i=0; i<queue.size(); i++){
+ this.sendNow(queue.get(queue.size()-1));
+ queue.clear();
+ }
+ } else {
+ try{sleep(1);} catch(Exception e){}
+ }
+ }
+ }
+
+ //UDP udp; // define the UDP object
// IP address
public final String ip;
public PandaDriver(String ip) {
this.ip = ip;
+ //udp = new UDP(this, 10000);
+
// Initialize our OSC output stuff
address = new NetAddress(ip, 9001);
message = new OscMessage("/shady/pointbuffer");
-
+
// Build the array of points, initialize all to nothing
points = new int[PandaMapping.PIXELS_PER_BOARD];
for (int i = 0; i < points.length; ++i) {
points[i] = NO_POINT;
}
+ this.start();
}
private final static int FORWARD = -1;
private final static int[][] LEFT_SPEAKER_STRIP_ORDERING = {
};
+
+ ArrayList<int[]> queue;
public PandaDriver(String ip, Model model, PandaMapping pm) {
this(ip);
+
+ queue = new ArrayList<int[]>();
// Ok, we are initialized, time to build the array if points in order to
// send out. We start at the head of our point buffer, and work our way
}
public final void send(int[] colors) {
- if (!enabled) {
+ queue.add(colors);
+ }
+ public final void sendNow(int[] colors) {
+ if (!enabled || colors==null) {
return;
}
int len = 0;
int packetNum = 0;
- for (int index : points) {
- int c = (index < 0) ? 0 : colors[index];
+ if(points==null) { return; }
+ for (int index: points) {
+ int c = 0;
+ if(index>0) { c= colors[index]; }
byte r = (byte) ((c >> 16) & 0xFF);
byte g = (byte) ((c >> 8) & 0xFF);
byte b = (byte) ((c) & 0xFF);
}
}
+
private void sendPacket(int packetNum) {
message.clearArguments();
message.add(packetNum);
message.add(packet.length);
message.add(packet);
try {
+ //udp.send(packet, "10.200.1.29", 9001);
OscP5.flush(message, address);
} catch (Exception x) {
x.printStackTrace();
}
}
}
-