Search in sources :

Example 11 with ModeManager

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

the class KeyCommand method execute.

/**
 * {@inheritDoc}
 */
@Override
public void execute(final ButtonEvent event) {
    if (event != ButtonEvent.DOWN)
        return;
    final ModeManager modeManager = this.surface.getModeManager();
    switch(this.key) {
        case ENTER:
            if (modeManager.isActiveMode(Modes.MODE_BROWSER)) {
                this.model.getBrowser().stopBrowsing(true);
                modeManager.restoreMode();
            } else
                this.model.getApplication().enter();
            break;
        case ESCAPE:
            if (modeManager.isActiveMode(Modes.MODE_BROWSER)) {
                this.model.getBrowser().stopBrowsing(false);
                modeManager.restoreMode();
            } else
                this.model.getApplication().escape();
            break;
    }
}
Also used : ModeManager(de.mossgrabers.framework.mode.ModeManager)

Example 12 with ModeManager

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

the class DeviceParamsMode method moveUp.

/**
 * Move up the hierarchy.
 */
protected void moveUp() {
    // There is no device on the track move upwards to the track view
    final ICursorDevice cd = this.model.getCursorDevice();
    final View activeView = this.surface.getViewManager().getActiveView();
    if (!cd.hasSelectedDevice()) {
        activeView.executeTriggerCommand(Commands.COMMAND_TRACK, ButtonEvent.DOWN);
        return;
    }
    // Parameter banks are shown -> show devices
    final ModeManager modeManager = this.surface.getModeManager();
    final DeviceParamsMode deviceParamsMode = (DeviceParamsMode) modeManager.getMode(Modes.MODE_DEVICE_PARAMS);
    if (!deviceParamsMode.isShowDevices()) {
        deviceParamsMode.setShowDevices(true);
        return;
    }
    // Devices are shown, if nested show the layers otherwise move up to the tracks
    if (cd.isNested()) {
        cd.selectParent();
        modeManager.setActiveMode(Modes.MODE_DEVICE_LAYER);
        deviceParamsMode.setShowDevices(false);
        cd.selectChannel();
        return;
    }
    // Move up to the track
    if (this.model.isCursorDeviceOnMasterTrack()) {
        activeView.executeTriggerCommand(Commands.COMMAND_MASTERTRACK, ButtonEvent.DOWN);
        activeView.executeTriggerCommand(Commands.COMMAND_MASTERTRACK, ButtonEvent.UP);
    } else
        activeView.executeTriggerCommand(Commands.COMMAND_TRACK, ButtonEvent.DOWN);
}
Also used : View(de.mossgrabers.framework.view.View) ICursorDevice(de.mossgrabers.framework.daw.ICursorDevice) ModeManager(de.mossgrabers.framework.mode.ModeManager)

Example 13 with ModeManager

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

the class AbstractTrackMode method updateSecondRow.

/**
 * {@inheritDoc}
 */
