| 1 | /** |
| 2 | * DOUBLE BLACK DIAMOND DOUBLE BLACK DIAMOND |
| 3 | * |
| 4 | * //\\ //\\ //\\ //\\ |
| 5 | * ///\\\ ///\\\ ///\\\ ///\\\ |
| 6 | * \\\/// \\\/// \\\/// \\\/// |
| 7 | * \\// \\// \\// \\//H |
| 8 | * |
| 9 | * EXPERTS ONLY!! EXPERTS ONLY!! |
| 10 | * |
| 11 | * If you are an artist, you may ignore this file! It just sets |
| 12 | * up the framework to run the patterns. Should not need modification |
| 13 | * for general animation work. |
| 14 | */ |
| 15 | |
| 16 | import glucose.*; |
| 17 | import glucose.model.*; |
| 18 | import heronarts.lx.*; |
| 19 | import heronarts.lx.effect.*; |
| 20 | import heronarts.lx.modulator.*; |
| 21 | import heronarts.lx.parameter.*; |
| 22 | import heronarts.lx.pattern.*; |
| 23 | import heronarts.lx.transform.*; |
| 24 | import heronarts.lx.transition.*; |
| 25 | import heronarts.lx.ui.*; |
| 26 | import heronarts.lx.ui.component.*; |
| 27 | import heronarts.lx.ui.control.*; |
| 28 | import ddf.minim.*; |
| 29 | import ddf.minim.analysis.*; |
| 30 | import processing.opengl.*; |
| 31 | import rwmidi.*; |
| 32 | import java.lang.reflect.*; |
| 33 | |
| 34 | final int VIEWPORT_WIDTH = 900; |
| 35 | final int VIEWPORT_HEIGHT = 700; |
| 36 | |
| 37 | // The trailer is measured from the outside of the black metal (but not including the higher welded part on the front) |
| 38 | final float TRAILER_WIDTH = 240; |
| 39 | final float TRAILER_DEPTH = 97; |
| 40 | final float TRAILER_HEIGHT = 33; |
| 41 | |
| 42 | int targetFramerate = 60; |
| 43 | int startMillis, lastMillis; |
| 44 | |
| 45 | // Core engine variables |
| 46 | GLucose glucose; |
| 47 | LX lx; |
| 48 | LXPattern[] patterns; |
| 49 | Effects effects; |
| 50 | MappingTool mappingTool; |
| 51 | PandaDriver[] pandaBoards; |
| 52 | PresetManager presetManager; |
| 53 | MidiEngine midiEngine; |
| 54 | |
| 55 | // Display configuration mode |
| 56 | boolean mappingMode = false; |
| 57 | boolean debugMode = false; |
| 58 | DebugUI debugUI; |
| 59 | boolean uiOn = true; |
| 60 | boolean simulationOn = true; |
| 61 | boolean diagnosticsOn = false; |
| 62 | LXPattern restoreToPattern = null; |
| 63 | PImage logo; |
| 64 | float[] hsb = new float[3]; |
| 65 | |
| 66 | // Handles to UI objects |
| 67 | UIPatternDeck uiPatternA; |
| 68 | UICrossfader uiCrossfader; |
| 69 | UIMidi uiMidi; |
| 70 | UIMapping uiMapping; |
| 71 | UIDebugText uiDebugText; |
| 72 | UISpeed uiSpeed; |
| 73 | |
| 74 | /** |
| 75 | * Engine construction and initialization. |
| 76 | */ |
| 77 | |
| 78 | LXTransition _transition(GLucose glucose) { |
| 79 | return new DissolveTransition(glucose.lx).setDuration(1000); |
| 80 | } |
| 81 | |
| 82 | LXPattern[] _leftPatterns(GLucose glucose) { |
| 83 | LXPattern[] patterns = patterns(glucose); |
| 84 | for (LXPattern p : patterns) { |
| 85 | p.setTransition(_transition(glucose)); |
| 86 | } |
| 87 | return patterns; |
| 88 | } |
| 89 | |
| 90 | LXPattern[] _rightPatterns(GLucose glucose) { |
| 91 | LXPattern[] patterns = _leftPatterns(glucose); |
| 92 | LXPattern[] rightPatterns = new LXPattern[patterns.length+1]; |
| 93 | int i = 0; |
| 94 | rightPatterns[i++] = new BlankPattern(glucose).setTransition(_transition(glucose)); |
| 95 | for (LXPattern p : patterns) { |
| 96 | rightPatterns[i++] = p; |
| 97 | } |
| 98 | return rightPatterns; |
| 99 | } |
| 100 | |
| 101 | LXEffect[] _effectsArray(Effects effects) { |
| 102 | List<LXEffect> effectList = new ArrayList<LXEffect>(); |
| 103 | for (Field f : effects.getClass().getDeclaredFields()) { |
| 104 | try { |
| 105 | Object val = f.get(effects); |
| 106 | if (val instanceof LXEffect) { |
| 107 | effectList.add((LXEffect)val); |
| 108 | } |
| 109 | } catch (IllegalAccessException iax) {} |
| 110 | } |
| 111 | return effectList.toArray(new LXEffect[]{}); |
| 112 | } |
| 113 | |
| 114 | void logTime(String evt) { |
| 115 | int now = millis(); |
| 116 | println(evt + ": " + (now - lastMillis) + "ms"); |
| 117 | lastMillis = now; |
| 118 | } |
| 119 | |
| 120 | void setup() { |
| 121 | startMillis = lastMillis = millis(); |
| 122 | |
| 123 | // Initialize the Processing graphics environment |
| 124 | size(VIEWPORT_WIDTH, VIEWPORT_HEIGHT, OPENGL); |
| 125 | frameRate(targetFramerate); |
| 126 | noSmooth(); |
| 127 | // hint(ENABLE_OPENGL_4X_SMOOTH); // no discernable improvement? |
| 128 | logTime("Created viewport"); |
| 129 | |
| 130 | // Create the GLucose engine to run the cubes |
| 131 | glucose = new GLucose(this, buildModel()); |
| 132 | lx = glucose.lx; |
| 133 | lx.enableKeyboardTempo(); |
| 134 | logTime("Built GLucose engine"); |
| 135 | |
| 136 | // Set the patterns |
| 137 | LXEngine engine = lx.engine; |
| 138 | engine.setPatterns(patterns = _leftPatterns(glucose)); |
| 139 | engine.addDeck(_rightPatterns(glucose)); |
| 140 | logTime("Built patterns"); |
| 141 | glucose.setTransitions(transitions(glucose)); |
| 142 | logTime("Built transitions"); |
| 143 | glucose.lx.addEffects(_effectsArray(effects = new Effects())); |
| 144 | logTime("Built effects"); |
| 145 | |
| 146 | // Preset manager |
| 147 | presetManager = new PresetManager(); |
| 148 | logTime("Loaded presets"); |
| 149 | |
| 150 | // MIDI devices |
| 151 | midiEngine = new MidiEngine(); |
| 152 | logTime("Setup MIDI devices"); |
| 153 | |
| 154 | // Build output driver |
| 155 | PandaMapping[] pandaMappings = buildPandaList(); |
| 156 | pandaBoards = new PandaDriver[pandaMappings.length]; |
| 157 | int pbi = 0; |
| 158 | for (PandaMapping pm : pandaMappings) { |
| 159 | pandaBoards[pbi++] = new PandaDriver(pm.ip, glucose.model, pm); |
| 160 | } |
| 161 | mappingTool = new MappingTool(glucose, pandaMappings); |
| 162 | logTime("Built PandaDriver"); |
| 163 | |
| 164 | // Build overlay UI |
| 165 | debugUI = new DebugUI(pandaMappings); |
| 166 | UIContext[] contexts = new UIContext[] { |
| 167 | uiPatternA = new UIPatternDeck(lx.ui, lx.engine.getDeck(GLucose.LEFT_DECK), "PATTERN A", 4, 4, 140, 324), |
| 168 | new UIBlendMode(4, 332, 140, 86), |
| 169 | new UIEffects(4, 422, 140, 144), |
| 170 | new UITempo(4, 570, 140, 50), |
| 171 | uiSpeed = new UISpeed(4, 624, 140, 50), |
| 172 | |
| 173 | new UIPatternDeck(lx.ui, lx.engine.getDeck(GLucose.RIGHT_DECK), "PATTERN B", width-144, 4, 140, 324), |
| 174 | uiMidi = new UIMidi(midiEngine, width-144, 332, 140, 158), |
| 175 | new UIOutput(width-144, 494, 140, 106), |
| 176 | |
| 177 | uiCrossfader = new UICrossfader(width/2-90, height-90, 180, 86), |
| 178 | |
| 179 | uiDebugText = new UIDebugText(148, height-138, width-304, 44), |
| 180 | uiMapping = new UIMapping(mappingTool, 4, 4, 140, 324) |
| 181 | }; |
| 182 | uiMapping.setVisible(false); |
| 183 | lx.ui.addLayer(new UICameraLayer(lx.ui).setCenter(TRAILER_WIDTH/2., glucose.model.yMax/2, TRAILER_DEPTH/2.).setRadius(290).addComponent(new UICubesLayer())); |
| 184 | for (UIContext context : contexts) { |
| 185 | lx.ui.addLayer(context); |
| 186 | } |
| 187 | logTime("Built overlay UI"); |
| 188 | |
| 189 | // Load logo image |
| 190 | logo = loadImage("data/logo.png"); |
| 191 | |
| 192 | println("Total setup: " + (millis() - startMillis) + "ms"); |
| 193 | println("Hit the 'p' key to toggle Panda Board output"); |
| 194 | } |
| 195 | |
| 196 | /** |
| 197 | * Core render loop and drawing functionality. |
| 198 | */ |
| 199 | void draw() { |
| 200 | long drawStart = System.nanoTime(); |
| 201 | |
| 202 | // Set background |
| 203 | background(40); |
| 204 | |
| 205 | // Send colors |
| 206 | color[] sendColors = glucose.getColors(); |
| 207 | if (debugMode) { |
| 208 | debugUI.maskColors(sendColors); |
| 209 | } |
| 210 | |
| 211 | long gammaStart = System.nanoTime(); |
| 212 | // Gamma correction here. Apply a cubic to the brightness |
| 213 | // for better representation of dynamic range |
| 214 | for (int i = 0; i < sendColors.length; ++i) { |
| 215 | lx.RGBtoHSB(sendColors[i], hsb); |
| 216 | float b = hsb[2]; |
| 217 | sendColors[i] = lx.hsb(360.*hsb[0], 100.*hsb[1], 100.*(b*b*b)); |
| 218 | } |
| 219 | long gammaNanos = System.nanoTime() - gammaStart; |
| 220 | |
| 221 | long sendStart = System.nanoTime(); |
| 222 | for (PandaDriver p : pandaBoards) { |
| 223 | p.send(sendColors); |
| 224 | } |
| 225 | long sendNanos = System.nanoTime() - sendStart; |
| 226 | |
| 227 | drawFPS(); |
| 228 | if (debugMode) { |
| 229 | debugUI.draw(); |
| 230 | } |
| 231 | |
| 232 | // TODO(mcslee): fix |
| 233 | long drawNanos = System.nanoTime() - drawStart; |
| 234 | |
| 235 | long simulationNanos = 0, uiNanos = 0; |
| 236 | if (diagnosticsOn) { |
| 237 | drawDiagnostics(drawNanos, simulationNanos, uiNanos, gammaNanos, sendNanos); |
| 238 | } |
| 239 | } |
| 240 | |
| 241 | class UICubesLayer extends UICameraComponent { |
| 242 | void onDraw(UI ui) { |
| 243 | color[] simulationColors = glucose.getColors(); |
| 244 | String displayMode = uiCrossfader.getDisplayMode(); |
| 245 | if (displayMode == "A") { |
| 246 | simulationColors = lx.engine.getDeck(GLucose.LEFT_DECK).getColors(); |
| 247 | } else if (displayMode == "B") { |
| 248 | simulationColors = lx.engine.getDeck(GLucose.RIGHT_DECK).getColors(); |
| 249 | } |
| 250 | if (debugMode) { |
| 251 | debugUI.maskColors(simulationColors); |
| 252 | } |
| 253 | |
| 254 | long simulationStart = System.nanoTime(); |
| 255 | if (simulationOn) { |
| 256 | drawSimulation(simulationColors); |
| 257 | } |
| 258 | long simulationNanos = System.nanoTime() - simulationStart; |
| 259 | |
| 260 | camera(); |
| 261 | javax.media.opengl.GL gl = ((PGraphicsOpenGL)g).beginGL(); |
| 262 | gl.glClear(javax.media.opengl.GL.GL_DEPTH_BUFFER_BIT); |
| 263 | ((PGraphicsOpenGL)g).endGL(); |
| 264 | strokeWeight(1); |
| 265 | } |
| 266 | } |
| 267 | |
| 268 | void drawDiagnostics(long drawNanos, long simulationNanos, long uiNanos, long gammaNanos, long sendNanos) { |
| 269 | float ws = 4 / 1000000.; |
| 270 | int thirtyfps = 1000000000 / 30; |
| 271 | int sixtyfps = 1000000000 / 60; |
| 272 | int x = width - 138; |
| 273 | int y = height - 14; |
| 274 | int h = 10; |
| 275 | noFill(); |
| 276 | stroke(#999999); |
| 277 | rect(x, y, thirtyfps * ws, h); |
| 278 | noStroke(); |
| 279 | int xp = x; |
| 280 | float hv = 0; |
| 281 | for (long val : new long[] {lx.timer.drawNanos, simulationNanos, uiNanos, gammaNanos, sendNanos }) { |
| 282 | fill(lx.hsb(hv % 360, 100, 80)); |
| 283 | rect(xp, y, val * ws, h-1); |
| 284 | hv += 140; |
| 285 | xp += val * ws; |
| 286 | } |
| 287 | noFill(); |
| 288 | stroke(#333333); |
| 289 | line(x+sixtyfps*ws, y+1, x+sixtyfps*ws, y+h-1); |
| 290 | |
| 291 | y = y - 14; |
| 292 | xp = x; |
| 293 | float tw = thirtyfps * ws; |
| 294 | noFill(); |
| 295 | stroke(#999999); |
| 296 | rect(x, y, tw, h); |
| 297 | h = 5; |
| 298 | noStroke(); |
| 299 | for (long val : new long[] { |
| 300 | lx.engine.timer.deckNanos, |
| 301 | lx.engine.timer.copyNanos, |
| 302 | lx.engine.timer.fxNanos}) { |
| 303 | float amt = val / (float) lx.timer.drawNanos; |
| 304 | fill(lx.hsb(hv % 360, 100, 80)); |
| 305 | rect(xp, y, amt * tw, h-1); |
| 306 | hv += 140; |
| 307 | xp += amt * tw; |
| 308 | } |
| 309 | |
| 310 | xp = x; |
| 311 | y += h; |
| 312 | hv = 120; |
| 313 | for (long val : new long[] { |
| 314 | lx.engine.getDeck(0).timer.runNanos, |
| 315 | lx.engine.getDeck(1).timer.runNanos, |
| 316 | lx.engine.getDeck(1).getFaderTransition().timer.blendNanos}) { |
| 317 | float amt = val / (float) lx.timer.drawNanos; |
| 318 | fill(lx.hsb(hv % 360, 100, 80)); |
| 319 | rect(xp, y, amt * tw, h-1); |
| 320 | hv += 140; |
| 321 | xp += amt * tw; |
| 322 | } |
| 323 | } |
| 324 | |
| 325 | void drawSimulation(color[] simulationColors) { |
| 326 | translate(0, 40, 0); |
| 327 | |
| 328 | noStroke(); |
| 329 | fill(#141414); |
| 330 | drawBox(0, -TRAILER_HEIGHT, 0, 0, 0, 0, TRAILER_WIDTH, TRAILER_HEIGHT, TRAILER_DEPTH, TRAILER_HEIGHT/2.); |
| 331 | fill(#070707); |
| 332 | stroke(#222222); |
| 333 | beginShape(); |
| 334 | vertex(0, 0, 0); |
| 335 | vertex(TRAILER_WIDTH, 0, 0); |
| 336 | vertex(TRAILER_WIDTH, 0, TRAILER_DEPTH); |
| 337 | vertex(0, 0, TRAILER_DEPTH); |
| 338 | endShape(); |
| 339 | |
| 340 | // Draw the logo on the front of platform |
| 341 | pushMatrix(); |
| 342 | translate(0, 0, -1); |
| 343 | float s = .07; |
| 344 | scale(s, -s, s); |
| 345 | image(logo, TRAILER_WIDTH/2/s-logo.width/2, TRAILER_HEIGHT/2/s-logo.height/2-2/s); |
| 346 | popMatrix(); |
| 347 | |
| 348 | noStroke(); |
| 349 | if (glucose.model.bassBox.exists) { |
| 350 | drawBassBox(glucose.model.bassBox, false); |
| 351 | } |
| 352 | for (Speaker speaker : glucose.model.speakers) { |
| 353 | drawSpeaker(speaker); |
| 354 | } |
| 355 | for (Cube c : glucose.model.cubes) { |
| 356 | drawCube(c); |
| 357 | } |
| 358 | |
| 359 | noFill(); |
| 360 | strokeWeight(2); |
| 361 | beginShape(POINTS); |
| 362 | for (LXPoint p : glucose.model.points) { |
| 363 | stroke(simulationColors[p.index]); |
| 364 | vertex(p.x, p.y, p.z); |
| 365 | } |
| 366 | endShape(); |
| 367 | } |
| 368 | |
| 369 | void drawBassBox(BassBox b, boolean hasSub) { |
| 370 | |
| 371 | float in = .15; |
| 372 | |
| 373 | if (hasSub) { |
| 374 | noStroke(); |
| 375 | fill(#191919); |
| 376 | pushMatrix(); |
| 377 | translate(b.x + BassBox.EDGE_WIDTH/2., b.y + BassBox.EDGE_HEIGHT/2, b.z + BassBox.EDGE_DEPTH/2.); |
| 378 | box(BassBox.EDGE_WIDTH-20*in, BassBox.EDGE_HEIGHT-20*in, BassBox.EDGE_DEPTH-20*in); |
| 379 | popMatrix(); |
| 380 | } |
| 381 | |
| 382 | noStroke(); |
| 383 | fill(#393939); |
| 384 | drawBox(b.x+in, b.y+in, b.z+in, 0, 0, 0, BassBox.EDGE_WIDTH-in*2, BassBox.EDGE_HEIGHT-in*2, BassBox.EDGE_DEPTH-in*2, Cube.CHANNEL_WIDTH-in); |
| 385 | |
| 386 | pushMatrix(); |
| 387 | translate(b.x+(Cube.CHANNEL_WIDTH-in)/2., b.y + BassBox.EDGE_HEIGHT-in, b.z + BassBox.EDGE_DEPTH/2.); |
| 388 | float lastOffset = 0; |
| 389 | for (float offset : BoothFloor.STRIP_OFFSETS) { |
| 390 | translate(offset - lastOffset, 0, 0); |
| 391 | box(Cube.CHANNEL_WIDTH-in, 0, BassBox.EDGE_DEPTH - 2*in); |
| 392 | lastOffset = offset; |
| 393 | } |
| 394 | popMatrix(); |
| 395 | |
| 396 | pushMatrix(); |
| 397 | translate(b.x + (Cube.CHANNEL_WIDTH-in)/2., b.y + BassBox.EDGE_HEIGHT/2., b.z + in); |
| 398 | for (int j = 0; j < 2; ++j) { |
| 399 | pushMatrix(); |
| 400 | for (int i = 0; i < BassBox.NUM_FRONT_STRUTS; ++i) { |
| 401 | translate(BassBox.FRONT_STRUT_SPACING, 0, 0); |
| 402 | box(Cube.CHANNEL_WIDTH-in, BassBox.EDGE_HEIGHT - in*2, 0); |
| 403 | } |
| 404 | popMatrix(); |
| 405 | translate(0, 0, BassBox.EDGE_DEPTH - 2*in); |
| 406 | } |
| 407 | popMatrix(); |
| 408 | |
| 409 | pushMatrix(); |
| 410 | translate(b.x + in, b.y + BassBox.EDGE_HEIGHT/2., b.z + BassBox.SIDE_STRUT_SPACING + (Cube.CHANNEL_WIDTH-in)/2.); |
| 411 | box(0, BassBox.EDGE_HEIGHT - in*2, Cube.CHANNEL_WIDTH-in); |
| 412 | translate(BassBox.EDGE_WIDTH-2*in, 0, 0); |
| 413 | box(0, BassBox.EDGE_HEIGHT - in*2, Cube.CHANNEL_WIDTH-in); |
| 414 | popMatrix(); |
| 415 | |
| 416 | } |
| 417 | |
| 418 | void drawCube(Cube c) { |
| 419 | float in = .15; |
| 420 | noStroke(); |
| 421 | fill(#393939); |
| 422 | drawBox(c.x+in, c.y+in, c.z+in, c.rx, c.ry, c.rz, Cube.EDGE_WIDTH-in*2, Cube.EDGE_HEIGHT-in*2, Cube.EDGE_WIDTH-in*2, Cube.CHANNEL_WIDTH-in); |
| 423 | } |
| 424 | |
| 425 | void drawSpeaker(Speaker s) { |
| 426 | float in = .15; |
| 427 | |
| 428 | noStroke(); |
| 429 | fill(#191919); |
| 430 | pushMatrix(); |
| 431 | translate(s.x, s.y, s.z); |
| 432 | rotate(s.ry / 180. * PI, 0, -1, 0); |
| 433 | translate(Speaker.EDGE_WIDTH/2., Speaker.EDGE_HEIGHT/2., Speaker.EDGE_DEPTH/2.); |
| 434 | box(Speaker.EDGE_WIDTH-20*in, Speaker.EDGE_HEIGHT-20*in, Speaker.EDGE_DEPTH-20*in); |
| 435 | translate(0, Speaker.EDGE_HEIGHT/2. + Speaker.EDGE_HEIGHT*.8/2, 0); |
| 436 | |
| 437 | fill(#222222); |
| 438 | box(Speaker.EDGE_WIDTH*.6, Speaker.EDGE_HEIGHT*.8, Speaker.EDGE_DEPTH*.75); |
| 439 | popMatrix(); |
| 440 | |
| 441 | noStroke(); |
| 442 | fill(#393939); |
| 443 | drawBox(s.x+in, s.y+in, s.z+in, 0, s.ry, 0, Speaker.EDGE_WIDTH-in*2, Speaker.EDGE_HEIGHT-in*2, Speaker.EDGE_DEPTH-in*2, Cube.CHANNEL_WIDTH-in); |
| 444 | } |
| 445 | |
| 446 | void drawBox(float x, float y, float z, float rx, float ry, float rz, float xd, float yd, float zd, float sw) { |
| 447 | pushMatrix(); |
| 448 | translate(x, y, z); |
| 449 | rotate(rx / 180. * PI, -1, 0, 0); |
| 450 | rotate(ry / 180. * PI, 0, -1, 0); |
| 451 | rotate(rz / 180. * PI, 0, 0, -1); |
| 452 | for (int i = 0; i < 4; ++i) { |
| 453 | float wid = (i % 2 == 0) ? xd : zd; |
| 454 | |
| 455 | beginShape(); |
| 456 | vertex(0, 0); |
| 457 | vertex(wid, 0); |
| 458 | vertex(wid, yd); |
| 459 | vertex(wid - sw, yd); |
| 460 | vertex(wid - sw, sw); |
| 461 | vertex(0, sw); |
| 462 | endShape(); |
| 463 | beginShape(); |
| 464 | vertex(0, sw); |
| 465 | vertex(0, yd); |
| 466 | vertex(wid - sw, yd); |
| 467 | vertex(wid - sw, yd - sw); |
| 468 | vertex(sw, yd - sw); |
| 469 | vertex(sw, sw); |
| 470 | endShape(); |
| 471 | |
| 472 | translate(wid, 0, 0); |
| 473 | rotate(HALF_PI, 0, -1, 0); |
| 474 | } |
| 475 | popMatrix(); |
| 476 | } |
| 477 | |
| 478 | void drawFPS() { |
| 479 | // Always draw FPS meter |
| 480 | fill(#555555); |
| 481 | textSize(9); |
| 482 | textAlign(LEFT, BASELINE); |
| 483 | text("FPS: " + ((int) (frameRate*10)) / 10. + " / " + targetFramerate + " (-/+)", 4, height-4); |
| 484 | } |
| 485 | |
| 486 | |
| 487 | /** |
| 488 | * Top-level keyboard event handling |
| 489 | */ |
| 490 | void keyPressed() { |
| 491 | if (mappingMode) { |
| 492 | mappingTool.keyPressed(uiMapping); |
| 493 | } |
| 494 | switch (key) { |
| 495 | case '1': |
| 496 | case '2': |
| 497 | case '3': |
| 498 | case '4': |
| 499 | case '5': |
| 500 | case '6': |
| 501 | case '7': |
| 502 | case '8': |
| 503 | if (!midiEngine.isQwertyEnabled()) { |
| 504 | presetManager.select(midiEngine.getFocusedDeck(), key - '1'); |
| 505 | } |
| 506 | break; |
| 507 | |
| 508 | case '!': |
| 509 | if (!midiEngine.isQwertyEnabled()) presetManager.store(midiEngine.getFocusedDeck(), 0); |
| 510 | break; |
| 511 | case '@': |
| 512 | if (!midiEngine.isQwertyEnabled()) presetManager.store(midiEngine.getFocusedDeck(), 1); |
| 513 | break; |
| 514 | case '#': |
| 515 | if (!midiEngine.isQwertyEnabled()) presetManager.store(midiEngine.getFocusedDeck(), 2); |
| 516 | break; |
| 517 | case '$': |
| 518 | if (!midiEngine.isQwertyEnabled()) presetManager.store(midiEngine.getFocusedDeck(), 3); |
| 519 | break; |
| 520 | case '%': |
| 521 | if (!midiEngine.isQwertyEnabled()) presetManager.store(midiEngine.getFocusedDeck(), 4); |
| 522 | break; |
| 523 | case '^': |
| 524 | if (!midiEngine.isQwertyEnabled()) presetManager.store(midiEngine.getFocusedDeck(), 5); |
| 525 | break; |
| 526 | case '&': |
| 527 | if (!midiEngine.isQwertyEnabled()) presetManager.store(midiEngine.getFocusedDeck(), 6); |
| 528 | break; |
| 529 | case '*': |
| 530 | if (!midiEngine.isQwertyEnabled()) presetManager.store(midiEngine.getFocusedDeck(), 7); |
| 531 | break; |
| 532 | |
| 533 | case '-': |
| 534 | case '_': |
| 535 | frameRate(--targetFramerate); |
| 536 | break; |
| 537 | case '=': |
| 538 | case '+': |
| 539 | frameRate(++targetFramerate); |
| 540 | break; |
| 541 | case 'b': |
| 542 | effects.boom.trigger(); |
| 543 | break; |
| 544 | case 'd': |
| 545 | if (!midiEngine.isQwertyEnabled()) { |
| 546 | debugMode = !debugMode; |
| 547 | println("Debug output: " + (debugMode ? "ON" : "OFF")); |
| 548 | } |
| 549 | break; |
| 550 | case 'm': |
| 551 | if (!midiEngine.isQwertyEnabled()) { |
| 552 | mappingMode = !mappingMode; |
| 553 | uiPatternA.setVisible(!mappingMode); |
| 554 | uiMapping.setVisible(mappingMode); |
| 555 | if (mappingMode) { |
| 556 | restoreToPattern = lx.getPattern(); |
| 557 | lx.setPatterns(new LXPattern[] { mappingTool }); |
| 558 | } else { |
| 559 | lx.setPatterns(patterns); |
| 560 | LXTransition pop = restoreToPattern.getTransition(); |
| 561 | restoreToPattern.setTransition(null); |
| 562 | lx.goPattern(restoreToPattern); |
| 563 | restoreToPattern.setTransition(pop); |
| 564 | } |
| 565 | } |
| 566 | break; |
| 567 | case 't': |
| 568 | if (!midiEngine.isQwertyEnabled()) { |
| 569 | lx.engine.setThreaded(!lx.engine.isThreaded()); |
| 570 | } |
| 571 | break; |
| 572 | case 'p': |
| 573 | for (PandaDriver p : pandaBoards) { |
| 574 | p.toggle(); |
| 575 | } |
| 576 | break; |
| 577 | case 'q': |
| 578 | if (!midiEngine.isQwertyEnabled()) { |
| 579 | diagnosticsOn = !diagnosticsOn; |
| 580 | } |
| 581 | break; |
| 582 | case 's': |
| 583 | if (!midiEngine.isQwertyEnabled()) { |
| 584 | simulationOn = !simulationOn; |
| 585 | } |
| 586 | break; |
| 587 | case 'u': |
| 588 | if (!midiEngine.isQwertyEnabled()) { |
| 589 | uiOn = !uiOn; |
| 590 | } |
| 591 | break; |
| 592 | } |
| 593 | } |
| 594 | |
| 595 | /** |
| 596 | * Top-level mouse event handling |
| 597 | */ |
| 598 | void mousePressed() { |
| 599 | if (debugMode) { |
| 600 | debugUI.mousePressed(); |
| 601 | } |
| 602 | } |
| 603 | |