Search in sources :

Example 1 with ConfiguredRecordCommand

use of de.mossgrabers.framework.command.trigger.transport.ConfiguredRecordCommand in project DrivenByMoss by git-moss.

the class LaunchkeyMiniMk3ControllerSetup method registerTriggerCommands.

/**
 * {@inheritDoc}
 */
@Override
protected void registerTriggerCommands() {
    final LaunchkeyMiniMk3ControlSurface surface = this.getSurface();
    final ITransport t = this.model.getTransport();
    final ViewManager viewManager = surface.getViewManager();
    this.addButton(ButtonID.SHIFT, "Shift", NopCommand.INSTANCE, LaunchkeyMiniMk3ControlSurface.LAUNCHKEY_SHIFT);
    this.addButton(ButtonID.PLAY, "Play", new PlayCommand<>(this.model, surface), 15, LaunchkeyMiniMk3ControlSurface.LAUNCHKEY_PLAY, t::isPlaying);
    final ConfiguredRecordCommand<LaunchkeyMiniMk3ControlSurface, LaunchkeyMiniMk3Configuration> recordCommand = new ConfiguredRecordCommand<>(this.model, surface);
    this.addButton(ButtonID.RECORD, "Record", recordCommand, 15, LaunchkeyMiniMk3ControlSurface.LAUNCHKEY_RECORD, recordCommand::isLit);
    final ModeCursorCommand<LaunchkeyMiniMk3ControlSurface, LaunchkeyMiniMk3Configuration> leftCommand = new ModeCursorCommand<>(Direction.LEFT, this.model, surface, true);
    this.addButton(ButtonID.MOVE_TRACK_LEFT, "Previous", leftCommand, 15, LaunchkeyMiniMk3ControlSurface.LAUNCHKEY_LEFT, leftCommand::canScroll);
    final ModeCursorCommand<LaunchkeyMiniMk3ControlSurface, LaunchkeyMiniMk3Configuration> rightCommand = new ModeCursorCommand<>(Direction.RIGHT, this.model, surface, true);
    this.addButton(ButtonID.MOVE_TRACK_RIGHT, "Next", rightCommand, 15, LaunchkeyMiniMk3ControlSurface.LAUNCHKEY_RIGHT, rightCommand::canScroll);
    // Scene buttons
    this.addButton(ButtonID.SCENE1, "Scene 1", new ViewButtonCommand<>(ButtonID.SCENE1, surface), LaunchkeyMiniMk3ControlSurface.LAUNCHKEY_SCENE1, new FeatureGroupButtonColorSupplier(viewManager, ButtonID.SCENE1));
    this.addButton(ButtonID.SCENE2, "Scene 2", new ViewButtonCommand<>(ButtonID.SCENE2, surface), LaunchkeyMiniMk3ControlSurface.LAUNCHKEY_SCENE2, new FeatureGroupButtonColorSupplier(viewManager, ButtonID.SCENE2));
    // View selection with Pads in Shift mode
    this.createViewButton(ButtonID.ROW2_1, OutputID.LED_RING1, "Session", Views.SESSION, LaunchkeyMiniMk3ControlSurface.PAD_MODE_SESSION);
    this.createViewButton(ButtonID.ROW2_2, OutputID.LED_RING2, "Drum", Views.DRUM, LaunchkeyMiniMk3ControlSurface.PAD_MODE_DRUM);
    this.createViewButton(ButtonID.ROW2_3, OutputID.LED_RING3, "Custom", Views.PLAY, LaunchkeyMiniMk3ControlSurface.PAD_MODE_CUSTOM);
    // Knob mode selection with Pads in Shift mode
    this.createModeButton(ButtonID.ROW1_1, OutputID.LED1, "Device", Modes.DEVICE_PARAMS, LaunchkeyMiniMk3ControlSurface.KNOB_MODE_PARAMS);
    this.createModeButton(ButtonID.ROW1_2, OutputID.LED2, "Volume", Modes.VOLUME, LaunchkeyMiniMk3ControlSurface.KNOB_MODE_VOLUME);
    this.createModeButton(ButtonID.ROW1_3, OutputID.LED3, "Pan", Modes.PAN, LaunchkeyMiniMk3ControlSurface.KNOB_MODE_PAN);
    this.createModeButton(ButtonID.ROW1_4, OutputID.LED4, "Send 1", Modes.SEND1, LaunchkeyMiniMk3ControlSurface.KNOB_MODE_SEND1);
    this.createModeButton(ButtonID.ROW1_5, OutputID.LED5, "Send 2", Modes.SEND2, LaunchkeyMiniMk3ControlSurface.KNOB_MODE_SEND2);
    this.createModeButton(ButtonID.ROW1_6, OutputID.LED6, "Custom", Modes.USER, LaunchkeyMiniMk3ControlSurface.KNOB_MODE_CUSTOM);
    // Online state
    this.addButton(ButtonID.CONTROL, "DAW Online", (event, velocity) -> surface.setDAWConnected(velocity > 0), 15, LaunchkeyMiniMk3ControlSurface.LAUNCHKEY_DAW_ONLINE, surface::isDAWConnected);
}
Also used : ITransport(de.mossgrabers.framework.daw.ITransport) LaunchkeyMiniMk3ControlSurface(de.mossgrabers.controller.novation.launchkey.mini.controller.LaunchkeyMiniMk3ControlSurface) ViewManager(de.mossgrabers.framework.featuregroup.ViewManager) ConfiguredRecordCommand(de.mossgrabers.framework.command.trigger.transport.ConfiguredRecordCommand) IMidiInput(de.mossgrabers.framework.daw.midi.IMidiInput) ITransport(de.mossgrabers.framework.daw.ITransport) IHost(de.mossgrabers.framework.daw.IHost) IHwLight(de.mossgrabers.framework.controller.hardware.IHwLight) IMidiOutput(de.mossgrabers.framework.daw.midi.IMidiOutput) ModeCursorCommand(de.mossgrabers.framework.command.trigger.mode.ModeCursorCommand) FeatureGroupButtonColorSupplier(de.mossgrabers.framework.command.trigger.view.FeatureGroupButtonColorSupplier)

