use of de.mossgrabers.framework.controller.ButtonID in project DrivenByMoss by git-moss.
the class SLControllerSetup method registerTriggerCommands.
/**
* {@inheritDoc}
*/
@Override
protected void registerTriggerCommands() {
final SLControlSurface surface = this.getSurface();
// Needs to be before the switch to Automap to catch the success response
this.addButton(ButtonID.CONTROL, "DAW Online", (event, velocity) -> surface.setDAWConnected(velocity > 0), SLControlSurface.MKI_CC_OFF_ONLINE_MESSAGE, surface::isDAWConnected);
surface.sendStartup();
for (int i = 0; i < 8; i++) {
final int index = i + 1;
final ButtonID buttonID1 = ButtonID.get(ButtonID.ROW1_1, i);
final ButtonID buttonID2 = ButtonID.get(ButtonID.ROW2_1, i);
final ButtonID buttonID3 = ButtonID.get(ButtonID.ROW3_1, i);
final ButtonID buttonID4 = ButtonID.get(ButtonID.ROW4_1, i);
final ButtonID buttonID5 = ButtonID.get(ButtonID.ROW_SELECT_1, i);
this.addButton(buttonID1, "Row 1-" + index, new ButtonRowViewCommand<>(0, i, this.model, surface), SLControlSurface.MKII_BUTTON_ROW1_1 + i, () -> this.getViewButtonColor(buttonID1));
this.addButton(buttonID2, "Row 2-" + index, new ButtonRowViewCommand<>(1, i, this.model, surface), SLControlSurface.MKII_BUTTON_ROW2_1 + i, () -> this.getViewButtonColor(buttonID2));
this.addButton(buttonID3, "Row 3-" + index, new ButtonRowViewCommand<>(2, i, this.model, surface), SLControlSurface.MKII_BUTTON_ROW3_1 + i, () -> this.getViewButtonColor(buttonID3));
this.addButton(buttonID4, "Row 4-" + index, new ButtonRowViewCommand<>(3, i, this.model, surface), SLControlSurface.MKII_BUTTON_ROW4_1 + i, () -> this.getViewButtonColor(buttonID4));
this.addButton(buttonID5, "Select " + index, new ButtonRowSelectCommand<>(i, this.model, surface), SLControlSurface.MKII_BUTTON_ROWSEL1 + i, () -> this.getViewButtonColor(buttonID5));
}
this.addButton(ButtonID.REWIND, "<<", new ButtonRowViewCommand<>(4, 0, this.model, surface), SLControlSurface.MKII_BUTTON_REWIND);
this.addButton(ButtonID.FORWARD, ">>", new ButtonRowViewCommand<>(4, 1, this.model, surface), SLControlSurface.MKII_BUTTON_FORWARD);
this.addButton(ButtonID.STOP, "Stop", new ButtonRowViewCommand<>(4, 2, this.model, surface), SLControlSurface.MKII_BUTTON_STOP);
this.addButton(ButtonID.PLAY, "Play", new ButtonRowViewCommand<>(4, 3, this.model, surface), SLControlSurface.MKII_BUTTON_PLAY);
this.addButton(ButtonID.LOOP, "Loop", new ButtonRowViewCommand<>(4, 4, this.model, surface), SLControlSurface.MKII_BUTTON_LOOP);
this.addButton(ButtonID.RECORD, "Record", new ButtonRowViewCommand<>(4, 6, this.model, surface), SLControlSurface.MKII_BUTTON_RECORD);
this.addButton(ButtonID.ARROW_LEFT, "Left", new P1ButtonCommand(true, this.model, surface), SLControlSurface.MKII_BUTTON_P1_UP);
this.addButton(ButtonID.ARROW_RIGHT, "Right", new P1ButtonCommand(false, this.model, surface), SLControlSurface.MKII_BUTTON_P1_DOWN);
this.addButton(ButtonID.ARROW_UP, "Up", new P2ButtonCommand(true, this.model, surface), SLControlSurface.MKII_BUTTON_P2_UP);
this.addButton(ButtonID.ARROW_DOWN, "Down", new P2ButtonCommand(false, this.model, surface), SLControlSurface.MKII_BUTTON_P2_DOWN);
this.addButton(ButtonID.NOTE, "Play View", new TransportButtonCommand(this.model, surface), SLControlSurface.MKII_BUTTON_TRANSPORT);
}
use of de.mossgrabers.framework.controller.ButtonID in project DrivenByMoss by git-moss.
the class LaunchpadControlSurface method setLaunchpadMode.
private void setLaunchpadMode(final String data) {
this.sendLaunchpadSysEx(data);
for (final Entry<ButtonID, IHwButton> entry : this.getButtons().entrySet()) {
final ButtonID key = entry.getKey();
final int keyValue = key.ordinal();
if (ButtonID.PAD1.ordinal() < keyValue || ButtonID.PAD64.ordinal() > keyValue)
entry.getValue().getLight().forceFlush();
}
}
use of de.mossgrabers.framework.controller.ButtonID in project DrivenByMoss by git-moss.
the class LaunchkeyMk3ControlSurface method createPads.
/**
* {@inheritDoc}
*/
@Override
protected void createPads() {
((LaunchkeyPadGrid) this.padGrid).setView(Views.SESSION);
super.createPads();
// Map alternative MIDI notes for grid...
final int size = this.padGrid.getRows() * this.padGrid.getCols();
final int startNote = this.padGrid.getStartNote();
for (int i = 0; i < size; i++) {
final int note = startNote + i;
final ButtonID buttonID = ButtonID.get(ButtonID.PAD17, i);
IHwButton pad = this.createButton(buttonID, "D " + (i + 1));
pad.addLight(this.surfaceFactory.createLight(this.surfaceID, null, () -> this.padGrid.getLightInfo(note).getEncoded(), state -> this.padGrid.sendState(note), colorIndex -> this.colorManager.getColor(colorIndex, buttonID), null));
int[] translated = LaunchkeyPadGrid.translateToController(Views.DRUM, note);
pad.bind(this.input, BindType.NOTE, translated[0], translated[1]);
pad.bind((event, velocity) -> this.handleGridNote(event, note, velocity));
final ButtonID buttonID2 = ButtonID.get(ButtonID.PAD33, i);
pad = this.createButton(buttonID2, "DS " + (i + 1));
pad.addLight(this.surfaceFactory.createLight(this.surfaceID, null, () -> this.padGrid.getLightInfo(note).getEncoded(), state -> this.padGrid.sendState(note), colorIndex -> this.colorManager.getColor(colorIndex, buttonID2), null));
translated = LaunchkeyPadGrid.translateToController(Views.DEVICE, note);
pad.bind(this.input, BindType.NOTE, translated[0], translated[1]);
pad.bind((event, velocity) -> this.handleGridNote(event, note, velocity));
}
}
use of de.mossgrabers.framework.controller.ButtonID in project DrivenByMoss by git-moss.
the class Kontrol1ControlSurface method buttonChange.
/**
* {@inheritDoc}
*/
@Override
public void buttonChange(final int usbControlNumber, final boolean isPressed) {
final ButtonID buttonID = BUTTON_MAP.get(Integer.valueOf(usbControlNumber));
if (buttonID == null) {
// Simulate knob touch via CC
final ContinuousID continuousID = CONTINUOUS_MAP.get(Integer.valueOf(usbControlNumber));
if (continuousID == null)
return;
final IHwContinuousControl continuous = this.getContinuous(continuousID);
if (isPressed) {
if (!continuous.isTouched())
continuous.triggerTouch(true);
} else if (continuous.isTouched())
continuous.triggerTouch(false);
return;
}
// Simulate button press via CC
if (isPressed) {
if (!this.isPressed(buttonID))
this.getButton(buttonID).trigger(ButtonEvent.DOWN);
} else if (this.isPressed(buttonID))
this.getButton(buttonID).trigger(ButtonEvent.UP);
}
use of de.mossgrabers.framework.controller.ButtonID in project DrivenByMoss by git-moss.
the class SLMkIIIControllerSetup method registerTriggerCommands.
/**
* {@inheritDoc}
*/
@Override
protected void registerTriggerCommands() {
final SLMkIIIControlSurface surface = this.getSurface();
final ModeManager modeManager = surface.getModeManager();
final ViewManager viewManager = surface.getViewManager();
final ITransport t = this.model.getTransport();
final ITrackBank tb = this.model.getTrackBank();
final WindCommand<SLMkIIIControlSurface, SLMkIIIConfiguration> rewindCommand = new WindCommand<>(this.model, surface, false);
final WindCommand<SLMkIIIControlSurface, SLMkIIIConfiguration> forwardCommand = new WindCommand<>(this.model, surface, true);
this.addButton(ButtonID.REWIND, "<<", rewindCommand, 15, SLMkIIIControlSurface.MKIII_TRANSPORT_REWIND, () -> rewindCommand.isRewinding() ? 1 : 0, SLMkIIIColorManager.BUTTON_STATE_WIND_ON, SLMkIIIColorManager.BUTTON_STATE_WIND_HI);
this.addButton(ButtonID.FORWARD, ">>", forwardCommand, 15, SLMkIIIControlSurface.MKIII_TRANSPORT_FORWARD, () -> forwardCommand.isForwarding() ? 1 : 0, SLMkIIIColorManager.BUTTON_STATE_WIND_ON, SLMkIIIColorManager.BUTTON_STATE_WIND_HI);
this.addButton(ButtonID.LOOP, "Loop", new SLMkIIIToggleLoopCommand(this.model, surface), 15, SLMkIIIControlSurface.MKIII_TRANSPORT_LOOP, () -> t.isLoop() ? 1 : 0, SLMkIIIColorManager.BUTTON_STATE_LOOP_ON, SLMkIIIColorManager.BUTTON_STATE_LOOP_HI);
this.addButton(ButtonID.STOP, "Stop", new StopCommand<>(this.model, surface), 15, SLMkIIIControlSurface.MKIII_TRANSPORT_STOP, () -> !t.isPlaying() ? 1 : 0, SLMkIIIColorManager.BUTTON_STATE_STOP_ON, SLMkIIIColorManager.BUTTON_STATE_STOP_HI);
this.addButton(ButtonID.PLAY, "Play", new SLMkIIIPlayCommand(this.model, surface), 15, SLMkIIIControlSurface.MKIII_TRANSPORT_PLAY, () -> t.isPlaying() ? 1 : 0, SLMkIIIColorManager.BUTTON_STATE_PLAY_ON, SLMkIIIColorManager.BUTTON_STATE_PLAY_HI);
this.addButton(ButtonID.RECORD, "Record", new RecordCommand<>(this.model, surface), 15, SLMkIIIControlSurface.MKIII_TRANSPORT_RECORD, () -> {
final boolean isOn = this.isRecordShifted(surface) ? t.isLauncherOverdub() : t.isRecording();
return isOn ? 1 : 0;
}, SLMkIIIColorManager.BUTTON_STATE_REC_ON, SLMkIIIColorManager.BUTTON_STATE_REC_HI, SLMkIIIColorManager.BUTTON_STATE_OVR_ON, SLMkIIIColorManager.BUTTON_STATE_OVR_HI);
for (int i = 0; i < 8; i++) {
final int index = i;
final ButtonID buttonID = ButtonID.get(ButtonID.ROW1_1, i);
this.addButton(buttonID, "Select " + (i + 1), new ButtonRowModeCommand<>(0, i, this.model, surface), 15, SLMkIIIControlSurface.MKIII_DISPLAY_BUTTON_1 + i, new FeatureGroupButtonColorSupplier(modeManager, buttonID));
this.addButton(ButtonID.get(ButtonID.ROW2_1, i), "Mute/Monitor " + (i + 1), new ButtonAreaCommand(0, i, this.model, surface), 15, SLMkIIIControlSurface.MKIII_BUTTON_ROW1_1 + i, () -> {
final ITrack track = tb.getItem(index);
if (!track.doesExist())
return SLMkIIIColorManager.SLMKIII_BLACK;
if (surface.isMuteSolo())
return track.isMute() ? SLMkIIIColorManager.SLMKIII_ORANGE : SLMkIIIColorManager.SLMKIII_ORANGE_HALF;
return track.isMonitor() ? SLMkIIIColorManager.SLMKIII_GREEN : SLMkIIIColorManager.SLMKIII_GREEN_HALF;
});
this.addButton(ButtonID.get(ButtonID.ROW3_1, i), "Solo/Arm" + (i + 1), new ButtonAreaCommand(1, i, this.model, surface), 15, SLMkIIIControlSurface.MKIII_BUTTON_ROW2_1 + i, () -> {
final ITrack track = tb.getItem(index);
if (!track.doesExist())
return SLMkIIIColorManager.SLMKIII_BLACK;
if (surface.isMuteSolo())
return track.isSolo() ? SLMkIIIColorManager.SLMKIII_YELLOW : SLMkIIIColorManager.SLMKIII_YELLOW_HALF;
return track.isRecArm() ? SLMkIIIColorManager.SLMKIII_RED : SLMkIIIColorManager.SLMKIII_RED_HALF;
});
}
this.addButton(ButtonID.ARROW_UP, "Up", new DeviceModeCommand(this.model, surface), 15, SLMkIIIControlSurface.MKIII_DISPLAY_UP, () -> getDeviceModeColor(modeManager));
this.addButton(ButtonID.ARROW_DOWN, "Down", new TrackModeCommand(this.model, surface), 15, SLMkIIIControlSurface.MKIII_DISPLAY_DOWN, () -> getTrackModeColor(modeManager));
this.addButton(ButtonID.SHIFT, "Shift", new ShiftCommand<>(this.model, surface), 15, SLMkIIIControlSurface.MKIII_SHIFT);
this.addButton(ButtonID.USER, "Options", new ModeSelectCommand<>(this.model, surface, Modes.FUNCTIONS, true), 15, SLMkIIIControlSurface.MKIII_OPTIONS, () -> modeManager.isActive(Modes.FUNCTIONS) ? SLMkIIIColorManager.SLMKIII_DARK_BROWN : SLMkIIIColorManager.SLMKIII_DARK_GREY);
this.addButton(ButtonID.OCTAVE_UP, "Up", (event, value) -> {
if (event == ButtonEvent.UP)
surface.toggleMuteSolo();
}, 15, SLMkIIIControlSurface.MKIII_BUTTONS_UP, () -> surface.isMuteSolo() ? SLMkIIIColorManager.SLMKIII_ORANGE : SLMkIIIColorManager.SLMKIII_ORANGE_HALF);
this.addButton(ButtonID.OCTAVE_DOWN, "Down", (event, value) -> {
if (event == ButtonEvent.UP)
surface.toggleMuteSolo();
}, 15, SLMkIIIControlSurface.MKIII_BUTTONS_DOWN, () -> !surface.isMuteSolo() ? SLMkIIIColorManager.SLMKIII_RED : SLMkIIIColorManager.SLMKIII_RED_HALF);
final ModeCursorCommand<SLMkIIIControlSurface, SLMkIIIConfiguration> cursorLeftCommand = new ModeCursorCommand<>(Direction.LEFT, this.model, surface, true);
this.addButton(ButtonID.ARROW_LEFT, "Left", cursorLeftCommand, 15, SLMkIIIControlSurface.MKIII_TRACK_LEFT, () -> getCursorColor(modeManager, cursorLeftCommand));
final ModeCursorCommand<SLMkIIIControlSurface, SLMkIIIConfiguration> cursorRightCommand = new ModeCursorCommand<>(Direction.RIGHT, this.model, surface, true);
this.addButton(ButtonID.ARROW_RIGHT, "Right", cursorRightCommand, 15, SLMkIIIControlSurface.MKIII_TRACK_RIGHT, () -> getCursorColor(modeManager, cursorRightCommand));
for (int i = 0; i < 2; i++) {
final ButtonID sceneButtonID = ButtonID.get(ButtonID.SCENE1, i);
this.addButton(sceneButtonID, "Scene " + (i + 1), new ViewButtonCommand<>(sceneButtonID, surface), 15, SLMkIIIControlSurface.MKIII_SCENE_1 + i, new FeatureGroupButtonColorSupplier(viewManager, sceneButtonID));
}
this.addButton(ButtonID.SCENE7, "Scene Up", (event, value) -> {
if (event != ButtonEvent.DOWN)
return;
if (viewManager.isActive(Views.SESSION))
this.model.getSceneBank().scrollBackwards();
else if (viewManager.isActive(Views.DRUM)) {
final DrumView drumView = (DrumView) viewManager.get(Views.DRUM);
if (drumView.isPlayMode())
drumView.onOctaveUp(ButtonEvent.DOWN);
else
drumView.onLeft(ButtonEvent.DOWN);
} else if (viewManager.isActive(Views.COLOR))
((ColorView<?, ?>) viewManager.get(Views.COLOR)).setPage(0);
}, 15, SLMkIIIControlSurface.MKIII_SCENE_UP, this::getSceneUpColor);
this.addButton(ButtonID.SCENE8, "Scene Down", (event, value) -> {
if (event != ButtonEvent.DOWN)
return;
if (viewManager.isActive(Views.SESSION))
this.model.getSceneBank().scrollForwards();
else if (viewManager.isActive(Views.DRUM)) {
final DrumView drumView = (DrumView) viewManager.get(Views.DRUM);
if (drumView.isPlayMode())
drumView.onOctaveDown(ButtonEvent.DOWN);
else
drumView.onRight(ButtonEvent.DOWN);
} else if (viewManager.isActive(Views.COLOR))
((ColorView<?, ?>) viewManager.get(Views.COLOR)).setPage(1);
}, 15, SLMkIIIControlSurface.MKIII_SCENE_DOWN, this::getSceneDownColor);
this.addButton(ButtonID.SESSION, "Grid", (event, value) -> {
if (event != ButtonEvent.DOWN)
return;
viewManager.setActive(viewManager.isActive(Views.SESSION) ? Views.DRUM : Views.SESSION);
this.getSurface().getDisplay().notify(viewManager.isActive(Views.SESSION) ? "Session" : "Sequencer");
}, 15, SLMkIIIControlSurface.MKIII_GRID, () -> viewManager.isActive(Views.SESSION) ? SLMkIIIColorManager.SLMKIII_GREEN : SLMkIIIColorManager.SLMKIII_BLUE);
this.addButton(ButtonID.DUPLICATE, "Duplicate", NopCommand.INSTANCE, 15, SLMkIIIControlSurface.MKIII_DUPLICATE, () -> surface.isPressed(ButtonID.DUPLICATE) ? SLMkIIIColorManager.SLMKIII_AMBER : SLMkIIIColorManager.SLMKIII_AMBER_HALF);
final SLMkIIIDisplay display = surface.getDisplay();
for (int i = 0; i < 8; i++) {
final int index = i;
surface.createLight(OutputID.get(OutputID.LED1, i), () -> {
final ITrack track = tb.getItem(index);
return track.getColor().dim(this.valueChanger.toNormalizedValue(track.getVolume()));
}, color -> display.setFaderLEDColor(SLMkIIIControlSurface.MKIII_FADER_LED_1 + index, color));
surface.createLight(OutputID.get(OutputID.LED_RING1, i), () -> {
// Note: On mode change the color does not change if the value is the same,
// let's ignore that since it is only visible in the simulation GUI
final IMode mode = modeManager.getActive();
if (mode == null)
return 0;
final int value = Math.max(0, mode.getKnobValue(index));
return this.valueChanger.toMidiValue(value);
}, color -> surface.setTrigger(SLMkIIIControlSurface.MKIII_KNOB_1 + index, color), state -> {
// On the device, the send value is displayed on the display as a knob
// On the simulation GUI represent it as a dimmed color of the mode
final BaseMode<?> mode = (BaseMode<?>) modeManager.getActive();
if (mode == null)
return ColorEx.BLACK;
final ColorEx c = this.colorManager.getColor(mode.getModeColor(), null);
return c.dim(this.valueChanger.toNormalizedValue(this.valueChanger.toDAWValue(state)));
}, null);
}
}
Aggregations