From: bb3dan Date: Wed, 25 Sep 2013 06:44:11 +0000 (-0400) Subject: one more update X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=59b99905d602178f2030cff782aa057f08ca6b2c;p=SugarCubes.git one more update on dpat. now it should work --- diff --git a/DanUtil.pde b/DanUtil.pde index 9f4b3a0..08d2bc4 100644 --- a/DanUtil.pde +++ b/DanUtil.pde @@ -1,6 +1,7 @@ //---------------------------------------------------------------------------------------------------------------------------------- float xdMax,ydMax,zdMax; int NumApcRows = 5, NumApcCols = 8; +DGlobals DG = new DGlobals(); 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; } @@ -19,7 +20,6 @@ public class _DhP extends BasicParameter { void Set (double value) { super.setValue(value); } void reset () { super.setValue(dflt); } float Val () { return getValuef(); } - boolean ZeroOrOne () { return Val()==0 || Val() == 1; } } //---------------------------------------------------------------------------------------------------------------------------------- public class xyz { float x,y,z; @@ -63,22 +63,10 @@ public class xyz { float x,y,z; } //---------------------------------------------------------------------------------------------------------------------------------- public class DGlobals { - - DGlobals() { - midiEngine.addListener(new MidiEngineListener() { - public void onFocusedDeck(int deckIndex) { - if (isFocused()) { - UpdateLights(); - SetText(); - } - } - }); - } - boolean bInit = false; MidiOutput APCOut = null; MidiInput APCIn = null, OxygenIn = null; - DPat CurPat = null, NextPat = null; + DPat CurPat = null;// NextPat = null; boolean _XSym = false, _YSym = false, _ZSym = false, _RSym = false; String Text1 = "", Text2 = ""; @@ -101,21 +89,15 @@ public class DGlobals { float _Spark () { return Sliders[6]; } float _Wiggle () { return Sliders[7]; } - boolean isFocused () { - return CurPat == midiEngine.getFocusedDeck().getActivePattern(); - } - void Init () { if (bInit) return; bInit=true; - for (MidiOutputDevice output : RWMidi.getOutputDevices()) { - if (APCOut == null && output.toString().contains("APC")) APCOut = output.createOutput(); - } + for (MidiOutputDevice output : RWMidi.getOutputDevices()) { if (APCOut == null && output.toString().contains("APC")) APCOut = output.createOutput(); } + for (MidiInputDevice input : RWMidi.getInputDevices ()) { if (input.toString().contains("APC")) input.createInput (this); } } void SetText() { if (!isFocused()) return; - Text1 = ""; Text2 = ""; Text1 += " XSym: " + (_XSym ? "ON" : "OFF") + " "; Text1 += " YSym: " + (_YSym ? "ON" : "OFF") + " "; @@ -132,26 +114,16 @@ public class DGlobals { uiDebugText.setText(Text1, Text2); } - public boolean controllerChangeReceived(rwmidi.Controller cc) { - if (cc.getCC() == 7 && btwn(cc.getChannel(),0,7)) { - Sliders[cc.getChannel()] = 1.*cc.getValue()/127.; - return true; - } - //else { println(cc.getCC() + " " + cc.getChannel() + " " + cc.getValue()); } - return false; - } - - void Deactivate (DPat p) { if (p == CurPat) { uiDebugText.setText(""); CurPat = NextPat; } NextPat = null; } + 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) { - NextPat = CurPat; CurPat = p; + CurPat = p; while (lx.tempo.bpm() > 40) lx.tempo.setBpm(lx.tempo.bpm()/2); for (int i=0; i 40) bpm/=2; lx.tempo.setBpm(bpm); lx.tempo.trigger(); Tap1=0; println("Tap Set - " + bpm + " bpm"); - consumed = true; } UpdateLights(); - return consumed; } - public boolean noteOnReceived (Note note) { - if (CurPat == null) return false; + void noteOnReceived (Note note) { + if (!isFocused()) return; int row = mapRow(note.getPitch()), col = note.getChannel(); - if (row == 50 && col == 0) { lx.tempo.trigger(); Tap1 = getNow(); return true; } - else if (row == 82 && col == 0) { _XSym = !_XSym ; return true; } - else if (row == 83 && col == 0) { _YSym = !_YSym ; return true; } - else if (row == 84 && col == 0) { _ZSym = !_ZSym ; return true; } - else if (row == 85 && col == 0) { _RSym = !_RSym ; return true; } + 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) _RSym = !_RSym ; else { for (int i=0; i 0) P.y += DG._Spark () * (noise(P.x,P.y+NoiseMove/30 ,P.z)*ydMax - ydMax/2.); if (DG._Wiggle() > 0) P.y += DG._Wiggle() * (noise(P.x/(xdMax*.3)-NoiseMove/1500.) - .5) * (ydMax/2.); @@ -320,4 +278,4 @@ public class DPat extends SCPattern } } } -//---------------------------------------------------------------------------------------------------------------------------------- +//---------------------------------------------------------------------------------------------------------------------------------- \ No newline at end of file