use of de.mossgrabers.controller.ni.maschine.mk3.view.DrumView in project DrivenByMoss by git-moss.
the class MaschineControllerSetup method registerTriggerCommands.
/**
* {@inheritDoc}
*/
@Override
protected void registerTriggerCommands() {
final MaschineControlSurface surface = this.getSurface();
final ModeManager modeManager = surface.getModeManager();
final ViewManager viewManager = surface.getViewManager();
final ITransport t = this.model.getTransport();
this.addButton(ButtonID.SHIFT, "SHIFT", new ToggleShiftViewCommand<>(this.model, surface), this.maschine == Maschine.STUDIO ? MaschineControlSurface.NAVIGATE_BACK : -1, () -> viewManager.isActive(Views.SHIFT) || surface.isShiftPressed());
// Transport
this.addButton(ButtonID.PLAY, "PLAY", new PlayCommand<>(this.model, surface), MaschineControlSurface.PLAY, t::isPlaying);
final ConfiguredRecordCommand<MaschineControlSurface, MaschineConfiguration> recordCommand = new ConfiguredRecordCommand<>(this.model, surface);
this.addButton(ButtonID.RECORD, "RECORD", recordCommand, MaschineControlSurface.REC, recordCommand::isLit);
this.addButton(ButtonID.STOP, "STOP", new MaschineStopCommand(this.model, surface), MaschineControlSurface.STOP, () -> !t.isPlaying());
this.addButton(ButtonID.LOOP, "LOOP", new ToggleLoopCommand<>(this.model, surface), MaschineControlSurface.RESTART, t::isLoop);
this.addButton(ButtonID.DELETE, "ERASE", NopCommand.INSTANCE, MaschineControlSurface.ERASE);
final MetronomeCommand<MaschineControlSurface, MaschineConfiguration> metroCommand = new MetronomeCommand<>(this.model, surface, false);
final TapTempoCommand<MaschineControlSurface, MaschineConfiguration> tapTempoCommand = new TapTempoCommand<>(this.model, surface);
this.addButton(ButtonID.TAP_TEMPO, "TAP/METRO", (event, velocity) -> {
if (event != ButtonEvent.UP)
return;
if (surface.isShiftPressed()) {
surface.setStopConsumed();
metroCommand.executeNormal(event);
} else
tapTempoCommand.execute(ButtonEvent.DOWN, velocity);
}, MaschineControlSurface.TAP_METRO, t::isMetronomeOn);
this.addButton(ButtonID.FLIP, this.maschine == Maschine.STUDIO || this.maschine == Maschine.MK2 ? "GRID" : "FOLLOW", (event, velocity) -> {
if (event != ButtonEvent.UP)
return;
if (viewManager.isActive(Views.DRUM, Views.PLAY))
((DrumView) viewManager.get(Views.DRUM)).toggleGridEditor();
}, MaschineControlSurface.FOLLOW, () -> viewManager.isActive(Views.DRUM, Views.PLAY) && ((DrumView) viewManager.get(Views.DRUM)).isGridEditor());
this.addButton(ButtonID.NEW, this.maschine.hasCursorKeys() ? "MACRO" : "GROUP", new NewCommand<>(this.model, surface), MaschineControlSurface.GROUP);
final AutomationCommand<MaschineControlSurface, MaschineConfiguration> automationCommand = new AutomationCommand<>(this.model, surface) {
@Override
protected void cleanupShift() {
this.surface.setStopConsumed();
}
};
this.addButton(ButtonID.AUTOMATION, "AUTO", automationCommand, MaschineControlSurface.AUTO, automationCommand::isLit);
this.addButton(ButtonID.OVERDUB, this.maschine == Maschine.STUDIO || this.maschine == Maschine.MK2 ? "ENTER" : "LOCK", new OverdubCommand<>(this.model, surface) {
@Override
protected void shiftedFunction() {
this.surface.setStopConsumed();
super.shiftedFunction();
}
}, MaschineControlSurface.LOCK, () -> surface.isShiftPressed() ? t.isLauncherOverdub() : t.isArrangerOverdub());
this.addButton(ButtonID.REPEAT, "NOTE REPEAT", new FillModeNoteRepeatCommand<>(this.model, surface, this.maschine.hasMCUDisplay()), MaschineControlSurface.NOTE_REPEAT, this.configuration::isNoteRepeatActive);
// Ribbon
this.addButton(ButtonID.F1, "PITCH", new RibbonCommand(this.model, surface, RIBBON_MODES_PITCH), MaschineControlSurface.PITCH, () -> this.isRibbonMode(new HashSet<>(RIBBON_MODES_PITCH)));
this.addButton(ButtonID.F2, "MOD", new RibbonCommand(this.model, surface, RIBBON_MODES_CC), MaschineControlSurface.MOD, () -> this.isRibbonMode(new HashSet<>(RIBBON_MODES_CC)));
this.addButton(ButtonID.F3, "PERFORM", new RibbonCommand(this.model, surface, RIBBON_MODES_MASTER_VOLUME), MaschineControlSurface.PERFORM, () -> this.isRibbonMode(new HashSet<>(RIBBON_MODES_MASTER_VOLUME)));
this.addButton(ButtonID.F4, "NOTES", new RibbonCommand(this.model, surface, RIBBON_MODES_NOTE_REPEAT), MaschineControlSurface.NOTES, () -> this.isRibbonMode(new HashSet<>(RIBBON_MODES_NOTE_REPEAT)));
this.addButton(ButtonID.FADER_TOUCH_1, "ENCODER PRESS", (event, velocity) -> {
if (event != ButtonEvent.DOWN)
return;
if (modeManager.getActiveID() == Modes.BROWSER) {
this.model.getBrowser().stopBrowsing(true);
modeManager.restore();
} else {
final boolean isSlow = !surface.isKnobSensitivitySlow();
surface.setKnobSensitivityIsSlow(isSlow);
surface.getDisplay().notify("Value change speed: " + (isSlow ? "Slow" : "Fast"));
}
}, MaschineControlSurface.ENCODER_PUSH);
// Encoder Modes
this.addButton(ButtonID.VOLUME, "VOLUME", new VolumePanSendCommand(this.model, surface), MaschineControlSurface.VOLUME, () -> Modes.isTrackMode(modeManager.getActiveID()));
this.addButton(ButtonID.SWING, "SWING", new SwingCommand(this.model, surface), MaschineControlSurface.SWING, () -> modeManager.isActive(Modes.POSITION, Modes.LOOP_START, Modes.LOOP_LENGTH));
this.addButton(ButtonID.TEMPO_TOUCH, "TEMPO", new TempoCommand(this.model, surface), MaschineControlSurface.TEMPO, () -> modeManager.isActive(Modes.TEMPO));
this.addButton(ButtonID.DEVICE, "PLUG-IN", (event, velocity) -> {
if (this.maschine.hasMCUDisplay() || surface.isShiftPressed())
new PanelLayoutCommand<>(this.model, surface).executeNormal(event);
else
new ModeSelectCommand<>(this.model, surface, Modes.DEVICE_PARAMS).execute(event, velocity);
}, MaschineControlSurface.PLUGIN, () -> this.maschine.hasMCUDisplay() || surface.isShiftPressed() ? this.model.getCursorDevice().isWindowOpen() : modeManager.isActive(Modes.DEVICE_PARAMS));
this.addButton(ButtonID.DEVICE_ON_OFF, "SAMPLING", new ConvertCommand<>(this.model, surface) {
@Override
protected void sliceToSampler() {
this.surface.setStopConsumed();
super.sliceToSampler();
}
}, MaschineControlSurface.SAMPLING);
// Browser
final String fileLabel;
if (this.maschine.hasCursorKeys()) {
if (this.maschine == Maschine.STUDIO || this.maschine == Maschine.MK2)
fileLabel = "ALL/SAVE";
else
fileLabel = "FILE";
} else
fileLabel = "PROJECT";
this.addButton(ButtonID.ADD_TRACK, fileLabel, new ProjectButtonCommand(this.model, surface), MaschineControlSurface.PROJECT);
this.addButton(ButtonID.ADD_EFFECT, this.maschine.hasCursorKeys() ? "SETTINGS" : "FAVORITES", new AddDeviceCommand(this.model, surface), MaschineControlSurface.FAVORITES);
this.addButton(ButtonID.BROWSE, this.maschine == Maschine.STUDIO || this.maschine == Maschine.MK2 ? "BROWSE" : "BROWSER", new BrowserCommand<>(this.model, surface, ButtonID.SHIFT, ButtonID.SELECT) {
/**
* {@inheritDoc}
*/
@Override
protected boolean getCommit() {
// Discard browser, confirmation is via encoder
return false;
}
}, MaschineControlSurface.BROWSER, this.model.getBrowser()::isActive);
// Pad modes
this.addButton(ButtonID.ACCENT, "ACCENT", new ToggleFixedVelCommand(this.model, surface), MaschineControlSurface.FIXED_VEL, this.configuration::isAccentActive);
this.addButton(ButtonID.SCENE1, "SCENE", new ViewMultiSelectCommand<>(this.model, surface, true, Views.SCENE_PLAY), MaschineControlSurface.SCENE, () -> viewManager.isActive(Views.SCENE_PLAY));
this.addButton(ButtonID.CLIP, "PATTERN", new ViewMultiSelectCommand<>(this.model, surface, true, Views.CLIP), MaschineControlSurface.PATTERN, () -> viewManager.isActive(Views.CLIP));
this.addButton(ButtonID.NOTE, "EVENTS", new ModeSelectCommand<>(this.model, surface, Modes.NOTE, true), MaschineControlSurface.EVENTS, () -> modeManager.isActive(Modes.NOTE));
this.addButton(ButtonID.TOGGLE_DEVICE, this.maschine == Maschine.STUDIO || this.maschine == Maschine.MK2 ? "NAVIGATE" : "VARIATION", new ViewMultiSelectCommand<>(this.model, surface, true, Views.DEVICE), MaschineControlSurface.VARIATION, () -> viewManager.isActive(Views.DEVICE));
this.addButton(ButtonID.DUPLICATE, "DUPLICATE", NopCommand.INSTANCE, MaschineControlSurface.DUPLICATE);
if (this.maschine.hasGroupButtons()) {
this.addButton(ButtonID.SELECT, "SELECT", new MaschineSelectButtonCommand(this.model, surface), MaschineControlSurface.SELECT);
this.addButton(ButtonID.SOLO, "SOLO", (event, velocity) -> {
if (event == ButtonEvent.UP && surface.isShiftPressed()) {
surface.setStopConsumed();
this.model.getProject().clearSolo();
}
}, MaschineControlSurface.SOLO);
this.addButton(ButtonID.MUTE, "MUTE", (event, velocity) -> {
if (event == ButtonEvent.UP && surface.isShiftPressed()) {
surface.setStopConsumed();
this.model.getProject().clearMute();
}
}, MaschineControlSurface.MUTE);
} else {
this.addButton(ButtonID.SELECT, "SELECT", new ViewMultiSelectCommand<>(this.model, surface, true, Views.TRACK_SELECT), MaschineControlSurface.SELECT, () -> viewManager.isActive(Views.TRACK_SELECT));
this.addButton(ButtonID.SOLO, "SOLO", new ViewMultiSelectCommand<>(this.model, surface, true, Views.TRACK_SOLO), MaschineControlSurface.SOLO, () -> viewManager.isActive(Views.TRACK_SOLO));
this.addButton(ButtonID.MUTE, "MUTE", new ViewMultiSelectCommand<>(this.model, surface, true, Views.TRACK_MUTE), MaschineControlSurface.MUTE, () -> viewManager.isActive(Views.TRACK_MUTE));
}
final KeyboardCommand keyboardCommand = new KeyboardCommand(this.model, surface);
this.addButton(ButtonID.ROW1_1, "PAD MODE", new PadModeCommand(keyboardCommand, this.model, surface), MaschineControlSurface.PAD_MODE, () -> viewManager.isActive(Views.DRUM));
this.addButton(ButtonID.ROW1_2, "KEYBOARD", keyboardCommand, MaschineControlSurface.KEYBOARD, () -> viewManager.isActive(Views.PLAY));
this.addButton(ButtonID.ROW1_3, "CHORDS", (event, velocity) -> {
if (velocity == 0)
((PlayView) viewManager.get(Views.PLAY)).toggleChordMode();
}, MaschineControlSurface.CHORDS, ((PlayView) viewManager.get(Views.PLAY))::isChordMode);
final DrumView drumView = (DrumView) viewManager.get(Views.DRUM);
this.addButton(ButtonID.ROW1_4, "STEP", (event, velocity) -> {
if (event == ButtonEvent.UP)
drumView.toggleSequencerVisible();
}, MaschineControlSurface.STEP, drumView::isSequencerVisible);
this.registerCursorKeys(surface);
this.registerDisplayButtons(surface, modeManager);
this.registerGroupButtons(surface);
if (this.maschine == Maschine.STUDIO)
this.registerMaschineStudioButtons(surface);
// Register foot switches
final int footswitches = this.maschine.getFootswitches();
if (footswitches >= 2) {
this.addButton(ButtonID.FOOTSWITCH1, "Foot Controller (Tip)", new FootswitchCommand<>(this.model, surface, 0), MaschineControlSurface.FOOTSWITCH1_TIP);
this.addButton(ButtonID.FOOTSWITCH2, "Foot Controller (Ring)", new FootswitchCommand<>(this.model, surface, 1), MaschineControlSurface.FOOTSWITCH1_RING);
if (footswitches == 4) {
this.addButton(ButtonID.FOOTSWITCH3, "Foot Controller 2 (Tip)", new FootswitchCommand<>(this.model, surface, 2), MaschineControlSurface.FOOTSWITCH2_TIP);
this.addButton(ButtonID.FOOTSWITCH4, "Foot Controller 2 (Ring)", new FootswitchCommand<>(this.model, surface, 3), MaschineControlSurface.FOOTSWITCH2_RING);
}
}
}
use of de.mossgrabers.controller.ni.maschine.mk3.view.DrumView in project DrivenByMoss by git-moss.
the class MaschineControllerSetup method createViews.
/**
* {@inheritDoc}
*/
@Override
protected void createViews() {
final MaschineControlSurface surface = this.getSurface();
final ViewManager viewManager = surface.getViewManager();
viewManager.register(Views.SCENE_PLAY, new SceneView(surface, this.model));
viewManager.register(Views.CLIP, new ClipView(surface, this.model));
final DrumView drumView = new DrumView(surface, this.model);
viewManager.register(Views.DRUM, drumView);
viewManager.register(Views.PLAY, new PlayView(surface, this.model, drumView));
viewManager.register(Views.DEVICE, new ParameterView(surface, this.model));
if (!this.maschine.hasGroupButtons()) {
viewManager.register(Views.TRACK_SELECT, new SelectView(surface, this.model));
viewManager.register(Views.TRACK_SOLO, new SoloView(surface, this.model));
viewManager.register(Views.TRACK_MUTE, new MuteView(surface, this.model));
}
viewManager.register(Views.REPEAT_NOTE, new NoteRepeatView(surface, this.model));
this.shiftView = new ShiftView(surface, this.model);
viewManager.register(Views.SHIFT, this.shiftView);
}
use of de.mossgrabers.controller.ni.maschine.mk3.view.DrumView in project DrivenByMoss by git-moss.
the class DrumConfigurationMode method onKnobValue.
/**
* {@inheritDoc}
*/
@Override
public void onKnobValue(final int index, final int value) {
if (!this.model.canSelectedTrackHoldNotes())
return;
final int idx = index < 0 ? this.selectedParam : index;
final Scales scales = this.model.getScales();
final boolean inc = this.model.getValueChanger().isIncrease(value);
final ViewManager viewManager = this.surface.getViewManager();
switch(idx) {
case 6:
case 7:
((DrumView) viewManager.get(Views.DRUM)).changeOctave(ButtonEvent.DOWN, inc, scales.getDrumDefaultOffset(), true, false);
viewManager.get(Views.DRUM).updateNoteMapping();
((INoteMode) this.surface.getModeManager().get(Modes.NOTE)).clearNotes();
break;
default:
// Not used
break;
}
}
Aggregations