Search in sources :

Example 1 with TriggerCommand

use of de.mossgrabers.framework.command.core.TriggerCommand in project DrivenByMoss by git-moss.

the class AbstractControllerSetup method test.

/**
 * {@inheritDoc}
 */
@Override
public void test(final TestCallback callback) {
    final TestFramework framework = new TestFramework(this.host);
    this.getSurfaces().forEach(surface -> {
        framework.scheduleFunction(() -> this.host.println("Testing controller: " + this.getClass().getName()));
        final ViewManager viewManager = surface.getViewManager();
        final ModeManager modeManager = surface.getModeManager();
        final int max = this.model.getValueChanger().getUpperBound() - 1;
        for (final Views viewID : Views.values()) {
            if (viewManager.get(viewID) == null)
                continue;
            for (final Modes modeID : Modes.values()) {
                if (modeManager.get(modeID) == null)
                    continue;
                framework.scheduleFunction(() -> {
                    this.host.println("- View " + viewID + " Mode " + modeID);
                    viewManager.setActive(viewID);
                    modeManager.setActive(modeID);
                    for (final ButtonID buttonID : ButtonID.values()) {
                        final IHwButton button = surface.getButton(buttonID);
                        if (button == null)
                            continue;
                        button.trigger(ButtonEvent.DOWN);
                        button.trigger(ButtonEvent.LONG);
                        button.trigger(ButtonEvent.UP);
                    }
                    for (final ContinuousID continuousID : ContinuousID.values()) {
                        final IHwContinuousControl continuous = surface.getContinuous(continuousID);
                        if (continuous == null)
                            continue;
                        final TriggerCommand touchCommand = continuous.getTouchCommand();
                        if (touchCommand != null) {
                            touchCommand.execute(ButtonEvent.DOWN, 127);
                            touchCommand.execute(ButtonEvent.LONG, 127);
                            touchCommand.execute(ButtonEvent.UP, 0);
                        }
                        final ContinuousCommand command = continuous.getCommand();
                        if (command != null) {
                            command.execute(0);
                            command.execute(max);
                            command.execute(max / 2);
                        }
                        final PitchbendCommand pitchbendCommand = continuous.getPitchbendCommand();
                        if (pitchbendCommand != null) {
                            pitchbendCommand.onPitchbend(0, 0);
                            pitchbendCommand.onPitchbend(0, 127);
                            pitchbendCommand.onPitchbend(0, 64);
                        }
                    }
                });
            }
        }
    });
    callback.startTesting();
    framework.executeScheduler(callback);
}
Also used : Modes(de.mossgrabers.framework.mode.Modes) Views(de.mossgrabers.framework.view.Views) TriggerCommand(de.mossgrabers.framework.command.core.TriggerCommand) ContinuousCommand(de.mossgrabers.framework.command.core.ContinuousCommand) ViewManager(de.mossgrabers.framework.featuregroup.ViewManager) IHwButton(de.mossgrabers.framework.controller.hardware.IHwButton) TestFramework(de.mossgrabers.framework.utils.TestFramework) PitchbendCommand(de.mossgrabers.framework.command.core.PitchbendCommand) IHwContinuousControl(de.mossgrabers.framework.controller.hardware.IHwContinuousControl) ModeManager(de.mossgrabers.framework.featuregroup.ModeManager)

Example 2 with TriggerCommand

use of de.mossgrabers.framework.command.core.TriggerCommand in project DrivenByMoss by git-moss.

the class SessionView method onGridNote.

/**
 * {@inheritDoc}
 */
