Search in sources :

Example 1 with IHwContinuousControl

use of de.mossgrabers.framework.controller.hardware.IHwContinuousControl in project DrivenByMoss by git-moss.

the class UserView method bindCurrentPage.

/**
 * Update the binding to the current page.
 */
private void bindCurrentPage() {
    for (int i = 0; i < 8; i++) {
        final ContinuousID faderID = ContinuousID.get(ContinuousID.FADER1, i);
        final IHwContinuousControl continuous = this.surface.getContinuous(faderID);
        if (continuous != null)
            continuous.bind(this.userParameterBank.getItem(i));
    }
}
Also used : ContinuousID(de.mossgrabers.framework.controller.ContinuousID) IHwContinuousControl(de.mossgrabers.framework.controller.hardware.IHwContinuousControl)

Example 2 with IHwContinuousControl

use of de.mossgrabers.framework.controller.hardware.IHwContinuousControl in project DrivenByMoss by git-moss.

the class UserView method onDeactivate.

/**
 * {@inheritDoc}
 */
@Override
public void onDeactivate() {
    for (int i = 0; i < 8; i++) {
        final ContinuousID faderID = ContinuousID.get(ContinuousID.FADER1, i);
        final IHwContinuousControl continuous = this.surface.getContinuous(faderID);
        if (continuous != null)
            continuous.bind((IParameter) null);
    }
    this.surface.rebindGrid();
    super.onDeactivate();
}
Also used : ContinuousID(de.mossgrabers.framework.controller.ContinuousID) IParameter(de.mossgrabers.framework.daw.data.IParameter) IHwContinuousControl(de.mossgrabers.framework.controller.hardware.IHwContinuousControl)

Example 3 with IHwContinuousControl

use of de.mossgrabers.framework.controller.hardware.IHwContinuousControl 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 4 with IHwContinuousControl

use of de.mossgrabers.framework.controller.hardware.IHwContinuousControl in project DrivenByMoss by git-moss.

the class Kontrol1ControlSurface method buttonChange.

/**
 * {@inheritDoc}
 */
@Override
public void buttonChange(final int usbControlNumber, final boolean isPressed) {
    final ButtonID buttonID = BUTTON_MAP.get(Integer.valueOf(usbControlNumber));
    if (buttonID == null) {
        // Simulate knob touch via CC
        final ContinuousID continuousID = CONTINUOUS_MAP.get(Integer.valueOf(usbControlNumber));
        if (continuousID == null)
            return;
        final IHwContinuousControl continuous = this.getContinuous(continuousID);
        if (isPressed) {
            if (!continuous.isTouched())
                continuous.triggerTouch(true);
        } else if (continuous.isTouched())
            continuous.triggerTouch(false);
        return;
    }
    // Simulate button press via CC
    if (isPressed) {
        if (!this.isPressed(buttonID))
            this.getButton(buttonID).trigger(ButtonEvent.DOWN);
    } else if (this.isPressed(buttonID))
        this.getButton(buttonID).trigger(ButtonEvent.UP);
}
Also used : ContinuousID(de.mossgrabers.framework.controller.ContinuousID) ButtonID(de.mossgrabers.framework.controller.ButtonID) IHwContinuousControl(de.mossgrabers.framework.controller.hardware.IHwContinuousControl)

Aggregations

IHwContinuousControl (de.mossgrabers.framework.controller.hardware.IHwContinuousControl)4 ContinuousID (de.mossgrabers.framework.controller.ContinuousID)3 ContinuousCommand (de.mossgrabers.framework.command.core.ContinuousCommand)1 PitchbendCommand (de.mossgrabers.framework.command.core.PitchbendCommand)1 TriggerCommand (de.mossgrabers.framework.command.core.TriggerCommand)1 ButtonID (de.mossgrabers.framework.controller.ButtonID)1 IHwButton (de.mossgrabers.framework.controller.hardware.IHwButton)1 IParameter (de.mossgrabers.framework.daw.data.IParameter)1 ModeManager (de.mossgrabers.framework.featuregroup.ModeManager)1 ViewManager (de.mossgrabers.framework.featuregroup.ViewManager)1 Modes (de.mossgrabers.framework.mode.Modes)1 TestFramework (de.mossgrabers.framework.utils.TestFramework)1 Views (de.mossgrabers.framework.view.Views)1