}
}
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 onPresetLoaded(Engine.Deck 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(Preset preset) {
- output.sendNoteOn(preset.index, 52, 2);
+ public void onPresetDirty(Engine.Deck deck, Preset preset) {
+ if (deck == getTargetDeck()) {
+ output.sendNoteOn(preset.index, 52, 2);
+ }
}
- public void onPresetStored(Preset preset) {
- onPresetLoaded(preset);
+ public void onPresetStored(Engine.Deck deck, Preset preset) {
+ if (deck == getTargetDeck()) {
+ onPresetLoaded(deck, preset);
+ }
}
public void onPresetUnloaded() {
for (int i = 0; i < 8; ++i) {
interface PresetListener {
- public void onPresetLoaded(Preset preset);
- public void onPresetDirty(Preset preset);
- public void onPresetStored(Preset preset);
+ 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 onPresetUnloaded();
}
public void patternDidChange(Engine.Deck deck, LXPattern pattern) {
if (midiEngine.getFocusedDeck() == deck) {
if (pattern != loadedPattern) {
- onPresetDirty();
+ onPresetDirty(deck);
}
}
}
public void addListener(PresetListener listener) {
listeners.add(listener);
}
+
+ public Engine.Deck deckForPattern(LXPattern pattern) {
+ for (Engine.Deck deck : lx.engine.getDecks()) {
+ for (LXPattern p : deck.getPatterns()) {
+ if (p == pattern) {
+ return deck;
+ }
+ }
+ }
+ return null;
+ }
public void dirty(LXPattern pattern) {
- if (loadedPattern == pattern) {
- onPresetDirty();
- }
+ onPresetDirty(deckForPattern(pattern));
}
public void select(Engine.Deck deck, int index) {
public void store(Engine.Deck deck, int index) {
presets[index].store(midiEngine.getFocusedPattern());
for (PresetListener listener : listeners) {
- listener.onPresetStored(presets[index]);
+ listener.onPresetStored(deck, presets[index]);
}
select(deck, index);
}
- public void onPresetLoaded(Preset preset, LXPattern pattern) {
+ public void onPresetLoaded(Engine.Deck deck, Preset preset, LXPattern pattern) {
if (loadedPattern != pattern) {
if (loadedPattern != null) {
for (LXParameter p : loadedPattern.getParameters()) {
}
}
for (PresetListener listener : listeners) {
- listener.onPresetLoaded(preset);
+ listener.onPresetLoaded(deck, preset);
}
loadedPreset = preset;
loadedPattern = pattern;
}
}
- private void onPresetDirty() {
+ private void onPresetDirty(Engine.Deck deck) {
if (loadedPreset != null) {
for (PresetListener listener : listeners) {
- listener.onPresetDirty(loadedPreset);
+ listener.onPresetDirty(deck, loadedPreset);
}
}
}
public void onParameterChanged(LXParameter p) {
- onPresetDirty();
+ onPresetDirty(deckForPattern(loadedPattern));
}
public void write() {
if (pattern instanceof DPat) {
((DPat)pattern).updateLights();
}
- manager.onPresetLoaded(this, pattern);
+ manager.onPresetLoaded(deck, this, pattern);
break;
}
}