@Override
public void onGridNote(final int note, final int velocity) {
    if (velocity == 0) {
        final TriggerCommand triggerCommand = this.surface.getViewManager().getView(Views.VIEW_SESSION).getTriggerCommand(Commands.COMMAND_SELECT_SESSION_VIEW);
        ((SelectSessionViewCommand) triggerCommand).setTemporary();
        return;
    }
    final int index = note - 36;
    int t = index % this.columns;
    int s = this.rows - 1 - index / this.columns;
    final boolean flipSession = this.surface.getConfiguration().isFlipSession();
    if (flipSession) {
        final int dummy = t;
        t = s;
        s = dummy;
    }
    final IChannelBank tb = this.model.getCurrentTrackBank();
    // Birds-eye-view navigation
    if (this.surface.isShiftPressed()) {
        // Calculate page offsets
        final int numTracks = tb.getNumTracks();
        final int numScenes = tb.getNumScenes();
        final int trackPosition = tb.getTrack(0).getPosition() / numTracks;
        final int scenePosition = tb.getScenePosition() / numScenes;
        final int selX = flipSession ? scenePosition : trackPosition;
        final int selY = flipSession ? trackPosition : scenePosition;
        final int padsX = flipSession ? this.rows : this.columns;
        final int padsY = flipSession ? this.columns : this.rows;
        final int offsetX = selX / padsX * padsX;
        final int offsetY = selY / padsY * padsY;
        tb.scrollToChannel(offsetX * numTracks + t * padsX);
        tb.scrollToScene(offsetY * numScenes + s * padsY);
        return;
    }
    // Duplicate a clip
    final ITrack track = tb.getTrack(t);
    if (this.surface.isPressed(PushControlSurface.PUSH_BUTTON_DUPLICATE)) {
        this.surface.setButtonConsumed(PushControlSurface.PUSH_BUTTON_DUPLICATE);
        if (track.doesExist())
            track.getSlot(s).duplicate();
        return;
    }
    // Stop clip
    if (this.surface.isPressed(PushControlSurface.PUSH_BUTTON_CLIP_STOP)) {
        this.surface.setButtonConsumed(PushControlSurface.PUSH_BUTTON_CLIP_STOP);
        track.stop();
        return;
    }
    // Browse for clips
    if (this.surface.isPressed(PushControlSurface.PUSH_BUTTON_BROWSE)) {
        this.surface.setButtonConsumed(PushControlSurface.PUSH_BUTTON_BROWSE);
        if (!track.doesExist())
            return;
        track.getSlot(s).browse();
        final ModeManager modeManager = this.surface.getModeManager();
        if (!modeManager.isActiveMode(Modes.MODE_BROWSER))
            modeManager.setActiveMode(Modes.MODE_BROWSER);
        return;
    }
    super.onGridNote(note, velocity);
}
Also used : TriggerCommand(de.mossgrabers.framework.command.core.TriggerCommand) ITrack(de.mossgrabers.framework.daw.data.ITrack) IChannelBank(de.mossgrabers.framework.daw.IChannelBank) SelectSessionViewCommand(de.mossgrabers.push.command.trigger.SelectSessionViewCommand) ModeManager(de.mossgrabers.framework.mode.ModeManager)

Aggregations

TriggerCommand (de.mossgrabers.framework.command.core.TriggerCommand)2 ContinuousCommand (de.mossgrabers.framework.command.core.ContinuousCommand)1 PitchbendCommand (de.mossgrabers.framework.command.core.PitchbendCommand)1 IHwButton (de.mossgrabers.framework.controller.hardware.IHwButton)1 IHwContinuousControl (de.mossgrabers.framework.controller.hardware.IHwContinuousControl)1 IChannelBank (de.mossgrabers.framework.daw.IChannelBank)1 ITrack (de.mossgrabers.framework.daw.data.ITrack)1 ModeManager (de.mossgrabers.framework.featuregroup.ModeManager)1 ViewManager (de.mossgrabers.framework.featuregroup.ViewManager)1 ModeManager (de.mossgrabers.framework.mode.ModeManager)1 Modes (de.mossgrabers.framework.mode.Modes)1 TestFramework (de.mossgrabers.framework.utils.TestFramework)1 Views (de.mossgrabers.framework.view.Views)1 SelectSessionViewCommand (de.mossgrabers.push.command.trigger.SelectSessionViewCommand)1