final float TRAILER_DEPTH = 97;
final float TRAILER_HEIGHT = 33;
-final int MaxCubeHeight = 7;
-final int NumBackTowers = 9;
+final int MaxCubeHeight = 5;
+final int NumBackTowers = 11;
int targetFramerate = 60;
int startMillis, lastMillis;
LXPattern[] patterns;
MappingTool mappingTool;
PandaDriver[] pandaBoards;
+PresetManager presetManager;
MidiEngine midiEngine;
// Display configuration mode
boolean uiOn = true;
LXPattern restoreToPattern = null;
PImage logo;
+float[] hsb = new float[3];
// Handles to UI objects
UIContext[] overlays;
lx.enableKeyboardTempo();
logTime("Built GLucose engine");
- // MIDI devices
- midiEngine = new MidiEngine();
- logTime("Setup MIDI devices");
-
// Set the patterns
- Engine engine = lx.engine;
+ LXEngine engine = lx.engine;
engine.setPatterns(patterns = _leftPatterns(glucose));
engine.addDeck(_rightPatterns(glucose));
logTime("Built patterns");
logTime("Built transitions");
glucose.lx.addEffects(effects(glucose));
logTime("Built effects");
-
+
+ // Preset manager
+ presetManager = new PresetManager();
+ logTime("Loaded presets");
+
+ // MIDI devices
+ midiEngine = new MidiEngine();
+ logTime("Setup MIDI devices");
+
// Build output driver
PandaMapping[] pandaMappings = buildPandaList();
pandaBoards = new PandaDriver[pandaMappings.length];
// Build overlay UI
debugUI = new DebugUI(pandaMappings);
overlays = new UIContext[] {
- uiPatternA = new UIPatternDeck(lx.engine.getDeck(0), "PATTERN A", 4, 4, 140, 324),
+ uiPatternA = new UIPatternDeck(lx.engine.getDeck(GLucose.LEFT_DECK), "PATTERN A", 4, 4, 140, 324),
new UIBlendMode(4, 332, 140, 86),
new UIEffects(4, 422, 140, 144),
new UITempo(4, 570, 140, 50),
new UISpeed(4, 624, 140, 50),
- new UIPatternDeck(lx.engine.getDeck(1), "PATTERN B", width-144, 4, 140, 324),
+ new UIPatternDeck(lx.engine.getDeck(GLucose.RIGHT_DECK), "PATTERN B", width-144, 4, 140, 324),
uiMidi = new UIMidi(midiEngine, width-144, 332, 140, 158),
new UIOutput(width-144, 494, 140, 106),
void draw() {
// Draws the simulation and the 2D UI overlay
background(40);
- color[] colors = glucose.getColors();
+ color[] simulationColors;
+ color[] sendColors;
+ simulationColors = sendColors = glucose.getColors();
String displayMode = uiCrossfader.getDisplayMode();
if (displayMode == "A") {
- colors = lx.engine.getDeck(0).getColors();
+ simulationColors = lx.engine.getDeck(0).getColors();
} else if (displayMode == "B") {
- colors = lx.engine.getDeck(1).getColors();
+ simulationColors = lx.engine.getDeck(1).getColors();
}
if (debugMode) {
- debugUI.maskColors(colors);
+ debugUI.maskColors(simulationColors);
+ debugUI.maskColors(sendColors);
}
camera(
strokeWeight(2);
beginShape(POINTS);
for (Point p : glucose.model.points) {
- stroke(colors[p.index]);
- vertex(p.fx, p.fy, p.fz);
+ stroke(simulationColors[p.index]);
+ vertex(p.x, p.y, p.z);
}
endShape();
// 2D Overlay UI
drawUI();
- // Send output colors
- color[] sendColors = glucose.getColors();
- if (debugMode) {
- debugUI.maskColors(sendColors);
- }
-
// Gamma correction here. Apply a cubic to the brightness
// for better representation of dynamic range
for (int i = 0; i < sendColors.length; ++i) {
- float b = brightness(sendColors[i]) / 100.f;
- sendColors[i] = color(
- hue(sendColors[i]),
- saturation(sendColors[i]),
- (b*b*b) * 100.
- );
+ lx.RGBtoHSB(sendColors[i], hsb);
+ float b = hsb[2];
+ sendColors[i] = lx.hsb(360.*hsb[0], 100.*hsb[1], 100.*(b*b*b));
}
// TODO(mcslee): move into GLucose engine
mappingTool.keyPressed(uiMapping);
}
switch (key) {
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ if (!midiEngine.isQwertyEnabled()) {
+ presetManager.select(midiEngine.getFocusedDeck(), key - '1');
+ }
+ break;
+
+ case '!':
+ if (!midiEngine.isQwertyEnabled()) presetManager.store(midiEngine.getFocusedDeck(), 0);
+ break;
+ case '@':
+ if (!midiEngine.isQwertyEnabled()) presetManager.store(midiEngine.getFocusedDeck(), 1);
+ break;
+ case '#':
+ if (!midiEngine.isQwertyEnabled()) presetManager.store(midiEngine.getFocusedDeck(), 2);
+ break;
+ case '$':
+ if (!midiEngine.isQwertyEnabled()) presetManager.store(midiEngine.getFocusedDeck(), 3);
+ break;
+ case '%':
+ if (!midiEngine.isQwertyEnabled()) presetManager.store(midiEngine.getFocusedDeck(), 4);
+ break;
+ case '^':
+ if (!midiEngine.isQwertyEnabled()) presetManager.store(midiEngine.getFocusedDeck(), 5);
+ break;
+ case '&':
+ if (!midiEngine.isQwertyEnabled()) presetManager.store(midiEngine.getFocusedDeck(), 6);
+ break;
+ case '*':
+ if (!midiEngine.isQwertyEnabled()) presetManager.store(midiEngine.getFocusedDeck(), 7);
+ break;
+
case '-':
case '_':
frameRate(--targetFramerate);
}
}
break;
+ case 't':
+ if (!midiEngine.isQwertyEnabled()) {
+ lx.engine.setThreaded(!lx.engine.isThreaded());
+ }
+ break;
case 'p':
for (PandaDriver p : pandaBoards) {
p.toggle();
}
}
-void mouseWheel(int delta) {delta*=20;
+void mouseWheel(int delta) {
boolean wheeled = false;
for (UIContext context : overlays) {
wheeled |= context.mouseWheel(mouseX, mouseY, delta);