From: Mark Slee Date: Tue, 22 Oct 2013 00:00:15 +0000 (-0700) Subject: Refactor Engine.Deck to LXEngine LXDeck X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=42a424d76b6ed74ffae8d72215e912d66a3d4bf6;p=SugarCubes.git Refactor Engine.Deck to LXEngine LXDeck --- diff --git a/DanUtil.pde b/DanUtil.pde index bdb18c0..097c61f 100644 --- a/DanUtil.pde +++ b/DanUtil.pde @@ -61,7 +61,6 @@ public class DParam extends BasicParameter { double dflt; DParam (String label, double value) { super(label,value); dflt=value; } void set (double value) { super.setValue(value); } - void reset () { super.setValue(dflt); } float Val () { return getValuef(); } } //---------------------------------------------------------------------------------------------------------------------------------- diff --git a/_Internals.pde b/_Internals.pde index 2e3af44..2e91381 100644 --- a/_Internals.pde +++ b/_Internals.pde @@ -125,7 +125,7 @@ void setup() { logTime("Built GLucose engine"); // Set the patterns - Engine engine = lx.engine; + LXEngine engine = lx.engine; engine.setPatterns(patterns = _leftPatterns(glucose)); engine.addDeck(_rightPatterns(glucose)); logTime("Built patterns"); @@ -156,13 +156,13 @@ void setup() { // 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), diff --git a/_MIDI.pde b/_MIDI.pde index 4e7cc1f..8f71457 100644 --- a/_MIDI.pde +++ b/_MIDI.pde @@ -84,7 +84,7 @@ class MidiEngine { return this.midiControllers; } - public Engine.Deck getFocusedDeck() { + public LXDeck getFocusedDeck() { return lx.engine.getDeck(activeDeckIndex); } @@ -352,7 +352,7 @@ public class APC40MidiInput extends GenericDeviceMidiInput { private boolean shiftOn = false; private LXEffect releaseEffect = null; - final private Engine.Deck targetDeck; + final private LXDeck targetDeck; APC40MidiInput(MidiEngine midiEngine, MidiInputDevice d) { this(midiEngine, d, -1); @@ -363,7 +363,7 @@ public class APC40MidiInput extends GenericDeviceMidiInput { targetDeck = (deckIndex < 0) ? null : lx.engine.getDecks().get(deckIndex); } - protected Engine.Deck getTargetDeck() { + protected LXDeck getTargetDeck() { return (targetDeck != null) ? targetDeck : midiEngine.getFocusedDeck(); } @@ -440,7 +440,7 @@ public class APC40MidiInput extends GenericDeviceMidiInput { // Crossfader case 15: - lx.engine.getDeck(1).getCrossfader().setValue(value); + lx.engine.getDeck(GLucose.RIGHT_DECK).getFader().setValue(value); break; } @@ -662,7 +662,7 @@ class APC40MidiOutput implements LXParameter.Listener, GridOutput { private final MidiOutput output; private LXPattern focusedPattern = null; private LXEffect focusedEffect = null; - private final Engine.Deck targetDeck; + private final LXDeck targetDeck; APC40MidiOutput(MidiEngine midiEngine, MidiOutputDevice device) { this(midiEngine, device, -1); @@ -685,30 +685,30 @@ class APC40MidiOutput implements LXParameter.Listener, GridOutput { resetEffectParameters(); } }); - Engine.Listener deckListener = new Engine.AbstractListener() { - public void patternDidChange(Engine.Deck deck, LXPattern pattern) { + LXDeck.Listener deckListener = new LXDeck.AbstractListener() { + public void patternDidChange(LXDeck deck, LXPattern pattern) { resetPatternParameters(); } }; - for (Engine.Deck d : lx.engine.getDecks()) { + for (LXDeck d : lx.engine.getDecks()) { if (targetDeck == null || d == targetDeck) { d.addListener(deckListener); } } presetManager.addListener(new PresetListener() { - public void onPresetLoaded(Engine.Deck deck, Preset preset) { + public void onPresetLoaded(LXDeck deck, Preset preset) { if (deck == getTargetDeck()) { for (int i = 0; i < 8; ++i) { output.sendNoteOn(i, 52, (preset.index == i) ? 1 : 0); } } } - public void onPresetDirty(Engine.Deck deck, Preset preset) { + public void onPresetDirty(LXDeck deck, Preset preset) { if (deck == getTargetDeck()) { output.sendNoteOn(preset.index, 52, 2); } } - public void onPresetStored(Engine.Deck deck, Preset preset) { + public void onPresetStored(LXDeck deck, Preset preset) { if (deck == getTargetDeck()) { onPresetLoaded(deck, preset); } @@ -736,7 +736,7 @@ class APC40MidiOutput implements LXParameter.Listener, GridOutput { } private void setDPatternOutputs() { - for (Engine.Deck deck : lx.engine.getDecks()) { + for (LXDeck deck : lx.engine.getDecks()) { if (targetDeck == null || deck == targetDeck) { for (LXPattern pattern : deck.getPatterns()) { if (pattern instanceof DPat) { @@ -747,7 +747,7 @@ class APC40MidiOutput implements LXParameter.Listener, GridOutput { } } - protected Engine.Deck getTargetDeck() { + protected LXDeck getTargetDeck() { if (targetDeck != null) { return targetDeck; } diff --git a/_Presets.pde b/_Presets.pde index ca3957e..2c61125 100644 --- a/_Presets.pde +++ b/_Presets.pde @@ -1,7 +1,7 @@ interface PresetListener { - public void onPresetLoaded(Engine.Deck deck, Preset preset); - public void onPresetDirty(Engine.Deck deck, Preset preset); - public void onPresetStored(Engine.Deck deck, Preset preset); + public void onPresetLoaded(LXDeck deck, Preset preset); + public void onPresetDirty(LXDeck deck, Preset preset); + public void onPresetStored(LXDeck deck, Preset preset); public void onPresetUnloaded(); } @@ -33,9 +33,9 @@ class PresetManager implements LXParameter.Listener { } } } - for (Engine.Deck deck : lx.engine.getDecks()) { - deck.addListener(new Engine.AbstractListener() { - public void patternDidChange(Engine.Deck deck, LXPattern pattern) { + for (LXDeck deck : lx.engine.getDecks()) { + deck.addListener(new LXDeck.AbstractListener() { + public void patternDidChange(LXDeck deck, LXPattern pattern) { if (pattern != loadedPattern) { onPresetDirty(deck); } @@ -59,8 +59,8 @@ class PresetManager implements LXParameter.Listener { listeners.add(listener); } - public Engine.Deck deckForPattern(LXPattern pattern) { - for (Engine.Deck deck : lx.engine.getDecks()) { + public LXDeck deckForPattern(LXPattern pattern) { + for (LXDeck deck : lx.engine.getDecks()) { for (LXPattern p : deck.getPatterns()) { if (p == pattern) { return deck; @@ -74,11 +74,11 @@ class PresetManager implements LXParameter.Listener { onPresetDirty(deckForPattern(pattern)); } - public void select(Engine.Deck deck, int index) { + public void select(LXDeck deck, int index) { presets[index].select(deck); } - public void store(Engine.Deck deck, int index) { + public void store(LXDeck deck, int index) { presets[index].store(midiEngine.getFocusedPattern()); for (PresetListener listener : listeners) { listener.onPresetStored(deck, presets[index]); @@ -86,7 +86,7 @@ class PresetManager implements LXParameter.Listener { select(deck, index); } - public void onPresetLoaded(Engine.Deck deck, Preset preset, LXPattern pattern) { + public void onPresetLoaded(LXDeck deck, Preset preset, LXPattern pattern) { if (loadedPattern != pattern) { if (loadedPattern != null) { for (LXParameter p : loadedPattern.getParameters()) { @@ -104,7 +104,7 @@ class PresetManager implements LXParameter.Listener { } } - private void onPresetDirty(Engine.Deck deck) { + private void onPresetDirty(LXDeck deck) { if (loadedPreset != null) { for (PresetListener listener : listeners) { listener.onPresetDirty(deck, loadedPreset); @@ -186,7 +186,7 @@ class Preset { manager.write(); } - public void select(Engine.Deck deck) { + public void select(LXDeck deck) { for (LXPattern pattern : deck.getPatterns()) { if (pattern.getClass().getName().equals(className)) { for (String pLabel : parameters.keySet()) { diff --git a/_UIImplementation.pde b/_UIImplementation.pde index df3a7e4..bd303dd 100644 --- a/_UIImplementation.pde +++ b/_UIImplementation.pde @@ -13,9 +13,9 @@ class UIPatternDeck extends UIWindow { - Engine.Deck deck; + LXDeck deck; - public UIPatternDeck(Engine.Deck deck, String label, float x, float y, float w, float h) { + public UIPatternDeck(LXDeck deck, String label, float x, float y, float w, float h) { super(label, x, y, w, h); this.deck = deck; int yp = titleHeight; @@ -34,11 +34,11 @@ class UIPatternDeck extends UIWindow { parameterKnobs[ki].addToContainer(this); } - Engine.Listener lxListener = new Engine.AbstractListener() { - public void patternWillChange(Engine.Deck deck, LXPattern pattern, LXPattern nextPattern) { + LXDeck.Listener lxListener = new LXDeck.AbstractListener() { + public void patternWillChange(LXDeck deck, LXPattern pattern, LXPattern nextPattern) { patternList.redraw(); } - public void patternDidChange(Engine.Deck deck, LXPattern pattern) { + public void patternDidChange(LXDeck deck, LXPattern pattern) { patternList.redraw(); int pi = 0; for (LXParameter parameter : pattern.getParameters()) { @@ -96,8 +96,8 @@ class UIBlendMode extends UIWindow { final UIScrollList tList; (tList = new UIScrollList(1, titleHeight, w-2, 60)).setItems(items).addToContainer(this); - lx.engine.getDeck(1).addListener(new Engine.AbstractListener() { - public void blendTransitionDidChange(Engine.Deck deck, LXTransition transition) { + lx.engine.getDeck(GLucose.RIGHT_DECK).addListener(new LXDeck.AbstractListener() { + public void faderTransitionDidChange(LXDeck deck, LXTransition transition) { tList.redraw(); } }); @@ -138,7 +138,7 @@ class UICrossfader extends UIWindow { public UICrossfader(float x, float y, float w, float h) { super("CROSSFADER", x, y, w, h); - new UIParameterSlider(4, titleHeight, w-9, 32).setParameter(lx.engine.getDeck(1).getCrossfader()).addToContainer(this); + new UIParameterSlider(4, titleHeight, w-9, 32).setParameter(lx.engine.getDeck(GLucose.RIGHT_DECK).getFader()).addToContainer(this); (displayMode = new UIToggleSet(4, titleHeight + 36, w-9, 20)).setOptions(new String[] { "A", "COMP", "B" }).setValue("COMP").addToContainer(this); } @@ -521,8 +521,8 @@ class UIMidi extends UIWindow { return logMode.isActive(); } - public Engine.Deck getFocusedDeck() { - return lx.engine.getDeck(deckMode.getValue() == "A" ? 0 : 1); + public LXDeck getFocusedDeck() { + return lx.engine.getDeck(deckMode.getValue() == "A" ? GLucose.LEFT_DECK : GLucose.RIGHT_DECK); } } diff --git a/code/GLucose.jar b/code/GLucose.jar index bdaa7e9..8a71ba7 100755 Binary files a/code/GLucose.jar and b/code/GLucose.jar differ diff --git a/code/HeronLX.jar b/code/HeronLX.jar index de2032b..eea9627 100755 Binary files a/code/HeronLX.jar and b/code/HeronLX.jar differ