-public class xyz { float x,y,z; // extends pVector; eliminate half of the functions
- xyz() {x=y=z=0;}
- xyz(Point p ) {x=p.x ; y=p.y; z=p.z;}
- xyz(xyz p ) {set(p); }
- xyz(float _x,float _y,float _z) {x=_x ; y=_y ; z=_z ;}
- void set(Point p ) {x=p.x ; y=p.y; z=p.z;}
- void set(xyz p ) {x=p.x ; y=p.y ; z=p.z ;}
- void set(float _x,float _y,float _z) {x=_x ; y=_y ; z=_z ;}
-
- void zoomX (float zx) {x = x*zx - mMax.x*(zx-1)/2; }
- void zoomY (float zy) {y = y*zy - mMax.y*(zy-1)/2; }
-
- float distance(xyz b) {return dist(x,y,z,b.x,b.y,b.z); }
- float distance(float _x, float _y) {return dist(x,y,_x,_y); }
- float dot (xyz b) {return x*b.x + y*b.y + z*b.z; }
- void add (xyz b) {x += b.x; y += b.y; z += b.z; }
- void add (float b) {x += b ; y += b ; z += b ; }
- void subtract(xyz b) {x -= b.x; y -= b.y; z -= b.z; }
- void scale (float b) {x *= b ; y *= b ; z *= b ; }
-
- void RotateZ (xyz o, float nSin, float nCos) {
- float nX = nCos*(x-o.x) - nSin*(y-o.y) + o.x;
- float nY = nSin*(x-o.x) + nCos*(y-o.y) + o.y;
- x = nX; y = nY;
- }
-
- void RotateX (xyz o, float nSin, float nCos) {
- float nY = nCos*(y-o.y) - nSin*(z-o.z) + o.y;
- float nZ = nSin*(y-o.y) + nCos*(z-o.z) + o.z;
- y = nY; z = nZ;
- }
-
- void RotateY (xyz o, float nSin, float nCos) {
- float nZ = nCos*(z-o.z) - nSin*(x-o.x) + o.z;
- float nX = nSin*(z-o.z) + nCos*(x-o.x) + o.x;
- z = nZ; x = nX;
- }
-
- void setRand () { x = random(mMax.x); y = random(mMax.y); z = random(mMax.z); }
- void setNorm () { x /= mMax.x; y /= mMax.y; z /= mMax.z; }
- void interpolate(float i, xyz d) { x = interp(i,x,d.x); y = interp(i,y,d.y); z = interp(i,z,d.z); }
-}
-//----------------------------------------------------------------------------------------------------------------------------------
-public class DGlobals {
- boolean bInit = false;
- MidiOutput APCOut = null;
- MidiInput APCIn = null, OxygenIn = null;
- DPat CurPat = null;
- int KeyPressed = -1;
- boolean bSustain = false;
-
-
- float Sliders[] = new float [] {1,0,0,0,0,0,0,0};
- String SliderText[] = new String[] {"Level", "SpinHue", "Spark", "Xwave", "Ywave", "Trails", "Quant", "??", "??"};
-
- void SetNoteOn (int row, int col, int clr){ if (APCOut != null) APCOut.sendNoteOn (col, row, clr); }
- void SetNoteOff (int row, int col, int clr){ if (APCOut != null) APCOut.sendNoteOff (col, row, clr); }
- void SetKnob (int cc , int c , int v ){ if (APCOut != null) APCOut.sendController (cc , c, v); }
-
- DBool GetBool (int i) { return (DBool)CurPat.bools .get(i); }
- Pick GetPick (int i) { return (Pick) CurPat.picks .get(i); }
- DParam GetParam(int i) { return (DParam) CurPat.params.get(i); }
-
- float _Level () { return Sliders[0]; }
- float _SpinHue () { return Sliders[1]; }
- float _Spark () { return Sliders[2]; }
- float _XWave () { return Sliders[3]; }
- float _YWave () { return Sliders[4]; }
- float _Trails () { return Sliders[5]; }
- float _Quantize () { return Sliders[6]; }
-
- void Init () {
- if (bInit) return; bInit=true;
- for (MidiOutputDevice o: RWMidi.getOutputDevices()) { if (o.toString().contains("APC")) { APCOut = o.createOutput(); break;}}
- for (MidiInputDevice i: RWMidi.getInputDevices ()) { if (i.toString().contains("APC")) { i.createInput (this); break;}}
- }
-
- boolean isFocused () { return CurPat != null && CurPat == midiEngine.getFocusedDeck().getActivePattern(); }
- void Deactivate (DPat p) { if (p != CurPat) return; uiDebugText.setText(""); CurPat = null; }
- void Activate (DPat p) {
- bSustain = false;
- CurPat = p;
- while (lx.tempo.bpm() > 40) lx.tempo.setBpm(lx.tempo.bpm()/2);
- for (int i=0; i<p.params.size(); i++) GetParam(i).reset();
- for (int i=0; i<p.bools .size(); i++) GetBool (i).reset();
- for (int i=0; i<p.picks .size(); i++) GetPick (i).reset();
- UpdateLights();
- }
-
- void SetText() {
- if (!isFocused()) return;
- String Text1="", Text2="";
- for (int i=0; i<CurPat.bools.size(); i++) if (GetBool(i).b) Text1 += " " + GetBool(i).tag + " ";
- for (int i=0; i<CurPat.picks.size(); i++) Text1 += GetPick(i).tag + ": " + GetPick(i).CurDesc() + " ";
- for (int i=0; i<8; i++) Text2 += SliderText[i] + ": " + round(100*Sliders[i]) + " ";
- uiDebugText.setText(Text1, Text2);
- }
-
- void UpdateLights() {
- if (!isFocused() || APCOut == null) return;
- for (int i=53;i< 58; i++) for (int j=0; j<NumApcCols; j++) SetNoteOn(i, j, 0);
- for (int i=48;i< 56; i++) SetKnob(0, i, 0);
- for (int i=16;i< 20; i++) SetKnob(0, i, 0);