X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=_MIDI.pde;h=535194f8264d63d40c7cf403464fde4cc841b666;hb=a1396b9e932bdf842b1817b0b313a34831889a5b;hp=a584ef9097d72a69543336def3fc6ef872620b3f;hpb=e530876366cf4c07a5e77b7e8890dff376cbcd3c;p=SugarCubes.git diff --git a/_MIDI.pde b/_MIDI.pde index a584ef9..535194f 100644 --- a/_MIDI.pde +++ b/_MIDI.pde @@ -348,7 +348,6 @@ public class APC40MidiInput extends GenericDeviceMidiInput { int pitch = note.getPitch(); if (channel < 8) { if (pitch >= 53 && pitch <=57) return new GridPosition(pitch-53, channel); - else if (pitch == 52) return new GridPosition(5, channel); } return null; } @@ -452,7 +451,7 @@ public class APC40MidiInput extends GenericDeviceMidiInput { break; } break; - + case 82: // scene 1 EFF_boom.trigger(); break; @@ -540,7 +539,17 @@ public class APC40MidiInput extends GenericDeviceMidiInput { 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 @@ -636,11 +645,38 @@ class APC40MidiOutput implements LXParameter.Listener, GridOutput { 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 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); } private void resetParameters() { @@ -667,9 +703,16 @@ 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 j = 0; j < 8; ++j) { + output.sendNoteOn(j, 48, 0); + } + for (int row = 0; row < 7; ++row) { + for (int col = 0; col < 8; ++col) { + setGridState(row, col, 0); + } } } } @@ -727,9 +770,8 @@ class APC40MidiOutput implements LXParameter.Listener, GridOutput { } public void setGridState(int row, int col, int state) { - if (col < 8) { - if (row < 5) output.sendNoteOn(col, 53+row, state); - else if (row == 6) output.sendNoteOn(col, 52, state); + if (col < 8 && row < 5) { + output.sendNoteOn(col, 53+row, state); } } }