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;
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 = "";
void Init () {
if (bInit) return; bInit=true;
- 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);
- }
+ 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") + " ";
uiDebugText.setText(Text1, Text2);
}
- void controllerChangeReceived(rwmidi.Controller cc) {
- if (cc.getCC() == 7 && btwn(cc.getChannel(),0,7)) { Sliders[cc.getChannel()] = 1.*cc.getValue()/127.; }
- else if (cc.getCC() == 15 && cc.getChannel() == 0) {
- lx.engine.getDeck(1).getCrossfader().setValue( 1.*cc.getValue()/127.);
- }
-
- //else { println(cc.getCC() + " " + cc.getChannel() + " " + cc.getValue()); }
- }
-
- 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<p.paramlist.size(); i++) ((_DhP)p.paramlist.get(i)).reset();
UpdateLights();
double Tap1 = 0;
double getNow() { return millis() + 1000*second() + 60*1000*minute() + 3600*1000*hour(); }
+
+ void controllerChangeReceived(rwmidi.Controller cc) {
+ if (cc.getCC() == 7 && btwn(cc.getChannel(),0,7)) { Sliders[cc.getChannel()] = 1.*cc.getValue()/127.; }
+ }
+
void noteOffReceived(Note note) {
- if (CurPat == null) return;
+ if (!isFocused()) return;
int row = DG.mapRow(note.getPitch()), col = note.getChannel();
if (row == 50 && col == 0 && btwn(getNow() - Tap1,5000,300*1000)) { // hackish tapping mechanism
}
void noteOnReceived (Note note) {
- if (CurPat == null) return;
+ if (!isFocused()) return;
int row = mapRow(note.getPitch()), col = note.getChannel();
if (row == 50 && col == 0) { lx.tempo.trigger(); Tap1 = getNow(); }
(sqrt(v1.minus(c).dot(v1.minus(c))) * sqrt(v2.minus(c).dot(v2.minus(c))) ) )); }
void StartRun(double deltaMs) { }
color CalcPoint(xyz p) { return color(0,0,0); }
- boolean IsActive() { return this == DG.CurPat; }
- void onInactive() { DG.Deactivate(this); }
- void onActive () { DG.Activate(this); }
+ boolean IsActive() { return this == DG.CurPat; }
+ boolean IsFocused() { return this == midiEngine.getFocusedDeck().getActivePattern(); }
+ void onInactive() { UpdateState(); }
+ void onActive () { UpdateState(); }
+ void UpdateState() { if (IsFocused() != IsActive()) { if (IsFocused()) DG.Activate(this); else DG.Deactivate(this); } }
_DhP addParam(String label, double value) {
_DhP P = new _DhP(label, value);
void run(double deltaMs)
{
+ UpdateState();
NoiseMove += deltaMs;
StartRun (deltaMs);
zSpinHue += DG._SpinHue ()*deltaMs*.05;
xyz P = new xyz();
float modhue = DG._ModHue ()==0 ? 0 : DG._ModHue ()*360;
float fSharp = 1/(1.01-pSharp.Val());
-
DG.SetText();
nPoint = 0;
for (Point p : model.points) { nPoint++;
- if (!IsActive()) { colors[p.index] = color(0,0,0); continue; }
-
P.set(p);
-
if (DG._Spark () > 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.);
}
}
}
-//----------------------------------------------------------------------------------------------------------------------------------
+//----------------------------------------------------------------------------------------------------------------------------------
\ No newline at end of file