From: Alexander Green Date: Fri, 6 Sep 2013 09:46:21 +0000 (-0700) Subject: This is the working branch from my desktop, that drives the cubes well with no bugs... X-Git-Url: https://git.piment-noir.org/?p=SugarCubes.git;a=commitdiff_plain;h=e28f168cec8ae5a8c25cae159af94f5b0aa7b342 This is the working branch from my desktop, that drives the cubes well with no bugs, and displays Dan Horwitz's text. It may already be committed in another branch but I am unsure. --- diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 diff --git a/AlexGreen.pde b/AlexGreen.pde old mode 100644 new mode 100755 index 9e53975..f73c26d --- a/AlexGreen.pde +++ b/AlexGreen.pde @@ -1,4 +1,4 @@ -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); @@ -52,34 +52,38 @@ final Sphery[] spherys; 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; } - } -} + } + diff --git a/Audio.pde b/Audio.pde old mode 100644 new mode 100755 diff --git a/BenMorrow.pde b/BenMorrow.pde old mode 100644 new mode 100755 index e610155..9314c3c --- a/BenMorrow.pde +++ b/BenMorrow.pde @@ -183,4 +183,4 @@ class DriveableCrossSections extends CrossSections } } -} \ No newline at end of file +} diff --git a/DanHorwitz.pde b/DanHorwitz.pde old mode 100644 new mode 100755 index 5435e62..3b7e1d6 --- a/DanHorwitz.pde +++ b/DanHorwitz.pde @@ -1,371 +1,216 @@ -//---------------------------------------------------------------------------------------------------------------------------------- -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; i0) 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 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 (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 +//---------------------------------------------------------------------------------------------------------------------------------- +public class Pong extends DPat { + SinLFO x,y,z,dx,dy,dz; + float cRad; _DhP pSize; + Pick pChoose; + + Pong(GLucose glucose) { + super(glucose); + cRad = xdMax/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, xdMax - cRad, 0)).trigger(); x.modulateDurationBy(dx); + addModulator(y = new SinLFO(cRad, ydMax - cRad, 0)).trigger(); y.modulateDurationBy(dy); + addModulator(z = new SinLFO(cRad, zdMax - cRad, 0)).trigger(); z.modulateDurationBy(dz); + pSize = addParam ("Size" , 0.4 ); + pChoose = addPick ("Animiation" , 0 , 3 ); + } + + void StartRun(int deltaMs) { cRad = xdMax*pSize.Val()/6; } + color CalcPoint(xyz p) { + xyz v = new xyz(x.getValuef(), y.getValuef(), z.getValuef()); + switch(pChoose.Cur()) { + case 0: return color(0,0,c1c(1 - min(v.distance(p), v.distance(xyzdMax.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(xdMax/2,0,zdMax/2)) * max(.02,.45-pSize.Val()))); // spot + } + return color(0,0,0); + } +} +//---------------------------------------------------------------------------------------------------------------------------------- +public class NDat { + float xz, yz, zz, hue, sat, speed, angle, den; + float xoff,yoff,zoff; + NDat (float _hue, float _sat, float _xz, float _yz, float _zz, float _den, float _speed, float _angle) { + hue=_hue; sat=_sat; xz=_xz; yz=_yz; zz =_zz; 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), zTheta=0; + float rtime = 0, ttime = 0, transAdd=0; + int XSym=1,YSym=2,RadSym=3; + int iSymm; + ArrayList noises = new ArrayList(); + _DhP pSpeed , pDensity, pRotZ; + Pick pChoose, pSymm; + + Noise(GLucose glucose) { + super(glucose); + pRotZ = addParam("RotZ" , .5 ); pSpeed = addParam("Fast", .55); + pDensity= addParam("Dens" , .5); + pSymm = addPick("Symmetry", 0, 4); pChoose = addPick("Animation", 1, 6); + } + + void StartRun(int deltaMs) { + zTime += deltaMs*(pSpeed.Val()-.5)*.002 ; + zTheta += deltaMs*(pRotZ .Val()-.5)*.01 ; + rtime += deltaMs; + iSymm = pSymm.Cur(); + 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 den mph angle + case 0: noises.add(new NDat(0 ,0 ,75 ,75 ,150,45 ,3 ,0 )); pSharp.Set(1 ); break; // drip + case 1: noises.add(new NDat(0 ,0 ,100,100,200,45 ,3 ,180)); pSharp.Set(0 ); break; // clouds + case 2: noises.add(new NDat(0 ,0 ,2 ,400,2 ,20 ,3 ,0 )); pSharp.Set(.5); break; // rain + case 3: noises.add(new NDat(40 ,1 ,100,100,200,10 ,1 ,180)); + noises.add(new NDat(0 ,1 ,100,100,200,10 ,5 ,180)); pSharp.Set(0 ); break; // fire 1 + case 4: noises.add(new NDat(0 ,1 ,40 ,40 ,40 ,15 ,2.5,180)); + noises.add(new NDat(20 ,1 ,40 ,40 ,40 ,15 ,4 ,0 )); + noises.add(new NDat(40 ,1 ,40 ,40 ,40 ,15 ,2 ,90 )); + noises.add(new NDat(60 ,1 ,40 ,40 ,40 ,15 ,3 ,-90)); pSharp.Set(.5); break; // machine + case 5: noises.add(new NDat(0 ,1 ,400,100,2 ,15 ,3 ,90 )); + noises.add(new NDat(20 ,1 ,400,100,2 ,15 ,2.5,0 )); + noises.add(new NDat(40 ,1 ,100,100,2 ,15 ,2 ,180)); + noises.add(new NDat(60 ,1 ,100,100,2 ,15 ,1.5,270)); pSharp.Set(.5); break; // spark + } + } + + } + + color CalcPoint(xyz P) { + color c = 0; + xyz v = P.RotateZ(xyzMid,zTheta); + if (iSymm == XSym && v.x > xdMax/2) v.x = xdMax-v.x; + if (iSymm == YSym && v.y > ydMax/2) v.y = ydMax-v.y; + + for (int i=0;i0) P = P.RotateZ(xyzHalf, Theta.x); + if (Theta.y>0) P = P.RotateZ(xyzHalf, Theta.y); + if (Theta.z>0) P = P.RotateZ(xyzHalf, Theta.z); + + 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)*150?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 + + case 9: return color(100 + noise(P.x,P.y,P.z + (NoiseMove+50000)/1000.)*200, + 85,c1c(P.y < noise(P.x + NoiseMove/2000.,P.z)*(1+a)-a/2.-.1 ? 1 : 0)); // + } + + + switch (pForm.Cur()) { + case 0: return color(0,0,c1c(1 - V.distance(P)/pRad.getValuef() > .5?1:0)); + case 1: return color(0,0,c1c(P.y < V.y ?1:0)); + case 2: return color(0,0,c1c(1 - V.distance(P)/pRad.getValuef())); + + default: return color(0,0,c1c(P.y < V.y ?1:0)); + } + } +} +//---------------------------------------------------------------------------------------------------------------------------------- diff --git a/DanKaminsky.pde b/DanKaminsky.pde new file mode 100644 index 0000000..59bde73 --- /dev/null +++ b/DanKaminsky.pde @@ -0,0 +1,268 @@ +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; i0; i--){ + frames[i] = frames[i-1]; + } + frames[0] = new int[model.points.size()]; + + for(int i=0; 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 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 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= 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 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 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 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; + } +} +//---------------------------------------------------------------------------------------------------------------------------------- diff --git a/GranimPattern.pde b/GranimPattern.pde old mode 100644 new mode 100755 diff --git a/JR.pde b/JR.pde new file mode 100755 index 0000000..ec0923f --- /dev/null +++ b/JR.pde @@ -0,0 +1,280 @@ +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) + ); +} + diff --git a/JackStahl.pde b/JackStahl.pde old mode 100644 new mode 100755 diff --git a/MarkSlee.pde b/MarkSlee.pde old mode 100644 new mode 100755 diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/SamMorrow.pde b/SamMorrow.pde old mode 100644 new mode 100755 diff --git a/ShaheenGandhi.pde b/ShaheenGandhi.pde old mode 100644 new mode 100755 diff --git a/SugarCubes.pde b/SugarCubes.pde index dac639a..4722852 100644 --- a/SugarCubes.pde +++ b/SugarCubes.pde @@ -22,12 +22,18 @@ * 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), @@ -40,9 +46,10 @@ LXPattern[] patterns(GLucose 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), @@ -105,8 +112,8 @@ LXEffect[] effects(GLucose 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), }; } - diff --git a/TestPatterns.pde b/TestPatterns.pde old mode 100644 new mode 100755 diff --git a/TimBavaro.pde b/TimBavaro.pde old mode 100644 new mode 100755 diff --git a/TobySegaran.pde b/TobySegaran.pde old mode 100644 new mode 100755 diff --git a/_Internals.pde b/_Internals.pde index a358f1b..e2291fb 100644 --- a/_Internals.pde +++ b/_Internals.pde @@ -124,24 +124,56 @@ void setup() { 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"); @@ -217,11 +249,12 @@ void draw() { // TODO(mcslee): move into GLucose engine for (PandaDriver p : pandaBoards) { - p.send(colors); + p.sendNow(colors); } } void drawBassBox(BassBox b) { + /* float in = .15; noStroke(); @@ -263,7 +296,7 @@ void drawBassBox(BassBox b) { 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();*/ } @@ -335,16 +368,21 @@ void drawUI() { 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); @@ -426,4 +464,3 @@ void mouseWheel(int delta) { eyeZ = midZ + eyeR*cos(eyeA); } } - diff --git a/_Mappings.pde b/_Mappings.pde index 3932f0b..a07c6d4 100644 --- a/_Mappings.pde +++ b/_Mappings.pde @@ -46,10 +46,94 @@ public Model buildModel() { // 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), @@ -63,27 +147,76 @@ public Model buildModel() { 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 speakers = Arrays.asList(new Speaker[] { + //List 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!!!! // @@ -110,7 +243,7 @@ public Model buildModel() { cubes[cubeIndex++] = cube; } - return new Model(towerList, cubes, bassBox, speakers); + return new Model(towerList, cubes, null, null); } /** @@ -123,47 +256,45 @@ public PandaMapping[] buildPandaList() { 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; @@ -204,7 +335,7 @@ class CubeMapping { 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; @@ -277,11 +408,11 @@ class ChannelMapping { } 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) { @@ -297,4 +428,3 @@ class ChannelMapping { } } } - diff --git a/_Overlay.pde b/_Overlay.pde index b071128..f1bc1d4 100644 --- a/_Overlay.pde +++ b/_Overlay.pde @@ -75,6 +75,14 @@ abstract class OverlayUI { 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); @@ -630,6 +638,7 @@ class MappingUI extends OverlayUI { public void draw() { drawLogoAndBackground(); + int yPos = 0; firstMappingY = yPos + lineHeight + 6; yPos = drawObjectList(yPos, "MAPPING MODE", mappingModes, mappingModes, mappingModeStateMethod); diff --git a/_PandaDriver.pde b/_PandaDriver.pde index d2998a7..2c8b96c 100644 --- a/_PandaDriver.pde +++ b/_PandaDriver.pde @@ -1,6 +1,11 @@ import netP5.*; import oscP5.*; +//import hypermedia.net.*; + + + + /** * DOUBLE BLACK DIAMOND DOUBLE BLACK DIAMOND * @@ -14,7 +19,23 @@ import oscP5.*; * 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; public PandaDriver(String ip, Model model, PandaMapping pm) { this(ip); + + queue = new ArrayList(); // 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 @@ -295,13 +323,18 @@ public static class PandaDriver { } 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); @@ -323,16 +356,17 @@ public static class PandaDriver { } } + 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(); } } } - diff --git a/code/GLucose.jar b/code/GLucose.jar old mode 100644 new mode 100755 index 88f7e08..39466d6 Binary files a/code/GLucose.jar and b/code/GLucose.jar differ diff --git a/code/HeronLX.jar b/code/HeronLX.jar old mode 100644 new mode 100755 diff --git a/code/ScreenShot.dll b/code/ScreenShot.dll new file mode 100755 index 0000000..68a6c99 Binary files /dev/null and b/code/ScreenShot.dll differ diff --git a/code/ScreenShot.jar b/code/ScreenShot.jar new file mode 100755 index 0000000..c75b8de Binary files /dev/null and b/code/ScreenShot.jar differ diff --git a/code/oscP5.jar b/code/oscP5.jar old mode 100644 new mode 100755 diff --git a/code/rwmidi.jar b/code/rwmidi.jar old mode 100644 new mode 100755 diff --git a/code/toxiclibscore.jar b/code/toxiclibscore.jar old mode 100644 new mode 100755 diff --git a/data/logo-sm.png b/data/logo-sm.png old mode 100644 new mode 100755