Example 2 with ConfiguredRecordCommand

use of de.mossgrabers.framework.command.trigger.transport.ConfiguredRecordCommand in project DrivenByMoss by git-moss.

the class KontrolProtocolControllerSetup method registerTriggerCommands.

/**
 * {@inheritDoc}
 */
@Override
protected void registerTriggerCommands() {
    final KontrolProtocolControlSurface surface = this.getSurface();
    final ITransport t = this.model.getTransport();
    this.addButton(ButtonID.PLAY, "Play", new PlayCommand<>(this.model, surface), 15, KontrolProtocolControlSurface.KONTROL_PLAY, t::isPlaying);
    this.addButton(ButtonID.NEW, "Shift+\nPlay", new NewCommand<>(this.model, surface), 15, KontrolProtocolControlSurface.KONTROL_RESTART);
    final ConfiguredRecordCommand<KontrolProtocolControlSurface, KontrolProtocolConfiguration> recordCommand = new ConfiguredRecordCommand<>(false, this.model, surface);
    this.addButton(ButtonID.RECORD, "Record", recordCommand, 15, KontrolProtocolControlSurface.KONTROL_RECORD, recordCommand::isLit);
    final ConfiguredRecordCommand<KontrolProtocolControlSurface, KontrolProtocolConfiguration> shiftedRecordCommand = new ConfiguredRecordCommand<>(true, this.model, surface);
    this.addButton(ButtonID.REC_ARM, "Shift+\nRecord", shiftedRecordCommand, 15, KontrolProtocolControlSurface.KONTROL_COUNT_IN, shiftedRecordCommand::isLit);
    this.addButton(ButtonID.STOP, "Stop", new StopCommand<>(this.model, surface), 15, KontrolProtocolControlSurface.KONTROL_STOP, () -> !t.isPlaying());
    this.addButton(ButtonID.LOOP, "Loop", new ToggleLoopCommand<>(this.model, surface), 15, KontrolProtocolControlSurface.KONTROL_LOOP, t::isLoop);
    this.addButton(ButtonID.METRONOME, "Metronome", new MetronomeCommand<>(this.model, surface, false), 15, KontrolProtocolControlSurface.KONTROL_METRO, t::isMetronomeOn);
    this.addButton(ButtonID.TAP_TEMPO, "Tempo", new TapTempoCommand<>(this.model, surface), 15, KontrolProtocolControlSurface.KONTROL_TAP_TEMPO);
    // Note: Since there is no pressed-state with this device, in the simulator-GUI the
    // following buttons are always on
    this.addButton(ButtonID.UNDO, "Undo", new UndoCommand<>(this.model, surface), 15, KontrolProtocolControlSurface.KONTROL_UNDO, () -> this.model.getApplication().canUndo());
    this.addButton(ButtonID.REDO, "Redo", new RedoCommand<>(this.model, surface), 15, KontrolProtocolControlSurface.KONTROL_REDO, () -> this.model.getApplication().canRedo());
    this.addButton(ButtonID.QUANTIZE, "Quantize", new QuantizeCommand<>(this.model, surface), 15, KontrolProtocolControlSurface.KONTROL_QUANTIZE, () -> true);
    this.addButton(ButtonID.AUTOMATION, "Automation", new WriteArrangerAutomationCommand<>(this.model, surface), 15, KontrolProtocolControlSurface.KONTROL_AUTOMATION, t::isWritingArrangerAutomation);
    this.addButton(ButtonID.DELETE, "Modes", new ModeMultiSelectCommand<>(this.model, surface, Modes.VOLUME, Modes.SEND, Modes.DEVICE_PARAMS), 15, KontrolProtocolControlSurface.KONTROL_CLEAR, () -> true);
    this.addButton(ButtonID.CLIP, "Start Clip", new StartClipOrSceneCommand(this.model, surface), 15, KontrolProtocolControlSurface.KONTROL_PLAY_SELECTED_CLIP);
    this.addButton(ButtonID.STOP_CLIP, "Stop Clip", new StopClipCommand<>(this.model, surface), 15, KontrolProtocolControlSurface.KONTROL_STOP_CLIP);
    // Not implemented in NIHIA
    this.addButton(ButtonID.SCENE1, "Play Scene", new StartSceneCommand<>(this.model, surface), 15, KontrolProtocolControlSurface.KONTROL_PLAY_SCENE);
    // KONTROL_RECORD_SESSION - Not implemented in NIHIA
    this.addButton(ButtonID.MUTE, "Mute", new MuteCommand<>(this.model, surface), 15, KontrolProtocolControlSurface.KONTROL_SELECTED_TRACK_MUTE, () -> {
        final ITrackBank tb = this.model.getCurrentTrackBank();
        final Optional<ITrack> selectedTrack = tb.getSelectedItem();
        return selectedTrack.isPresent() && selectedTrack.get().isMute() ? 1 : 0;
    });
    this.addButton(ButtonID.SOLO, "Solo", new SoloCommand<>(this.model, surface), 15, KontrolProtocolControlSurface.KONTROL_SELECTED_TRACK_SOLO, () -> {
        final ITrackBank tb = this.model.getCurrentTrackBank();
        final Optional<ITrack> selectedTrack = tb.getSelectedItem();
        return selectedTrack.isPresent() && selectedTrack.get().isSolo() ? 1 : 0;
    });
    this.addButtons(surface, 0, 8, ButtonID.ROW_SELECT_1, "Select", (event, index) -> {
        if (event == ButtonEvent.DOWN)
            this.model.getCurrentTrackBank().getItem(index).selectOrExpandGroup();
    }, 15, KontrolProtocolControlSurface.KONTROL_TRACK_SELECTED, index -> this.model.getTrackBank().getItem(index).isSelected() ? 1 : 0);
    this.addButtons(surface, 0, 8, ButtonID.ROW1_1, "Mute", (event, index) -> {
        if (event == ButtonEvent.DOWN)
            this.model.getTrackBank().getItem(index).toggleMute();
    }, 15, KontrolProtocolControlSurface.KONTROL_TRACK_MUTE, index -> this.model.getTrackBank().getItem(index).isMute() ? 1 : 0);
    this.addButtons(surface, 0, 8, ButtonID.ROW2_1, "Solo", (event, index) -> {
        if (event == ButtonEvent.DOWN)
            this.model.getTrackBank().getItem(index).toggleSolo();
    }, 15, KontrolProtocolControlSurface.KONTROL_TRACK_SOLO, index -> this.model.getTrackBank().getItem(index).isSolo() ? 1 : 0);
    this.addButtons(surface, 0, 8, ButtonID.ROW3_1, "Arm", (event, index) -> {
        if (event == ButtonEvent.DOWN)
            this.model.getTrackBank().getItem(index).toggleRecArm();
    }, 15, KontrolProtocolControlSurface.KONTROL_TRACK_RECARM, index -> this.model.getTrackBank().getItem(index).isRecArm() ? 1 : 0);
    this.addButton(ButtonID.F1, "", NopCommand.INSTANCE, 15, KontrolProtocolControlSurface.KONTROL_SELECTED_TRACK_AVAILABLE);
    this.addButton(ButtonID.F2, "", NopCommand.INSTANCE, 15, KontrolProtocolControlSurface.KONTROL_SELECTED_TRACK_MUTED_BY_SOLO);
}
Also used : ITrackBank(de.mossgrabers.framework.daw.data.bank.ITrackBank) ITransport(de.mossgrabers.framework.daw.ITransport) StartClipOrSceneCommand(de.mossgrabers.controller.ni.kontrol.mkii.command.trigger.StartClipOrSceneCommand) ConfiguredRecordCommand(de.mossgrabers.framework.command.trigger.transport.ConfiguredRecordCommand) KontrolProtocolControlSurface(de.mossgrabers.controller.ni.kontrol.mkii.controller.KontrolProtocolControlSurface) ITrack(de.mossgrabers.framework.daw.data.ITrack) ButtonEvent(de.mossgrabers.framework.utils.ButtonEvent) List(java.util.List) IMidiInput(de.mossgrabers.framework.daw.midi.IMidiInput) ITransport(de.mossgrabers.framework.daw.ITransport) IHost(de.mossgrabers.framework.daw.IHost) IMidiOutput(de.mossgrabers.framework.daw.midi.IMidiOutput)