@Override
public void updateSecondRow() {
    final PushConfiguration config = this.surface.getConfiguration();
    final IChannelBank tb = this.model.getCurrentTrackBank();
    if (this.isPush2) {
        if (this.surface.isPressed(PushControlSurface.PUSH_BUTTON_CLIP_STOP)) {
            for (int i = 0; i < 8; i++) {
                final ITrack track = tb.getTrack(i);
                this.surface.updateButton(102 + i, track.doesExist() && track.isPlaying() ? PushColors.PUSH2_COLOR_RED_HI : PushColors.PUSH2_COLOR_BLACK);
            }
            return;
        }
        if (config.isMuteLongPressed() || config.isSoloLongPressed() || config.isMuteSoloLocked()) {
            final boolean muteState = config.isMuteState();
            for (int i = 0; i < 8; i++) this.surface.updateButton(102 + i, this.getTrackStateColor(muteState, tb.getTrack(i)));
            return;
        }
        final ModeManager modeManager = this.surface.getModeManager();
        this.surface.updateButton(102, modeManager.isActiveMode(Modes.MODE_VOLUME) ? PushColors.PUSH2_COLOR2_WHITE : PushColors.PUSH2_COLOR_BLACK);
        this.surface.updateButton(103, modeManager.isActiveMode(Modes.MODE_PAN) ? PushColors.PUSH2_COLOR2_WHITE : PushColors.PUSH2_COLOR_BLACK);
        this.surface.updateButton(104, modeManager.isActiveMode(Modes.MODE_CROSSFADER) ? PushColors.PUSH2_COLOR2_WHITE : PushColors.PUSH2_COLOR_BLACK);
        this.surface.updateButton(105, PushColors.PUSH2_COLOR_BLACK);
        final boolean sendsAreToggled = config.isSendsAreToggled();
        this.surface.updateButton(106, modeManager.isActiveMode(sendsAreToggled ? Modes.MODE_SEND5 : Modes.MODE_SEND1) ? PushColors.PUSH2_COLOR2_WHITE : PushColors.PUSH2_COLOR_BLACK);
        this.surface.updateButton(107, modeManager.isActiveMode(sendsAreToggled ? Modes.MODE_SEND6 : Modes.MODE_SEND2) ? PushColors.PUSH2_COLOR2_WHITE : PushColors.PUSH2_COLOR_BLACK);
        this.surface.updateButton(108, modeManager.isActiveMode(sendsAreToggled ? Modes.MODE_SEND7 : Modes.MODE_SEND3) ? PushColors.PUSH2_COLOR2_WHITE : PushColors.PUSH2_COLOR_BLACK);
        this.surface.updateButton(109, tb instanceof ITrackBank && ((ITrackBank) tb).hasParent() ? PushColors.PUSH2_COLOR2_WHITE : PushColors.PUSH2_COLOR_BLACK);
        return;
    }
    final boolean muteState = config.isMuteState();
    for (int i = 0; i < 8; i++) {
        final ITrack t = tb.getTrack(i);
        int color = PushColors.PUSH1_COLOR_BLACK;
        if (t.doesExist()) {
            if (muteState) {
                if (!t.isMute())
                    color = PushColors.PUSH1_COLOR2_YELLOW_HI;
            } else
                color = t.isSolo() ? PushColors.PUSH1_COLOR2_BLUE_HI : PushColors.PUSH1_COLOR2_GREY_LO;
        }
        this.surface.updateButton(102 + i, color);
    }
}
Also used : PushConfiguration(de.mossgrabers.push.PushConfiguration) ITrack(de.mossgrabers.framework.daw.data.ITrack) ITrackBank(de.mossgrabers.framework.daw.ITrackBank) IChannelBank(de.mossgrabers.framework.daw.IChannelBank) ModeManager(de.mossgrabers.framework.mode.ModeManager)

Example 14 with ModeManager

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

the class PushControllerSetup method handleTrackChange.

/**
 * Handle a track selection change.
 *
 * @param index The index of the track
 * @param isSelected Has the track been selected?
 */
private void handleTrackChange(final int index, final boolean isSelected) {
    if (!isSelected)
        return;
    final PushControlSurface surface = this.getSurface();
    final ViewManager viewManager = surface.getViewManager();
    final ModeManager modeManager = surface.getModeManager();
    // Recall last used view (if we are not in session mode)
    if (!viewManager.isActiveView(Views.VIEW_SESSION)) {
        final ITrack selectedTrack = this.model.getCurrentTrackBank().getSelectedTrack();
        if (selectedTrack != null) {
            final Integer preferredView = viewManager.getPreferredView(selectedTrack.getPosition());
            viewManager.setActiveView(preferredView == null ? this.configuration.getDefaultNoteView() : preferredView);
        }
    }
    if (modeManager.isActiveMode(Modes.MODE_MASTER))
        modeManager.setActiveMode(Modes.MODE_TRACK);
    if (viewManager.isActiveView(Views.VIEW_PLAY))
        viewManager.getActiveView().updateNoteMapping();
    // Reset drum octave because the drum pad bank is also reset
    this.scales.setDrumOctave(0);
    if (viewManager.isActiveView(Views.VIEW_DRUM))
        viewManager.getView(Views.VIEW_DRUM).updateNoteMapping();
}
Also used : ITrack(de.mossgrabers.framework.daw.data.ITrack) ViewManager(de.mossgrabers.framework.view.ViewManager) PushControlSurface(de.mossgrabers.push.controller.PushControlSurface) ModeManager(de.mossgrabers.framework.mode.ModeManager)

Example 15 with ModeManager

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

the class PushControllerSetup method createObservers.

/**
 * {@inheritDoc}
 */
