Search in sources :

Example 1 with WorkaroundMasterFader

use of de.mossgrabers.controller.mackie.hui.command.trigger.WorkaroundMasterFader 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

WorkaroundFader (de.mossgrabers.controller.mackie.hui.command.trigger.WorkaroundFader)1 WorkaroundMasterFader (de.mossgrabers.controller.mackie.hui.command.trigger.WorkaroundMasterFader)1 ContinuousCommand (de.mossgrabers.framework.command.core.ContinuousCommand)1 IHwButton (de.mossgrabers.framework.controller.hardware.IHwButton)1