Search in sources :

Example 1 with MaschineStopCommand

use of de.mossgrabers.controller.ni.maschine.mk3.command.trigger.MaschineStopCommand 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);
        }
    }
}
Also used : TapTempoCommand(de.mossgrabers.framework.command.trigger.transport.TapTempoCommand) ITransport(de.mossgrabers.framework.daw.ITransport) KeyboardCommand(de.mossgrabers.controller.ni.maschine.mk3.command.trigger.KeyboardCommand) ToggleFixedVelCommand(de.mossgrabers.controller.ni.maschine.mk3.command.trigger.ToggleFixedVelCommand) ViewManager(de.mossgrabers.framework.featuregroup.ViewManager) MaschineControlSurface(de.mossgrabers.controller.ni.maschine.mk3.controller.MaschineControlSurface) ConfiguredRecordCommand(de.mossgrabers.framework.command.trigger.transport.ConfiguredRecordCommand) ProjectButtonCommand(de.mossgrabers.controller.ni.maschine.mk3.command.trigger.ProjectButtonCommand) AutomationCommand(de.mossgrabers.framework.command.trigger.transport.AutomationCommand) MetronomeCommand(de.mossgrabers.framework.command.trigger.transport.MetronomeCommand) VolumePanSendCommand(de.mossgrabers.controller.ni.maschine.mk3.command.trigger.VolumePanSendCommand) ModeSelectCommand(de.mossgrabers.framework.command.trigger.mode.ModeSelectCommand) PadModeCommand(de.mossgrabers.controller.ni.maschine.mk3.command.trigger.PadModeCommand) ModeManager(de.mossgrabers.framework.featuregroup.ModeManager) StudioEncoderModeManager(de.mossgrabers.controller.ni.maschine.mk3.controller.StudioEncoderModeManager) HashSet(java.util.HashSet) MaschineSelectButtonCommand(de.mossgrabers.controller.ni.maschine.mk3.command.trigger.MaschineSelectButtonCommand) SwingCommand(de.mossgrabers.controller.ni.maschine.mk3.command.trigger.SwingCommand) TempoCommand(de.mossgrabers.controller.ni.maschine.mk3.command.trigger.TempoCommand) TapTempoCommand(de.mossgrabers.framework.command.trigger.transport.TapTempoCommand) PanelLayoutCommand(de.mossgrabers.framework.command.trigger.application.PanelLayoutCommand) DrumView(de.mossgrabers.controller.ni.maschine.mk3.view.DrumView) AddDeviceCommand(de.mossgrabers.controller.ni.maschine.mk3.command.trigger.AddDeviceCommand) Set(java.util.Set) IMidiInput(de.mossgrabers.framework.daw.midi.IMidiInput) ITransport(de.mossgrabers.framework.daw.ITransport) IHost(de.mossgrabers.framework.daw.IHost) ButtonEvent(de.mossgrabers.framework.utils.ButtonEvent) List(java.util.List) HashSet(java.util.HashSet) IMidiOutput(de.mossgrabers.framework.daw.midi.IMidiOutput) MaschineStopCommand(de.mossgrabers.controller.ni.maschine.mk3.command.trigger.MaschineStopCommand) RibbonCommand(de.mossgrabers.controller.ni.maschine.mk3.command.trigger.RibbonCommand)

Aggregations

AddDeviceCommand (de.mossgrabers.controller.ni.maschine.mk3.command.trigger.AddDeviceCommand)1 KeyboardCommand (de.mossgrabers.controller.ni.maschine.mk3.command.trigger.KeyboardCommand)1 MaschineSelectButtonCommand (de.mossgrabers.controller.ni.maschine.mk3.command.trigger.MaschineSelectButtonCommand)1 MaschineStopCommand (de.mossgrabers.controller.ni.maschine.mk3.command.trigger.MaschineStopCommand)1 PadModeCommand (de.mossgrabers.controller.ni.maschine.mk3.command.trigger.PadModeCommand)1 ProjectButtonCommand (de.mossgrabers.controller.ni.maschine.mk3.command.trigger.ProjectButtonCommand)1 RibbonCommand (de.mossgrabers.controller.ni.maschine.mk3.command.trigger.RibbonCommand)1 SwingCommand (de.mossgrabers.controller.ni.maschine.mk3.command.trigger.SwingCommand)1 TempoCommand (de.mossgrabers.controller.ni.maschine.mk3.command.trigger.TempoCommand)1 ToggleFixedVelCommand (de.mossgrabers.controller.ni.maschine.mk3.command.trigger.ToggleFixedVelCommand)1 VolumePanSendCommand (de.mossgrabers.controller.ni.maschine.mk3.command.trigger.VolumePanSendCommand)1 MaschineControlSurface (de.mossgrabers.controller.ni.maschine.mk3.controller.MaschineControlSurface)1 StudioEncoderModeManager (de.mossgrabers.controller.ni.maschine.mk3.controller.StudioEncoderModeManager)1 DrumView (de.mossgrabers.controller.ni.maschine.mk3.view.DrumView)1 PanelLayoutCommand (de.mossgrabers.framework.command.trigger.application.PanelLayoutCommand)1 ModeSelectCommand (de.mossgrabers.framework.command.trigger.mode.ModeSelectCommand)1 AutomationCommand (de.mossgrabers.framework.command.trigger.transport.AutomationCommand)1 ConfiguredRecordCommand (de.mossgrabers.framework.command.trigger.transport.ConfiguredRecordCommand)1 MetronomeCommand (de.mossgrabers.framework.command.trigger.transport.MetronomeCommand)1 TapTempoCommand (de.mossgrabers.framework.command.trigger.transport.TapTempoCommand)1