Search in sources :

Example 1 with IHwButton

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

the class LaunchpadControlSurface method setLaunchpadMode.

private void setLaunchpadMode(final String data) {
    this.sendLaunchpadSysEx(data);
    for (final Entry<ButtonID, IHwButton> entry : this.getButtons().entrySet()) {
        final ButtonID key = entry.getKey();
        final int keyValue = key.ordinal();
        if (ButtonID.PAD1.ordinal() < keyValue || ButtonID.PAD64.ordinal() > keyValue)
            entry.getValue().getLight().forceFlush();
    }
}
Also used : ButtonID(de.mossgrabers.framework.controller.ButtonID) IHwButton(de.mossgrabers.framework.controller.hardware.IHwButton)

Example 2 with IHwButton

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

the class LaunchkeyMk3ControlSurface method createPads.

/**
 * {@inheritDoc}
 */
@Override
protected void createPads() {
    ((LaunchkeyPadGrid) this.padGrid).setView(Views.SESSION);
    super.createPads();
    // Map alternative MIDI notes for grid...
    final int size = this.padGrid.getRows() * this.padGrid.getCols();
    final int startNote = this.padGrid.getStartNote();
    for (int i = 0; i < size; i++) {
        final int note = startNote + i;
        final ButtonID buttonID = ButtonID.get(ButtonID.PAD17, i);
        IHwButton pad = this.createButton(buttonID, "D " + (i + 1));
        pad.addLight(this.surfaceFactory.createLight(this.surfaceID, null, () -> this.padGrid.getLightInfo(note).getEncoded(), state -> this.padGrid.sendState(note), colorIndex -> this.colorManager.getColor(colorIndex, buttonID), null));
        int[] translated = LaunchkeyPadGrid.translateToController(Views.DRUM, note);
        pad.bind(this.input, BindType.NOTE, translated[0], translated[1]);
        pad.bind((event, velocity) -> this.handleGridNote(event, note, velocity));
        final ButtonID buttonID2 = ButtonID.get(ButtonID.PAD33, i);
        pad = this.createButton(buttonID2, "DS " + (i + 1));
        pad.addLight(this.surfaceFactory.createLight(this.surfaceID, null, () -> this.padGrid.getLightInfo(note).getEncoded(), state -> this.padGrid.sendState(note), colorIndex -> this.colorManager.getColor(colorIndex, buttonID2), null));
        translated = LaunchkeyPadGrid.translateToController(Views.DEVICE, note);
        pad.bind(this.input, BindType.NOTE, translated[0], translated[1]);
        pad.bind((event, velocity) -> this.handleGridNote(event, note, velocity));
    }
}
Also used : IHwButton(de.mossgrabers.framework.controller.hardware.IHwButton) ModeManager(de.mossgrabers.framework.featuregroup.ModeManager) LaunchkeyMk3Configuration(de.mossgrabers.controller.novation.launchkey.maxi.LaunchkeyMk3Configuration) IMidiOutput(de.mossgrabers.framework.daw.midi.IMidiOutput) AbstractControlSurface(de.mossgrabers.framework.controller.AbstractControlSurface) BindType(de.mossgrabers.framework.controller.hardware.BindType) ButtonID(de.mossgrabers.framework.controller.ButtonID) StringUtils(de.mossgrabers.framework.utils.StringUtils) IMode(de.mossgrabers.framework.featuregroup.IMode) IMidiInput(de.mossgrabers.framework.daw.midi.IMidiInput) DeviceInquiry(de.mossgrabers.framework.daw.midi.DeviceInquiry) Views(de.mossgrabers.framework.view.Views) ColorManager(de.mossgrabers.framework.controller.color.ColorManager) IHost(de.mossgrabers.framework.daw.IHost) ButtonID(de.mossgrabers.framework.controller.ButtonID) IHwButton(de.mossgrabers.framework.controller.hardware.IHwButton)

Example 3 with IHwButton

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

the class AbstractControllerSetup method addButton.

