final float TRAILER_HEIGHT = 33;
int targetFramerate = 60;
-
int startMillis, lastMillis;
+
+// Core engine variables
GLucose glucose;
HeronLX lx;
-MappingTool mappingTool;
LXPattern[] patterns;
-LXTransition[] transitions;
-LXEffect[] effects;
+MappingTool mappingTool;
PandaDriver[] pandaBoards;
+
+// Display configuration mode
boolean mappingMode = false;
boolean debugMode = false;
DebugUI debugUI;
-String displayMode;
+// Handles to UI objects
UIContext[] overlays;
UIPatternDeck uiPatternA;
+UICrossfader uiCrossfader;
UIMapping uiMapping;
UIDebugText uiDebugText;
// Set the patterns
Engine engine = lx.engine;
- glucose.setTransitions(transitions = transitions(glucose));
- logTime("Built transitions");
engine.setPatterns(patterns = _patterns(glucose));
engine.addDeck(_patterns(glucose));
- engine.getDeck(1).setBlendTransition(transitions[0]);
logTime("Built patterns");
- glucose.lx.addEffects(effects = effects(glucose));
+ glucose.setTransitions(transitions(glucose));
+ logTime("Built transitions");
+ glucose.lx.addEffects(effects(glucose));
logTime("Built effects");
// Build output driver
debugUI = new DebugUI(pandaMappings);
overlays = new UIContext[] {
uiPatternA = new UIPatternDeck(lx.engine.getDeck(0), "PATTERN A", 4, 4, 140, 344),
- new UICrossfader(4, 352, 140, 212),
+ uiCrossfader = new UICrossfader(4, 352, 140, 212),
new UIPatternDeck(lx.engine.getDeck(1), "PATTERN B", width-144, 4, 140, 344),
new UIEffects(width-144, 352, 140, 144),
void draw() {
// Draws the simulation and the 2D UI overlay
background(40);
- color[] colors = glucose.getColors();;
+ color[] colors = glucose.getColors();
+
+ String displayMode = uiCrossfader.getDisplayMode();
if (displayMode == "A") {
colors = lx.engine.getDeck(0).getColors();
} else if (displayMode == "B") {
lx.setPatterns(new LXPattern[] { mappingTool });
} else {
lx.setPatterns(patterns);
+ LXTransition pop = restoreToPattern.getTransition();
+ restoreToPattern.setTransition(null);
lx.goPattern(restoreToPattern);
+ restoreToPattern.setTransition(pop);
}
break;
case 'p':
parameterKnobs[ki].addToContainer(this);
}
- Engine.Listener lxListener = new Engine.Listener() {
+ Engine.Listener lxListener = new Engine.AbstractListener() {
public void patternWillChange(Engine.Deck deck, LXPattern pattern, LXPattern nextPattern) {
patternList.redraw();
}
}
class UICrossfader extends UIWindow {
-
+
+ private final UIToggleSet displayMode;
+
public UICrossfader(float x, float y, float w, float h) {
super("CROSSFADER", x, y, w, h);
List<ScrollItem> items = new ArrayList<ScrollItem>();
- for (LXTransition t : transitions) {
+ for (LXTransition t : glucose.getTransitions()) {
items.add(new TransitionScrollItem(t));
- }
- new UIScrollList(1, titleHeight, w-2, 120).setItems(items).addToContainer(this);
+ }
+ final UIScrollList tList;
+ (tList = new UIScrollList(1, titleHeight, w-2, 120)).setItems(items).addToContainer(this);
new UIParameterSlider(4, titleHeight + 126, w-10, 24).setParameter(lx.engine.getDeck(1).getCrossfader()).addToContainer(this);
- new UIToggleSet(4, 182, w-10, 20) {
- protected void onToggle(String value) {
- displayMode = value;
+ (displayMode = new UIToggleSet(4, 182, w-10, 20)).setOptions(new String[] { "A", "COMP", "B" }).setValue("COMP").addToContainer(this);
+
+ lx.engine.getDeck(1).addListener(new Engine.AbstractListener() {
+ public void blendTransitionDidChange(Engine.Deck deck, LXTransition transition) {
+ tList.redraw();
}
- }.setOptions(new String[] { "A", "COMP", "B" }).setValue(displayMode = "COMP").addToContainer(this);
+ });
+ }
+
+ public String getDisplayMode() {
+ return displayMode.getValue();
}
}
}
public boolean isSelected() {
- return transition == lx.engine.getDeck(1).getBlendTransition();
+ return transition == glucose.getSelectedTransition();
}
public boolean isPending() {
}
public void onMousePressed() {
- lx.engine.getDeck(1).setBlendTransition(transition);
+ glucose.setSelectedTransition(transition);
}
}