Search in sources :

Example 1 with ContinuousCommand

use of de.mossgrabers.framework.command.core.ContinuousCommand 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 ContinuousCommand

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

the class HUIControlSurface method handleMidi.

/**
 * {@inheritDoc}
 */
@Override
protected void handleMidi(final int status, final int data1, final int data2) {
    final int code = status & 0xF0;
    if (code != 0xB0)
        return;
    switch(data1) {
        // Move fader high-byte
        case 0x00:
        case 0x01:
        case 0x02:
        case 0x03:
        case 0x04:
        case 0x05:
        case 0x06:
        case 0x07:
        // This is an iCON extension
        case 0x08:
            this.faderHiValues[data1] = data2;
            break;
        case 0x0d:
            final int d = ENCODER.encode(DECODER.decode(data2));
            this.getContinuous(ContinuousID.PLAY_POSITION).getCommand().execute(d);
            break;
        // Button zone selection
        case 0x0F:
            this.zone = data2;
            break;
        // Move fader low-byte
        case 0x20:
        case 0x21:
        case 0x22:
        case 0x23:
        case 0x24:
        case 0x25:
        case 0x26:
        case 0x27:
            final int chnl = data1 - 0x20;
            final int value = (this.faderHiValues[chnl] << 7) + data2;
            final ContinuousCommand command = this.getContinuous(ContinuousID.get(ContinuousID.FADER1, chnl)).getCommand();
            ((WorkaroundFader) command).executeHiRes(value);
            break;
        case 0x28:
            final int masterValue = (this.faderHiValues[8] << 7) + data2;
            ((WorkaroundMasterFader) this.getContinuous(ContinuousID.FADER_MASTER).getCommand()).executeHiRes(masterValue);
            break;
        // Button port up/down (a button in the selected row)
        case 0x2F:
            final boolean isDown = data2 >= 0x40;
            final int buttonIndex = this.zone * 8 + data2 % 8;
            final IHwButton button = this.huiButtons.get(Integer.valueOf(buttonIndex));
            if (button == null)
                this.host.error("Button " + buttonIndex + " not supported (Zone: " + this.zone + " Index: " + data2 % 8 + ")");
            else
                button.trigger(isDown ? ButtonEvent.DOWN : ButtonEvent.UP);
            break;
        case 0x40:
        case 0x41:
        case 0x42:
        case 0x43:
        case 0x44:
        case 0x45:
        case 0x46:
        case 0x47:
            final int channel = data1 - 0x40;
            final int v = data2 > 0x40 ? data2 - 0x40 : 128 - data2;
            this.getContinuous(ContinuousID.get(ContinuousID.KNOB1, channel)).getCommand().execute(v);
            break;
        default:
            this.host.println("Unhandled MIDI CC: " + data1);
            break;
    }
}
Also used : ContinuousCommand(de.mossgrabers.framework.command.core.ContinuousCommand) WorkaroundFader(de.mossgrabers.controller.mackie.hui.command.trigger.WorkaroundFader) WorkaroundMasterFader(de.mossgrabers.controller.mackie.hui.command.trigger.WorkaroundMasterFader) IHwButton(de.mossgrabers.framework.controller.hardware.IHwButton)

Aggregations

ContinuousCommand (de.mossgrabers.framework.command.core.ContinuousCommand)2 IHwButton (de.mossgrabers.framework.controller.hardware.IHwButton)2 WorkaroundFader (de.mossgrabers.controller.mackie.hui.command.trigger.WorkaroundFader)1 WorkaroundMasterFader (de.mossgrabers.controller.mackie.hui.command.trigger.WorkaroundMasterFader)1 PitchbendCommand (de.mossgrabers.framework.command.core.PitchbendCommand)1 TriggerCommand (de.mossgrabers.framework.command.core.TriggerCommand)1 IHwContinuousControl (de.mossgrabers.framework.controller.hardware.IHwContinuousControl)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