Search in sources :

Example 76 with ModeManager

use of de.mossgrabers.framework.featuregroup.ModeManager in project DrivenByMoss by git-moss.

the class ControlView method onButtonRow2.

/**
 * {@inheritDoc}
 */
@Override
public void onButtonRow2(final int index, final ButtonEvent event) {
    if (event != ButtonEvent.DOWN)
        return;
    final ModeManager modeManager = this.surface.getModeManager();
    Modes cm = modeManager.getActiveID();
    if (!Modes.TRACK_DETAILS.equals(cm) && !Modes.FRAME.equals(cm) && !Modes.BROWSER.equals(cm)) {
        modeManager.setActive(Modes.TRACK_DETAILS);
        cm = Modes.TRACK_DETAILS;
    }
    if (Modes.FRAME.equals(cm)) {
        modeManager.get(Modes.FRAME).onButton(0, index, event);
        return;
    } else if (Modes.BROWSER.equals(cm)) {
        modeManager.get(Modes.BROWSER).onButton(0, index, event);
        return;
    }
    switch(index) {
        // Mute
        case 0:
            this.model.getCursorTrack().toggleMute();
            break;
        // Solo
        case 1:
            this.model.getCursorTrack().toggleSolo();
            break;
        // Arm
        case 2:
            this.model.getCursorTrack().toggleRecArm();
            break;
        // Write
        case 3:
            this.model.getTransport().toggleWriteArrangerAutomation();
            break;
        // Browse
        case 4:
            this.model.getBrowser().replace(this.model.getCursorDevice());
            modeManager.setTemporary(Modes.BROWSER);
            break;
        // Dis-/Enable device
        case 5:
            this.model.getCursorDevice().toggleEnabledState();
            break;
        // Previous device
        case 6:
            this.model.getCursorDevice().selectPrevious();
            break;
        // Next device
        case 7:
            this.model.getCursorDevice().selectNext();
            break;
        default:
            // Not used
            break;
    }
}
Also used : Modes(de.mossgrabers.framework.mode.Modes) ModeManager(de.mossgrabers.framework.featuregroup.ModeManager)

Example 77 with ModeManager

use of de.mossgrabers.framework.featuregroup.ModeManager in project DrivenByMoss by git-moss.

the class SessionView method handleFirstRowModes.

/**
 * Execute the functions of row 1 if active.
 *
 * @param index The index on the first row
 */
private void handleFirstRowModes(final int index) {
    // First row mode handling
    final ITrack track = this.model.getCurrentTrackBank().getItem(index);
    if (this.isButtonCombination(ButtonID.DELETE)) {
        track.remove();
        return;
    }
    if (this.isButtonCombination(ButtonID.DUPLICATE)) {
        track.duplicate();
        return;
    }
    final ModeManager modeManager = this.surface.getModeManager();
    if (modeManager.isActive(Modes.REC_ARM))
        track.toggleRecArm();
    else if (modeManager.isActive(Modes.TRACK_SELECT)) {
        track.selectOrExpandGroup();
        this.mvHelper.notifySelectedTrack();
    } else if (modeManager.isActive(Modes.MUTE))
        track.toggleMute();
    else if (modeManager.isActive(Modes.SOLO))
        track.toggleSolo();
    else if (modeManager.isActive(Modes.STOP_CLIP))
        track.stop();
}
Also used : ITrack(de.mossgrabers.framework.daw.data.ITrack) ModeManager(de.mossgrabers.framework.featuregroup.ModeManager)

Example 78 with ModeManager

use of de.mossgrabers.framework.featuregroup.ModeManager in project DrivenByMoss by git-moss.

the class FaderCommand method execute.

/**
 * {@inheritDoc}
 */
@Override
public void execute(final int value) {
    this.model.getCurrentTrackBank().getItem(this.index).setVolume(value);
    final ModeManager modeManager = this.surface.getModeManager();
    if (!modeManager.isActive(Modes.VOLUME))
        modeManager.setActive(Modes.VOLUME);
}
Also used : ModeManager(de.mossgrabers.framework.featuregroup.ModeManager)

Example 79 with ModeManager

use of de.mossgrabers.framework.featuregroup.ModeManager 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 80 with ModeManager

use of de.mossgrabers.framework.featuregroup.ModeManager in project DrivenByMoss by git-moss.

the class KeyboardCommand method executeNormal.

/**
 * {@inheritDoc}
 */
@Override
public void executeNormal(final ButtonEvent event) {
    if (event != ButtonEvent.DOWN)
        return;
    final ViewManager viewManager = this.surface.getViewManager();
    if (viewManager.isActive(Views.PLAY)) {
        if (!this.surface.getMaschine().hasMCUDisplay())
            ((PlayView) viewManager.get(Views.PLAY)).toggleShifted();
        final ModeManager modeManager = this.surface.getModeManager();
        if (modeManager.isActive(Modes.SCALES))
            modeManager.restore();
        else
            modeManager.setTemporary(Modes.SCALES);
    } else {
        viewManager.setActive(Views.PLAY);
        ((INoteMode) this.surface.getModeManager().get(Modes.NOTE)).clearNotes();
    }
}
Also used : INoteMode(de.mossgrabers.framework.mode.INoteMode) ViewManager(de.mossgrabers.framework.featuregroup.ViewManager) ModeManager(de.mossgrabers.framework.featuregroup.ModeManager)

Aggregations

ModeManager (de.mossgrabers.framework.featuregroup.ModeManager)90 Modes (de.mossgrabers.framework.mode.Modes)22 ITrack (de.mossgrabers.framework.daw.data.ITrack)15 ITrackBank (de.mossgrabers.framework.daw.data.bank.ITrackBank)15 ViewManager (de.mossgrabers.framework.featuregroup.ViewManager)11 ICursorDevice (de.mossgrabers.framework.daw.data.ICursorDevice)10 PushConfiguration (de.mossgrabers.controller.ableton.push.PushConfiguration)6 MaschineControlSurface (de.mossgrabers.controller.ni.maschine.mk3.controller.MaschineControlSurface)4 StudioEncoderModeManager (de.mossgrabers.controller.ni.maschine.mk3.controller.StudioEncoderModeManager)4 EditNoteMode (de.mossgrabers.controller.ni.maschine.mk3.mode.EditNoteMode)4 StepState (de.mossgrabers.framework.daw.StepState)4 INoteMode (de.mossgrabers.framework.mode.INoteMode)4 IMode (de.mossgrabers.framework.featuregroup.IMode)3 NoteMode (de.mossgrabers.controller.akai.apc.mode.NoteMode)2 MCUConfiguration (de.mossgrabers.controller.mackie.mcu.MCUConfiguration)2 SLControlSurface (de.mossgrabers.controller.novation.sl.controller.SLControlSurface)2 SLMkIIIControlSurface (de.mossgrabers.controller.novation.slmkiii.controller.SLMkIIIControlSurface)2 SLMkIIIDisplay (de.mossgrabers.controller.novation.slmkiii.controller.SLMkIIIDisplay)2 IHwRelativeKnob (de.mossgrabers.framework.controller.hardware.IHwRelativeKnob)2 INoteClip (de.mossgrabers.framework.daw.INoteClip)2