@Override
protected void createObservers() {
    final PushControlSurface surface = this.getSurface();
    if (this.configuration.isPush2()) {
        this.configuration.addSettingObserver(PushConfiguration.DISPLAY_BRIGHTNESS, surface::sendDisplayBrightness);
        this.configuration.addSettingObserver(PushConfiguration.LED_BRIGHTNESS, surface::sendLEDBrightness);
        this.configuration.addSettingObserver(PushConfiguration.PAD_SENSITIVITY, () -> {
            surface.sendPadVelocityCurve();
            surface.sendPadThreshold();
        });
        this.configuration.addSettingObserver(PushConfiguration.PAD_GAIN, () -> {
            surface.sendPadVelocityCurve();
            surface.sendPadThreshold();
        });
        this.configuration.addSettingObserver(PushConfiguration.PAD_DYNAMICS, () -> {
            surface.sendPadVelocityCurve();
            surface.sendPadThreshold();
        });
    } else {
        this.configuration.addSettingObserver(PushConfiguration.VELOCITY_CURVE, surface::sendPadSensitivity);
        this.configuration.addSettingObserver(PushConfiguration.PAD_THRESHOLD, surface::sendPadSensitivity);
    }
    surface.getModeManager().addModeListener((oldMode, newMode) -> {
        this.updateMode(null);
        this.updateMode(newMode);
    });
    surface.getViewManager().addViewChangeListener((previousViewId, activeViewId) -> {
        // Update button states
        final View view = surface.getViewManager().getActiveView();
        for (final int button : surface.getButtons()) {
            if (surface.shouldUpdateButton(button))
                surface.setButton(button, view.usesButton(button) ? ColorManager.BUTTON_STATE_ON : ColorManager.BUTTON_STATE_OFF);
        }
        // Update ribbon mode
        if (Views.VIEW_SESSION.equals(activeViewId))
            surface.setRibbonMode(PushControlSurface.PUSH_RIBBON_PAN);
        else
            this.updateRibbonMode();
    });
    this.configuration.addSettingObserver(PushConfiguration.RIBBON_MODE, this::updateRibbonMode);
    this.configuration.addSettingObserver(PushConfiguration.SEND_PORT, () -> ((PushDisplay) surface.getDisplay()).setCommunicationPort(this.configuration.getSendPort()));
    this.configuration.addSettingObserver(PushConfiguration.DEBUG_MODE, () -> {
        final ModeManager modeManager = surface.getModeManager();
        final Integer debugMode = this.configuration.getDebugMode();
        if (modeManager.getMode(debugMode) != null)
            modeManager.setActiveMode(debugMode);
        else
            this.host.error("Mode " + debugMode + " not registered.");
    });
    this.createScaleObservers(this.configuration);
}
Also used : PushControlSurface(de.mossgrabers.push.controller.PushControlSurface) ColorView(de.mossgrabers.push.view.ColorView) PlayView(de.mossgrabers.push.view.PlayView) SequencerView(de.mossgrabers.push.view.SequencerView) ScenePlayView(de.mossgrabers.push.view.ScenePlayView) DrumView(de.mossgrabers.push.view.DrumView) SceneView(de.mossgrabers.framework.view.SceneView) View(de.mossgrabers.framework.view.View) ClipView(de.mossgrabers.push.view.ClipView) AbstractSequencerView(de.mossgrabers.framework.view.AbstractSequencerView) PrgChangeView(de.mossgrabers.push.view.PrgChangeView) PianoView(de.mossgrabers.push.view.PianoView) SessionView(de.mossgrabers.push.view.SessionView) RaindropsView(de.mossgrabers.push.view.RaindropsView) ModeManager(de.mossgrabers.framework.mode.ModeManager)

Aggregations

ModeManager (de.mossgrabers.framework.mode.ModeManager)67 IChannelBank (de.mossgrabers.framework.daw.IChannelBank)20 ITrack (de.mossgrabers.framework.daw.data.ITrack)18 ICursorDevice (de.mossgrabers.framework.daw.ICursorDevice)9 ViewManager (de.mossgrabers.framework.view.ViewManager)7 PushConfiguration (de.mossgrabers.push.PushConfiguration)7 View (de.mossgrabers.framework.view.View)6 SceneView (de.mossgrabers.framework.view.SceneView)5 PushControlSurface (de.mossgrabers.push.controller.PushControlSurface)5 ITrackBank (de.mossgrabers.framework.daw.ITrackBank)4 IChannel (de.mossgrabers.framework.daw.data.IChannel)4 ITransport (de.mossgrabers.framework.daw.ITransport)3 DeviceBrowserMode (de.mossgrabers.push.mode.device.DeviceBrowserMode)3 DeviceParamsMode (de.mossgrabers.push.mode.device.DeviceParamsMode)3 APCControlSurface (de.mossgrabers.apc.controller.APCControlSurface)2 APCminiControlSurface (de.mossgrabers.apcmini.controller.APCminiControlSurface)2 ICursorClip (de.mossgrabers.framework.daw.ICursorClip)2 IMasterTrack (de.mossgrabers.framework.daw.data.IMasterTrack)2 AbstractSequencerView (de.mossgrabers.framework.view.AbstractSequencerView)2 LaunchpadControlSurface (de.mossgrabers.launchpad.controller.LaunchpadControlSurface)2