From: Mark Slee Date: Sat, 19 Oct 2013 20:56:35 +0000 (-0700) Subject: Fix preset dirtying and lights update on DPat X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=66067e53a4adab2860ba09f88e2c3f8984ff65ba;p=SugarCubes.git Fix preset dirtying and lights update on DPat --- diff --git a/DanUtil.pde b/DanUtil.pde index b769b78..85f49fd 100644 --- a/DanUtil.pde +++ b/DanUtil.pde @@ -129,8 +129,7 @@ public class DPat extends SCPattern void SetNoteOn (int row, int col, int clr){ if (APCOut != null) APCOut.sendNoteOn (col, row, clr); } void SetNoteOff (int row, int col, int clr){ if (APCOut != null) APCOut.sendNoteOff (col, row, clr); } - boolean isFocused() { return midiEngine != null && midiEngine.getFocusedDeck() != null && - this == midiEngine.getFocusedDeck().getActivePattern(); } + boolean isFocused() { return midiEngine != null && midiEngine.getFocusedPattern() == this; } void onInactive() { uiDebugText.setText(""); } void onTransitionEnd() { updateLights(); } void onReset() { diff --git a/MarkSlee.pde b/MarkSlee.pde index 7a556d5..fde5fc7 100644 --- a/MarkSlee.pde +++ b/MarkSlee.pde @@ -173,11 +173,13 @@ class Pulley extends SCPattern { } // A little silliness to test the grid API - for (int i = 0; i < 7; ++i) { - for (int j = 0; j < 8; ++j) { - int gi = (int) constrain(j * NUM_DIVISIONS / 8, 0, NUM_DIVISIONS-1); - float b = 1 - 4.*abs((6-i)/7. - gravity[gi].getValuef() / model.yMax); - midiEngine.grid.setState(i, j, (b < 0) ? 0 : 1); + if (midiEngine != null && midiEngine.getFocusedPattern() == this) { + for (int i = 0; i < 5; ++i) { + for (int j = 0; j < 8; ++j) { + int gi = (int) constrain(j * NUM_DIVISIONS / 8, 0, NUM_DIVISIONS-1); + float b = 1 - 4.*abs((6-i)/6. - gravity[gi].getValuef() / model.yMax); + midiEngine.grid.setState(i, j, (b < 0) ? 0 : 3); + } } } diff --git a/_MIDI.pde b/_MIDI.pde index 9a3ce5c..79c3860 100644 --- a/_MIDI.pde +++ b/_MIDI.pde @@ -703,9 +703,13 @@ class APC40MidiOutput implements LXParameter.Listener, GridOutput { while (i < 12) { sendKnob(i++, 0); } - for (int row = 0; row < 7; ++row) { - for (int col = 0; col < 8; ++col) { - setGridState(row, col, 0); + if (focusedPattern instanceof DPat) { + ((DPat)focusedPattern).updateLights(); + } else { + for (int row = 0; row < 7; ++row) { + for (int col = 0; col < 8; ++col) { + setGridState(row, col, 0); + } } } } diff --git a/_Presets.pde b/_Presets.pde index f1855c6..f4371d6 100644 --- a/_Presets.pde +++ b/_Presets.pde @@ -92,8 +92,10 @@ class PresetManager implements LXParameter.Listener { } private void onPresetDirty() { - for (PresetListener listener : listeners) { - listener.onPresetDirty(loadedPreset); + if (loadedPreset != null) { + for (PresetListener listener : listeners) { + listener.onPresetDirty(loadedPreset); + } } }