APC40 is mapped, update UI to reflect that and use GLucose internals
[SugarCubes.git] / _Internals.pde
index a103f13ace4630df806fb6b3f67dcc26f7686926..46c39390dcf93ac1dfe29deaee243eba0c36efa5 100644 (file)
@@ -44,6 +44,8 @@ LXTransition[] transitions;
 LXEffect[] effects;
 OverlayUI ui;
 
+boolean debugMode = false;
+
 void setup() {
   startMillis = lastMillis = millis();
 
@@ -57,6 +59,7 @@ void setup() {
   // Create the GLucose engine to run the cubes
   glucose = new GLucose(this, new SCMapping());
   lx = glucose.lx;
+  lx.enableKeyboardTempo();
   logTime("Built GLucose engine");
   
   // Set the patterns
@@ -64,7 +67,7 @@ void setup() {
   logTime("Built patterns");
   glucose.lx.addEffects(effects = effects(glucose));
   logTime("Built effects");
-  transitions = transitions(glucose);
+  glucose.setTransitions(transitions = transitions(glucose));
   logTime("Built transitions");
   
   // Build overlay UI
@@ -72,12 +75,33 @@ void setup() {
   logTime("Built overlay UI");
     
   // MIDI devices
-  SCMidiDevices.initializeStandardDevices(glucose, ui.patternKnobs, ui.transitionKnobs, ui.effectKnobs);
+  for (MidiInputDevice d : RWMidi.getInputDevices()) {
+    d.createInput(this);
+  }
+  SCMidiDevices.initializeStandardDevices(glucose);
   logTime("Setup MIDI devices");
   
   println("Total setup: " + (millis() - startMillis) + "ms");
 }
 
+void controllerChangeReceived(rwmidi.Controller cc) {
+  if (debugMode) {
+    println("CC: " + cc.toString());
+  }
+}
+
+void noteOnReceived(Note note) {
+  if (debugMode) {
+    println("Note On: " + note.toString());
+  }
+}
+
+void noteOffReceived(Note note) {
+  if (debugMode) {
+    println("Note Off: " + note.toString());
+  }
+}
+
 void logTime(String evt) {
   int now = millis();
   println(evt + ": " + (now - lastMillis) + "ms");
@@ -102,12 +126,13 @@ boolean uiOn = true;
 boolean knobsOn = true;
 void keyPressed() {
   switch (key) {
+    case 'd':
+      debugMode = !debugMode;
+      println("Debug output: " + (debugMode ? "ON" : "OFF"));
+      break;
     case 'u':
       uiOn = !uiOn;
       break;
-    case 'k':
-      knobsOn = !knobsOn;
-      break;
   }
 }