/**
 * Create a hardware button proxy, bind a trigger command to it and bind it to the trigger bind
 * type retrieved from {@link #getTriggerBindType(ButtonID)}.
 *
 * @param surface The control surface
 * @param buttonID The ID of the button (for later access)
 * @param label The label of the button
 * @param supplier Callback for retrieving the state of the light
 * @param midiInputChannel The MIDI input channel
 * @param midiOutputChannel The MIDI output channel
 * @param midiControl The MIDI CC or note
 * @param value The specific value of the control to bind to
 * @param command The command to bind
 * @param hasLight True create and add a light
 * @param colorIds The color IDs to map to the states
 */
protected void addButton(final S surface, final ButtonID buttonID, final String label, final TriggerCommand command, final int midiInputChannel, final int midiOutputChannel, final int midiControl, final int value, final boolean hasLight, final IntSupplier supplier, final String... colorIds) {
    final IHwButton button = surface.createButton(buttonID, label);
    button.bind(command);
    if (midiControl < 0)
        return;
    final IMidiInput midiInput = surface.getMidiInput();
    final BindType triggerBindType = this.getTriggerBindType(buttonID);
    if (value == -1)
        button.bind(midiInput, triggerBindType, midiInputChannel, midiControl);
    else
        button.bind(midiInput, triggerBindType, midiInputChannel, midiControl, value);
    if (hasLight) {
        final IntSupplier intSupplier = () -> button.isPressed() ? 1 : 0;
        final IntSupplier supp = supplier == null ? intSupplier : supplier;
        this.addLight(surface, null, buttonID, button, midiOutputChannel, midiControl, supp, colorIds);
    }
}
Also used : IntSupplier(java.util.function.IntSupplier) IMidiInput(de.mossgrabers.framework.daw.midi.IMidiInput) BindType(de.mossgrabers.framework.controller.hardware.BindType) IHwButton(de.mossgrabers.framework.controller.hardware.IHwButton)

Example 4 with IHwButton

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

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

the class AbstractView method simulateButtonPress.

/**
 * Simulate pressing a button by sending a button down and up event.
 *
 * @param buttonID The ID of the button to trigger
 */
protected void simulateButtonPress(final ButtonID buttonID) {
    final IHwButton button = this.surface.getButton(buttonID);
    final AbstractTriggerCommand<?, ?> triggerCommand = (AbstractTriggerCommand<?, ?>) button.getCommand();
    triggerCommand.executeNormal(ButtonEvent.DOWN);
    triggerCommand.executeNormal(ButtonEvent.UP);
}
Also used : AbstractTriggerCommand(de.mossgrabers.framework.command.core.AbstractTriggerCommand) IHwButton(de.mossgrabers.framework.controller.hardware.IHwButton)

Aggregations

IHwButton (de.mossgrabers.framework.controller.hardware.IHwButton)17 ButtonID (de.mossgrabers.framework.controller.ButtonID)4 IStepInfo (de.mossgrabers.framework.daw.IStepInfo)4 StepState (de.mossgrabers.framework.daw.StepState)4 IntSupplier (java.util.function.IntSupplier)4 BindType (de.mossgrabers.framework.controller.hardware.BindType)3 IMidiInput (de.mossgrabers.framework.daw.midi.IMidiInput)3 AbstractTriggerCommand (de.mossgrabers.framework.command.core.AbstractTriggerCommand)2 ContinuousCommand (de.mossgrabers.framework.command.core.ContinuousCommand)2 IHwLight (de.mossgrabers.framework.controller.hardware.IHwLight)2 IHost (de.mossgrabers.framework.daw.IHost)2 IMidiOutput (de.mossgrabers.framework.daw.midi.IMidiOutput)2 ModeManager (de.mossgrabers.framework.featuregroup.ModeManager)2 Views (de.mossgrabers.framework.view.Views)2 Color (com.bitwig.extension.api.Color)1 HardwareButton (com.bitwig.extension.controller.api.HardwareButton)1 HardwareLightVisualState (com.bitwig.extension.controller.api.HardwareLightVisualState)1 HardwareSurface (com.bitwig.extension.controller.api.HardwareSurface)1 InternalHardwareLightState (com.bitwig.extension.controller.api.InternalHardwareLightState)1 MultiStateHardwareLight (com.bitwig.extension.controller.api.MultiStateHardwareLight)1