Example 3 with ConfiguredRecordCommand

use of de.mossgrabers.framework.command.trigger.transport.ConfiguredRecordCommand 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)

Example 4 with ConfiguredRecordCommand

use of de.mossgrabers.framework.command.trigger.transport.ConfiguredRecordCommand in project DrivenByMoss by git-moss.

the class LaunchkeyMk3ControllerSetup method registerTriggerCommands.

/**
 * {@inheritDoc}
 */
@Override
protected void registerTriggerCommands() {
    final LaunchkeyMk3ControlSurface surface = this.getSurface();
    final ITransport t = this.model.getTransport();
    final ViewManager viewManager = surface.getViewManager();
    this.addButton(ButtonID.SHIFT, "Shift", NopCommand.INSTANCE, LaunchkeyMk3ControlSurface.LAUNCHKEY_SHIFT);
    this.addButton(ButtonID.PLAY, "Play", new LaunchkeyMk3PlayCommand(this.model, surface), 15, LaunchkeyMk3ControlSurface.LAUNCHKEY_PLAY, t::isPlaying);
    this.addButton(ButtonID.STOP, "Stop", new StopCommand<>(this.model, surface), 15, LaunchkeyMk3ControlSurface.LAUNCHKEY_STOP, () -> !t.isPlaying());
    final ConfiguredRecordCommand<LaunchkeyMk3ControlSurface, LaunchkeyMk3Configuration> recordCommand = new ConfiguredRecordCommand<>(this.model, surface);
    this.addButton(ButtonID.RECORD, "Record", recordCommand, 15, LaunchkeyMk3ControlSurface.LAUNCHKEY_RECORD, recordCommand::isLit);
    this.addButton(ButtonID.REPEAT, "Repeat", new ToggleLoopCommand<>(this.model, surface), 15, LaunchkeyMk3ControlSurface.LAUNCHKEY_LOOP, t::isLoop);
    this.addButton(ButtonID.NEW, "Capture MIDI", new NewCommand<>(this.model, surface), 15, LaunchkeyMk3ControlSurface.LAUNCHKEY_CAPTURE_MIDI);
    this.addButton(ButtonID.QUANTIZE, "Quantize", new QuantizeCommand<>(this.model, surface), 15, LaunchkeyMk3ControlSurface.LAUNCHKEY_QUANTIZE);
    this.addButton(ButtonID.METRONOME, "Metronome", new MetronomeCommand<>(this.model, surface, true), 15, LaunchkeyMk3ControlSurface.LAUNCHKEY_CLICK, t::isMetronomeOn);
    this.addButton(ButtonID.UNDO, "Undo", new UndoCommand<>(this.model, surface), 15, LaunchkeyMk3ControlSurface.LAUNCHKEY_UNDO);
    this.addDummyButton(ButtonID.F3, 15, LaunchkeyMk3ControlSurface.LAUNCHKEY_DEVICE_SELECT);
    this.addButton(ButtonID.TOGGLE_DEVICE, "Device Lock", new DeviceLockCommand(this.model, surface), 15, LaunchkeyMk3ControlSurface.LAUNCHKEY_DEVICE_LOCK, () -> this.model.getCursorDevice().isPinned() ? 127 : 40);
    this.addButton(ButtonID.MOVE_TRACK_LEFT, "Previous", new SelectPrevNextTrackCommand<>(this.model, surface, true), 15, LaunchkeyMk3ControlSurface.LAUNCHKEY_TRACK_LEFT);
    this.addButton(ButtonID.MOVE_TRACK_RIGHT, "Next", new SelectPrevNextTrackCommand<>(this.model, surface, false), 15, LaunchkeyMk3ControlSurface.LAUNCHKEY_TRACK_RIGHT);
    // Scene buttons
    this.addButton(ButtonID.SCENE1, "Scene 1", new ViewButtonCommand<>(ButtonID.SCENE1, surface), LaunchkeyMk3ControlSurface.LAUNCHKEY_SCENE1, new FeatureGroupButtonColorSupplier(viewManager, ButtonID.SCENE1));
    this.addButton(ButtonID.SCENE2, "Scene 2", new ViewButtonCommand<>(ButtonID.SCENE2, surface), LaunchkeyMk3ControlSurface.LAUNCHKEY_SCENE2, new FeatureGroupButtonColorSupplier(viewManager, ButtonID.SCENE2));
    this.addButton(surface, ButtonID.ARROW_UP, "Up", new ViewButtonCommand<>(ButtonID.ARROW_UP, surface), 15, 0, LaunchkeyMk3ControlSurface.LAUNCHKEY_ARROW_UP, -1, true, new FeatureGroupButtonColorSupplier(viewManager, ButtonID.ARROW_UP));
    this.addButton(surface, ButtonID.ARROW_DOWN, "Down", new ViewButtonCommand<>(ButtonID.ARROW_DOWN, surface), 15, 0, LaunchkeyMk3ControlSurface.LAUNCHKEY_ARROW_DOWN, -1, true, new FeatureGroupButtonColorSupplier(viewManager, ButtonID.ARROW_DOWN));
    // Ignore redundant messages sent by arrow up/down buttons
    this.addDummyButton(ButtonID.F1, 15, LaunchkeyMk3ControlSurface.LAUNCHKEY_SCENE1);
    this.addDummyButton(ButtonID.F2, 15, LaunchkeyMk3ControlSurface.LAUNCHKEY_SCENE2);
    // View selection with Pads in Shift mode
    this.createViewButton(ButtonID.ROW2_1, OutputID.LED_RING1, "Session", Views.SESSION, LaunchkeyMk3ControlSurface.PAD_MODE_SESSION);
    this.createViewButton(ButtonID.ROW2_2, OutputID.LED_RING2, "Drum", Views.DRUM, LaunchkeyMk3ControlSurface.PAD_MODE_DRUM);
    this.createViewButton(ButtonID.ROW2_3, OutputID.LED_RING3, "Scale Chords", Views.DUMMY1, LaunchkeyMk3ControlSurface.PAD_MODE_SCALE_CHORDS);
    this.createViewButton(ButtonID.ROW2_4, OutputID.LED_RING4, "User Chords", Views.DUMMY2, LaunchkeyMk3ControlSurface.PAD_MODE_USER_CHORDS);
    this.createViewButton(ButtonID.ROW2_5, OutputID.LED_RING5, NAME_CUSTOM_1, Views.DUMMY3, LaunchkeyMk3ControlSurface.PAD_MODE_CUSTOM_MODE0);
    this.createViewButton(ButtonID.ROW2_6, OutputID.LED_RING6, NAME_CUSTOM_2, Views.DUMMY4, LaunchkeyMk3ControlSurface.PAD_MODE_CUSTOM_MODE1);
    this.createViewButton(ButtonID.ROW2_7, OutputID.LED_RING7, NAME_CUSTOM_3, Views.DUMMY5, LaunchkeyMk3ControlSurface.PAD_MODE_CUSTOM_MODE2);
    this.createViewButton(ButtonID.ROW2_8, OutputID.LED_RING8, NAME_CUSTOM_4, Views.DUMMY6, LaunchkeyMk3ControlSurface.PAD_MODE_CUSTOM_MODE3);
    this.createViewButton(ButtonID.DEVICE, OutputID.LED_RING9, "Device Select", Views.DEVICE, LaunchkeyMk3ControlSurface.PAD_MODE_DEVICE_SELECT);
    this.createViewButton(ButtonID.BROWSE, OutputID.LED_RING10, "Browser", Views.BROWSER, LaunchkeyMk3ControlSurface.PAD_MODE_NAVIGATION);
    // Knob mode selection with Pads in Shift mode
    this.createModeButton(ButtonID.ROW1_1, OutputID.LED1, "Device", Modes.DEVICE_PARAMS, LaunchkeyMk3ControlSurface.KNOB_MODE_PARAMS);
    this.createModeButton(ButtonID.ROW1_2, OutputID.LED2, "Volume", Modes.VOLUME, LaunchkeyMk3ControlSurface.KNOB_MODE_VOLUME);
    this.createModeButton(ButtonID.ROW1_3, OutputID.LED3, "Pan", Modes.PAN, LaunchkeyMk3ControlSurface.KNOB_MODE_PAN);
    this.createModeButton(ButtonID.ROW1_4, OutputID.LED4, "Send 1", Modes.SEND1, LaunchkeyMk3ControlSurface.KNOB_MODE_SEND1);
    this.createModeButton(ButtonID.ROW1_5, OutputID.LED5, "Send 2", Modes.SEND2, LaunchkeyMk3ControlSurface.KNOB_MODE_SEND2);
    this.createModeButton(ButtonID.ROW1_6, OutputID.LED6, NAME_CUSTOM_1, Modes.DEVICE_LAYER_SEND1, LaunchkeyMk3ControlSurface.KNOB_MODE_CUSTOM1);
    this.createModeButton(ButtonID.ROW1_7, OutputID.LED7, NAME_CUSTOM_2, Modes.DEVICE_LAYER_SEND2, LaunchkeyMk3ControlSurface.KNOB_MODE_CUSTOM2);
    this.createModeButton(ButtonID.ROW1_8, OutputID.LED8, NAME_CUSTOM_3, Modes.DEVICE_LAYER_SEND3, LaunchkeyMk3ControlSurface.KNOB_MODE_CUSTOM3);
    this.createModeButton(ButtonID.USER, OutputID.LED9, NAME_CUSTOM_4, Modes.DEVICE_LAYER_SEND4, LaunchkeyMk3ControlSurface.KNOB_MODE_CUSTOM4);
    // Fader mode selection with fader buttons in Shift mode
    this.createFaderModeButton(ButtonID.ROW3_1, OutputID.LIGHT_GUIDE1, "Device", Modes.DEVICE_PARAMS, LaunchkeyMk3ControlSurface.FADER_MODE_PARAMS);
    this.createFaderModeButton(ButtonID.ROW3_2, OutputID.LIGHT_GUIDE2, "Volume", Modes.VOLUME, LaunchkeyMk3ControlSurface.FADER_MODE_VOLUME);
    this.createFaderModeButton(ButtonID.ROW3_3, OutputID.LIGHT_GUIDE3, "Send 1", Modes.SEND1, LaunchkeyMk3ControlSurface.FADER_MODE_SEND1);
    this.createFaderModeButton(ButtonID.ROW3_4, OutputID.LIGHT_GUIDE4, "Send 2", Modes.SEND2, LaunchkeyMk3ControlSurface.FADER_MODE_SEND2);
    this.createFaderModeButton(ButtonID.ROW3_5, OutputID.LIGHT_GUIDE5, NAME_CUSTOM_1, Modes.DEVICE_LAYER_SEND1, LaunchkeyMk3ControlSurface.FADER_MODE_CUSTOM1);
    this.createFaderModeButton(ButtonID.ROW3_6, OutputID.LIGHT_GUIDE6, NAME_CUSTOM_2, Modes.DEVICE_LAYER_SEND2, LaunchkeyMk3ControlSurface.FADER_MODE_CUSTOM2);
    this.createFaderModeButton(ButtonID.ROW3_7, OutputID.LIGHT_GUIDE7, NAME_CUSTOM_3, Modes.DEVICE_LAYER_SEND3, LaunchkeyMk3ControlSurface.FADER_MODE_CUSTOM3);
    this.createFaderModeButton(ButtonID.ROW3_8, OutputID.LIGHT_GUIDE8, NAME_CUSTOM_4, Modes.DEVICE_LAYER_SEND4, LaunchkeyMk3ControlSurface.FADER_MODE_CUSTOM4);
    // Fader mode buttons
    for (int i = 0; i < 8; i++) {
        final ButtonID row1ButtonID = ButtonID.get(ButtonID.ROW_SELECT_1, i);
        final IHwButton button = surface.createButton(row1ButtonID, "Select " + (i + 1));
        final ButtonAreaCommand command = new ButtonAreaCommand(i, this.model, surface);
        button.bind(command);
        final IMidiInput midiInput = surface.getMidiInput();
        final BindType triggerBindType = this.getTriggerBindType(row1ButtonID);
        final int midiControl = LaunchkeyMk3ControlSurface.LAUNCHKEY_SELECT1 + i;
        button.bind(midiInput, triggerBindType, 15, midiControl);
        final IntSupplier supplier = command::getButtonColor;
        surface.createLight(null, supplier::getAsInt, color -> surface.setTrigger(color >= 0x1000 ? 2 : 0, midiControl, color >= 0x1000 ? color - 0x1000 : color), state -> this.colorManager.getColor(state >= 0x1000 ? state - 0x1000 : state, row1ButtonID), button);
    }
    this.addButton(surface, ButtonID.MASTERTRACK, "Toggle Select/RecArm", (event, velocity) -> {
        if (event == ButtonEvent.DOWN)
            ButtonAreaCommand.toggleSelect();
    }, 15, 0, LaunchkeyMk3ControlSurface.LAUNCHKEY_TOGGLE_SELECT, -1, true, () -> ButtonAreaCommand.isSelect() ? 40 : 127);
    // Online state
    this.addButton(ButtonID.CONTROL, "DAW Online", (event, velocity) -> surface.setDAWConnected(velocity > 0), 15, LaunchkeyMk3ControlSurface.LAUNCHKEY_DAW_ONLINE, surface::isDAWConnected);
}
Also used : LaunchkeyMk3ControlSurface(de.mossgrabers.controller.novation.launchkey.maxi.controller.LaunchkeyMk3ControlSurface) IntSupplier(java.util.function.IntSupplier) ITransport(de.mossgrabers.framework.daw.ITransport) ViewManager(de.mossgrabers.framework.featuregroup.ViewManager) ConfiguredRecordCommand(de.mossgrabers.framework.command.trigger.transport.ConfiguredRecordCommand) IMidiInput(de.mossgrabers.framework.daw.midi.IMidiInput) LaunchkeyMk3PlayCommand(de.mossgrabers.controller.novation.launchkey.maxi.command.trigger.LaunchkeyMk3PlayCommand) ButtonID(de.mossgrabers.framework.controller.ButtonID) BindType(de.mossgrabers.framework.controller.hardware.BindType) IHwButton(de.mossgrabers.framework.controller.hardware.IHwButton) ButtonAreaCommand(de.mossgrabers.controller.novation.launchkey.maxi.command.trigger.ButtonAreaCommand) DeviceLockCommand(de.mossgrabers.controller.novation.launchkey.maxi.command.trigger.DeviceLockCommand) ButtonEvent(de.mossgrabers.framework.utils.ButtonEvent) List(java.util.List) IMidiInput(de.mossgrabers.framework.daw.midi.IMidiInput) ArrayList(java.util.ArrayList) ITransport(de.mossgrabers.framework.daw.ITransport) IHost(de.mossgrabers.framework.daw.IHost) IHwLight(de.mossgrabers.framework.controller.hardware.IHwLight) IMidiOutput(de.mossgrabers.framework.daw.midi.IMidiOutput) FeatureGroupButtonColorSupplier(de.mossgrabers.framework.command.trigger.view.FeatureGroupButtonColorSupplier)

Aggregations

ConfiguredRecordCommand (de.mossgrabers.framework.command.trigger.transport.ConfiguredRecordCommand)4 IHost (de.mossgrabers.framework.daw.IHost)4 ITransport (de.mossgrabers.framework.daw.ITransport)4 IMidiInput (de.mossgrabers.framework.daw.midi.IMidiInput)4 IMidiOutput (de.mossgrabers.framework.daw.midi.IMidiOutput)4 ViewManager (de.mossgrabers.framework.featuregroup.ViewManager)3 ButtonEvent (de.mossgrabers.framework.utils.ButtonEvent)3 List (java.util.List)3 FeatureGroupButtonColorSupplier (de.mossgrabers.framework.command.trigger.view.FeatureGroupButtonColorSupplier)2 IHwLight (de.mossgrabers.framework.controller.hardware.IHwLight)2 StartClipOrSceneCommand (de.mossgrabers.controller.ni.kontrol.mkii.command.trigger.StartClipOrSceneCommand)1 KontrolProtocolControlSurface (de.mossgrabers.controller.ni.kontrol.mkii.controller.KontrolProtocolControlSurface)1 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