LXPattern[] patterns;
MappingTool mappingTool;
PandaDriver[] pandaBoards;
-MidiEngine midiEngine;
PresetManager presetManager;
+MidiEngine midiEngine;
// Display configuration mode
boolean mappingMode = false;
glucose.lx.addEffects(effects(glucose));
logTime("Built effects");
- // MIDI devices
- midiEngine = new MidiEngine();
- logTime("Setup MIDI devices");
-
// Preset manager
presetManager = new PresetManager();
logTime("Loaded presets");
+ // MIDI devices
+ midiEngine = new MidiEngine();
+ presetManager.setMidiEngine(midiEngine);
+ logTime("Setup MIDI devices");
+
// Build output driver
PandaMapping[] pandaMappings = buildPandaList();
pandaBoards = new PandaDriver[pandaMappings.length];
break;
}
break;
-
- case 52: // CLIP STOP
- if (nChan < PresetManager.NUM_PRESETS) {
- if (shiftOn) {
- presetManager.store(nChan);
- } else {
- presetManager.select(nChan);
- }
- }
- break;
-
+
case 82: // scene 1
EFF_boom.trigger();
break;
break;
}
break;
-
+
+ case 52: // CLIP STOP
+ if (nChan < PresetManager.NUM_PRESETS) {
+ if (shiftOn) {
+ presetManager.store(nChan);
+ } else {
+ presetManager.select(nChan);
+ }
+ }
+ break;
+
case 90: // SEND C
long tapDelta = millis() - tap1;
if (lbtwn(tapDelta,5000,300*1000)) { // hackish tapping mechanism
for (Engine.Deck d : lx.engine.getDecks()) {
d.addListener(deckListener);
}
+ presetManager.addListener(new PresetListener() {
+ public void onPresetLoaded(Preset preset) {
+ for (int i = 0; i < 8; ++i) {
+ output.sendNoteOn(i, 52, (preset.index == i) ? 1 : 0);
+ }
+ }
+ public void onPresetDirty(Preset preset) {
+ output.sendNoteOn(preset.index, 52, 2);
+ }
+ public void onPresetStored(Preset preset) {
+ onPresetLoaded(preset);
+ }
+ public void onPresetUnloaded() {
+ for (int i = 0; i < 8; ++i) {
+ output.sendNoteOn(i, 52, 0);
+ }
+ }
+ });
resetParameters();
midiEngine.grid.addOutput(this);
lx.cycleBaseHue(60000);
output.sendNoteOn(6, 49, 127);
- // Turn off the track selection lights
+ // Turn off the track selection lights and preset selectors
for (int i = 0; i < 8; ++i) {
output.sendNoteOn(i, 51, 0);
+ output.sendNoteOn(i, 52, 0);
}
+
+ // Turn off the MASTER selector
output.sendNoteOn(0, 80, 0);
}
public void onPresetLoaded(Preset preset);
public void onPresetDirty(Preset preset);
public void onPresetStored(Preset preset);
+ public void onPresetUnloaded();
}
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) {
+ if (midiEngine.getFocusedDeck() == deck) {
+ if (pattern != loadedPattern) {
+ onPresetDirty();
+ }
+ }
+ }
+ });
+ }
+ }
+
+ public void setMidiEngine(MidiEngine midiEngine) {
+ midiEngine.addListener(new MidiEngineListener() {
+ public void onFocusedDeck(int deckIndex) {
+ loadedPreset = null;
+ for (PresetListener listener : listeners) {
+ listener.onPresetUnloaded();
+ }
+ }
+ });
}
public void addListener(PresetListener listener) {
public void store(int index) {
presets[index].store(midiEngine.getFocusedPattern());
+ for (PresetListener listener : listeners) {
+ listener.onPresetStored(presets[index]);
+ }
select(index);
}
}
}
- public void onParameterChanged(LXParameter p) {
+ private void onPresetDirty() {
for (PresetListener listener : listeners) {
listener.onPresetDirty(loadedPreset);
}
}
+ public void onParameterChanged(LXParameter p) {
+ onPresetDirty();
+ }
+
public void write() {
String[] lines = new String[NUM_PRESETS];
int i = 0;