Search in sources :

Example 1 with IHwRelativeKnob

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

the class MaschineControllerSetup method registerContinuousCommands.

/**
 * {@inheritDoc}
 */
@Override
protected void registerContinuousCommands() {
    final MaschineControlSurface surface = this.getSurface();
    final ModeManager modeManager = surface.getModeManager();
    final ViewManager viewManager = surface.getViewManager();
    final IHwRelativeKnob knob = this.addRelativeKnob(ContinuousID.MASTER_KNOB, "Encoder", new MainKnobRowModeCommand(this.model, surface), MaschineControlSurface.ENCODER);
    knob.bindTouch((event, velocity) -> {
        final IMode mode = modeManager.getActive();
        if (mode != null && event != ButtonEvent.LONG)
            mode.onKnobTouch(8, event == ButtonEvent.DOWN);
    }, surface.getMidiInput(), BindType.CC, 0, MaschineControlSurface.ENCODER_TOUCH);
    if (this.maschine.hasMCUDisplay()) {
        for (int i = 0; i < 8; i++) {
            final int index = i;
            final IHwRelativeKnob modeKnob = this.addRelativeKnob(ContinuousID.get(ContinuousID.KNOB1, i), "Knob " + (i + 1), new KnobRowModeCommand<>(i, this.model, surface), MaschineControlSurface.MODE_KNOB_1 + i);
            modeKnob.bindTouch((event, velocity) -> {
                final IMode mode = modeManager.getActive();
                if (mode != null && event != ButtonEvent.LONG)
                    mode.onKnobTouch(index, event == ButtonEvent.DOWN);
            }, surface.getMidiInput(), BindType.CC, 0, MaschineControlSurface.MODE_KNOB_TOUCH_1 + i);
            modeKnob.setIndexInGroup(i);
        }
    }
    final TouchstripCommand touchstripCommand = new TouchstripCommand(this.model, surface);
    this.addFader(ContinuousID.CROSSFADER, "Touchstrip", touchstripCommand, BindType.CC, MaschineControlSurface.TOUCHSTRIP, false);
    surface.getContinuous(ContinuousID.CROSSFADER).bindTouch(touchstripCommand, surface.getMidiInput(), BindType.CC, 0, MaschineControlSurface.TOUCHSTRIP_TOUCH);
    // Enable aftertouch
    final Views[] views = { Views.PLAY, Views.DRUM };
    for (final Views viewID : views) {
        final IView view = viewManager.get(viewID);
        view.registerAftertouchCommand(new AftertouchViewCommand<>(view, this.model, surface));
    }
    if (this.maschine == Maschine.STUDIO) {
        final IHwAbsoluteKnob masterKnob = this.addAbsoluteKnob(ContinuousID.MONITOR_KNOB, "Encoder", null, MaschineControlSurface.MONITOR_ENCODER);
        this.encoderManager = new StudioEncoderModeManager(masterKnob, this.model, surface);
        masterKnob.bind(this.encoderManager);
        final MaschineMonitorEncoderCommand<MaschineControlSurface, MaschineConfiguration> encoderCommandMaster = new MaschineMonitorEncoderCommand<>(this.encoderManager, EncoderMode.MASTER_VOLUME, this.model, surface);
        this.addButton(ButtonID.ROW4_1, "MST", encoderCommandMaster, MaschineControlSurface.MONITOR_MST, encoderCommandMaster::isLit);
        final MaschineMonitorEncoderCommand<MaschineControlSurface, MaschineConfiguration> encoderCommandSelectedTrack = new MaschineMonitorEncoderCommand<>(this.encoderManager, EncoderMode.SELECTED_TRACK_VOLUME, this.model, surface);
        this.addButton(ButtonID.ROW4_2, "GRP", encoderCommandSelectedTrack, MaschineControlSurface.MONITOR_GRP, encoderCommandSelectedTrack::isLit);
        final MaschineMonitorEncoderCommand<MaschineControlSurface, MaschineConfiguration> encoderCommandMetronome = new MaschineMonitorEncoderCommand<>(this.encoderManager, EncoderMode.METRONOME_VOLUME, this.model, surface);
        this.addButton(ButtonID.ROW4_3, "SND", encoderCommandMetronome, MaschineControlSurface.MONITOR_SND, encoderCommandMetronome::isLit);
        final MaschineMonitorEncoderCommand<MaschineControlSurface, MaschineConfiguration> encoderCommandCue = new MaschineMonitorEncoderCommand<>(this.encoderManager, EncoderMode.CUE_VOLUME, this.model, surface);
        this.addButton(ButtonID.ROW4_4, "CUE", encoderCommandCue, MaschineControlSurface.MONITOR_CUE, encoderCommandCue::isLit);
        final MaschineMonitorEncoderCommand<MaschineControlSurface, MaschineConfiguration> encoderCommandMasterPan = new MaschineMonitorEncoderCommand<>(this.encoderManager, EncoderMode.MASTER_PANORAMA, this.model, surface);
        this.addButton(ButtonID.ROW4_5, "IN1", encoderCommandMasterPan, MaschineControlSurface.MONITOR_IN1, encoderCommandMasterPan::isLit);
        final MaschineMonitorEncoderCommand<MaschineControlSurface, MaschineConfiguration> encoderCommandSelectedTrackPan = new MaschineMonitorEncoderCommand<>(this.encoderManager, EncoderMode.SELECTED_TRACK_PANORAMA, this.model, surface);
        this.addButton(ButtonID.ROW4_6, "IN2", encoderCommandSelectedTrackPan, MaschineControlSurface.MONITOR_IN2, encoderCommandSelectedTrackPan::isLit);
        final MaschineMonitorEncoderCommand<MaschineControlSurface, MaschineConfiguration> encoderCommandCueMix = new MaschineMonitorEncoderCommand<>(this.encoderManager, EncoderMode.CUE_MIX, this.model, surface);
        this.addButton(ButtonID.ROW4_8, "IN4", encoderCommandCueMix, MaschineControlSurface.MONITOR_IN4, encoderCommandCueMix::isLit);
        this.addButton(ButtonID.TOGGLE_VU, "IN3", (event, value) -> {
            if (event == ButtonEvent.UP)
                this.encoderManager.toggleMode();
        }, MaschineControlSurface.MONITOR_IN3, this.encoderManager::isParameterMode);
        // Activate the default mode
        this.encoderManager.setActiveEncoderMode(EncoderMode.MASTER_VOLUME);
    }
}
Also used : MainKnobRowModeCommand(de.mossgrabers.controller.ni.maschine.mk3.command.continuous.MainKnobRowModeCommand) ViewManager(de.mossgrabers.framework.featuregroup.ViewManager) MaschineControlSurface(de.mossgrabers.controller.ni.maschine.mk3.controller.MaschineControlSurface) IHwRelativeKnob(de.mossgrabers.framework.controller.hardware.IHwRelativeKnob) ModeManager(de.mossgrabers.framework.featuregroup.ModeManager) StudioEncoderModeManager(de.mossgrabers.controller.ni.maschine.mk3.controller.StudioEncoderModeManager) MaschineMonitorEncoderCommand(de.mossgrabers.controller.ni.maschine.core.command.trigger.MaschineMonitorEncoderCommand) Views(de.mossgrabers.framework.view.Views) IView(de.mossgrabers.framework.featuregroup.IView) IMode(de.mossgrabers.framework.featuregroup.IMode) TouchstripCommand(de.mossgrabers.controller.ni.maschine.mk3.command.continuous.TouchstripCommand) IHwAbsoluteKnob(de.mossgrabers.framework.controller.hardware.IHwAbsoluteKnob) StudioEncoderModeManager(de.mossgrabers.controller.ni.maschine.mk3.controller.StudioEncoderModeManager)

Example 2 with IHwRelativeKnob

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

the class KontrolProtocolControllerSetup method registerContinuousCommands.

/**
 * {@inheritDoc}
 */
@Override
protected void registerContinuousCommands() {
    final KontrolProtocolControlSurface surface = this.getSurface();
    this.addFader(ContinuousID.HELLO, "Hello", surface::handshakeSuccess, BindType.CC, 15, KontrolProtocolControlSurface.CMD_HELLO);
    this.addButton(surface, ButtonID.BANK_LEFT, "Left", (event, velocity) -> this.moveTrackBank(event, true), 15, KontrolProtocolControlSurface.KONTROL_NAVIGATE_BANKS, 127, () -> this.getKnobValue(KontrolProtocolControlSurface.KONTROL_NAVIGATE_BANKS));
    this.addButton(surface, ButtonID.BANK_RIGHT, "Right", (event, velocity) -> this.moveTrackBank(event, false), 15, KontrolProtocolControlSurface.KONTROL_NAVIGATE_BANKS, 1, () -> this.getKnobValue(KontrolProtocolControlSurface.KONTROL_NAVIGATE_BANKS));
    this.addButton(surface, ButtonID.MOVE_TRACK_LEFT, "Enc Left", (event, velocity) -> this.moveTrack(event, true), 15, KontrolProtocolControlSurface.KONTROL_NAVIGATE_TRACKS, 127, () -> this.getKnobValue(KontrolProtocolControlSurface.KONTROL_NAVIGATE_TRACKS));
    this.addButton(surface, ButtonID.MOVE_TRACK_RIGHT, "Enc Right", (event, velocity) -> this.moveTrack(event, false), 15, KontrolProtocolControlSurface.KONTROL_NAVIGATE_TRACKS, 1, () -> this.getKnobValue(KontrolProtocolControlSurface.KONTROL_NAVIGATE_TRACKS));
    this.addButton(surface, ButtonID.ARROW_UP, "Enc Up", (event, velocity) -> this.moveClips(event, true), 15, KontrolProtocolControlSurface.KONTROL_NAVIGATE_CLIPS, 127, () -> this.getKnobValue(KontrolProtocolControlSurface.KONTROL_NAVIGATE_CLIPS));
    this.addButton(surface, ButtonID.ARROW_DOWN, "Enc Down", (event, velocity) -> this.moveClips(event, false), 15, KontrolProtocolControlSurface.KONTROL_NAVIGATE_CLIPS, 1, () -> this.getKnobValue(KontrolProtocolControlSurface.KONTROL_NAVIGATE_CLIPS));
    this.addRelativeKnob(ContinuousID.MOVE_TRANSPORT, "Move Transport", value -> this.changeTransportPosition(value, 0), BindType.CC, 15, KontrolProtocolControlSurface.KONTROL_NAVIGATE_MOVE_TRANSPORT);
    this.addRelativeKnob(ContinuousID.MOVE_LOOP, "Move Loop", this::changeLoopPosition, BindType.CC, 15, KontrolProtocolControlSurface.KONTROL_NAVIGATE_MOVE_LOOP);
    // Only on S models
    this.addRelativeKnob(ContinuousID.NAVIGATE_VOLUME, "Navigate Volume", value -> this.changeTransportPosition(value, 1), BindType.CC, 15, KontrolProtocolControlSurface.KONTROL_CHANGE_SELECTED_TRACK_VOLUME);
    this.addRelativeKnob(ContinuousID.NAVIGATE_PAN, "Navigate Pan", value -> this.changeTransportPosition(value, 2), BindType.CC, 15, KontrolProtocolControlSurface.KONTROL_CHANGE_SELECTED_TRACK_PAN);
    for (int i = 0; i < 8; i++) {
        final int knobMidi1 = KontrolProtocolControlSurface.KONTROL_TRACK_VOLUME + i;
        final IHwRelativeKnob knob1 = this.addRelativeKnob(ContinuousID.get(ContinuousID.KNOB1, i), "Knob " + (i + 1), null, BindType.CC, 15, knobMidi1);
        knob1.addOutput(() -> this.getKnobValue(knobMidi1), value -> surface.setTrigger(15, knobMidi1, value));
        knob1.setIndexInGroup(i);
        final int knobMidi2 = KontrolProtocolControlSurface.KONTROL_TRACK_PAN + i;
        final IHwRelativeKnob knob2 = this.addRelativeKnob(ContinuousID.get(ContinuousID.FADER1, i), "Fader " + (i + 1), null, BindType.CC, 15, KontrolProtocolControlSurface.KONTROL_TRACK_PAN + i);
        knob2.addOutput(() -> this.getKnobValue(knobMidi2), value -> surface.setTrigger(15, knobMidi2, value));
        knob2.setIndexInGroup(i);
    }
}
Also used : IHwRelativeKnob(de.mossgrabers.framework.controller.hardware.IHwRelativeKnob) KontrolProtocolControlSurface(de.mossgrabers.controller.ni.kontrol.mkii.controller.KontrolProtocolControlSurface)

Example 3 with IHwRelativeKnob

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

the class SLControllerSetup method registerContinuousCommands.

/**
 * {@inheritDoc}
 */
@Override
protected void registerContinuousCommands() {
    final SLControlSurface surface = this.getSurface();
    for (int i = 0; i < 8; i++) {
        final int index = i;
        this.addFader(ContinuousID.get(ContinuousID.FADER1, i), "Fader " + (i + 1), null, BindType.CC, SLControlSurface.MKII_SLIDER1 + i);
        final IHwRelativeKnob relativeKnob = this.addRelativeKnob(ContinuousID.get(ContinuousID.DEVICE_KNOB1, i), "Device Knob " + (i + 1), null, SLControlSurface.MKII_KNOB_ROW1_1 + i, RelativeEncoding.SIGNED_BIT);
        relativeKnob.addOutput(() -> {
            final boolean hasDevice = this.model.hasSelectedDevice();
            final IParameterBank parameterBank = this.model.getCursorDevice().getParameterBank();
            return hasDevice ? parameterBank.getItem(index).getValue() : 0;
        }, value -> surface.getMidiOutput().sendCC(0x70 + index, Math.min(value * 11 / 127, 11)));
        this.addAbsoluteKnob(ContinuousID.get(ContinuousID.KNOB1, i), "Knob " + (i + 1), null, SLControlSurface.MKII_KNOB_ROW2_1 + i);
    }
    this.addFader(ContinuousID.TOUCHPAD_X, "Touchpad X", new TouchpadCommand(true, this.model, surface), BindType.CC, SLControlSurface.MKII_TOUCHPAD_X);
    this.addFader(ContinuousID.TOUCHPAD_Y, "Touchpad Y", new TouchpadCommand(false, this.model, surface), BindType.CC, SLControlSurface.MKII_TOUCHPAD_Y);
    // These are no faders but cannot be mapped to any meaningful control anyway
    this.addFader(ContinuousID.HELLO, "Tap Init", new TapTempoInitMkICommand(this.model, surface), BindType.CC, SLControlSurface.MKI_BUTTON_TAP_TEMPO);
    this.addFader(ContinuousID.TEMPO, "Tap Tempo", new TapTempoMkICommand(this.model, surface), BindType.CC, SLControlSurface.MKI_BUTTON_TAP_TEMPO_VALUE);
    // Volume, Track and Parameter modes are always bound since they have dedicated controls
    final ModeManager modeManager = surface.getModeManager();
    modeManager.get(Modes.VOLUME).onActivate();
    modeManager.get(Modes.TRACK).onActivate();
    modeManager.get(Modes.DEVICE_PARAMS).onActivate();
}
Also used : IHwRelativeKnob(de.mossgrabers.framework.controller.hardware.IHwRelativeKnob) TapTempoMkICommand(de.mossgrabers.controller.novation.sl.command.continuous.TapTempoMkICommand) TapTempoInitMkICommand(de.mossgrabers.controller.novation.sl.command.continuous.TapTempoInitMkICommand) SLControlSurface(de.mossgrabers.controller.novation.sl.controller.SLControlSurface) IParameterBank(de.mossgrabers.framework.daw.data.bank.IParameterBank) TouchpadCommand(de.mossgrabers.controller.novation.sl.command.continuous.TouchpadCommand) ModeManager(de.mossgrabers.framework.featuregroup.ModeManager)

Example 4 with IHwRelativeKnob

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

the class Kontrol1ControllerSetup method registerContinuousCommands.

/**
 * {@inheritDoc}
 */
@Override
protected void registerContinuousCommands() {
    final Kontrol1ControlSurface surface = this.getSurface();
    final IMidiInput input = surface.getMidiInput();
    for (int i = 0; i < 8; i++) {
        final IHwRelativeKnob knob = this.addRelativeKnob(ContinuousID.get(ContinuousID.KNOB1, i), "Knob " + (i + 1), new KnobRowModeCommand<>(i, this.model, surface), Kontrol1ControlSurface.ENCODER_1 + i);
        knob.bindTouch(new KnobRowTouchModeCommand<>(i, this.model, surface), input, BindType.CC, 0, Kontrol1ControlSurface.TOUCH_ENCODER_1 + i);
        knob.setIndexInGroup(i);
    }
    this.addRelativeKnob(ContinuousID.MASTER_KNOB, "Master", new MainEncoderCommand(this.model, surface), Kontrol1ControlSurface.MAIN_ENCODER);
    surface.addPianoKeyboard(25, input, true);
}
Also used : IHwRelativeKnob(de.mossgrabers.framework.controller.hardware.IHwRelativeKnob) Kontrol1ControlSurface(de.mossgrabers.controller.ni.kontrol.mki.controller.Kontrol1ControlSurface) IMidiInput(de.mossgrabers.framework.daw.midi.IMidiInput) MainEncoderCommand(de.mossgrabers.controller.ni.kontrol.mki.command.continuous.MainEncoderCommand)

Example 5 with IHwRelativeKnob

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

the class AbstractControllerSetup method addRelativeKnob.

/**
 * Create a hardware knob proxy on a controller, which sends relative values, bind a continuous
 * command to it and bind it to a MIDI CC on MIDI channel 1.
 *
 * @param surface The control surface
 * @param continuousID The ID of the control (for later access)
 * @param label The label of the fader
 * @param command The command to bind
 * @param bindType The MIDI bind type
 * @param midiChannel The MIDI channel
 * @param midiControl The MIDI CC or note
 * @param encoding The relative value encoding
 * @return The created knob
 */
protected IHwRelativeKnob addRelativeKnob(final S surface, final ContinuousID continuousID, final String label, final ContinuousCommand command, final BindType bindType, final int midiChannel, final int midiControl, final RelativeEncoding encoding) {
    final IHwRelativeKnob knob = surface.createRelativeKnob(continuousID, label, encoding);
    knob.bind(command);
    knob.bind(surface.getMidiInput(), bindType, midiChannel, midiControl);
    return knob;
}
Also used : IHwRelativeKnob(de.mossgrabers.framework.controller.hardware.IHwRelativeKnob)

Aggregations

IHwRelativeKnob (de.mossgrabers.framework.controller.hardware.IHwRelativeKnob)5 ModeManager (de.mossgrabers.framework.featuregroup.ModeManager)2 MainEncoderCommand (de.mossgrabers.controller.ni.kontrol.mki.command.continuous.MainEncoderCommand)1 Kontrol1ControlSurface (de.mossgrabers.controller.ni.kontrol.mki.controller.Kontrol1ControlSurface)1 KontrolProtocolControlSurface (de.mossgrabers.controller.ni.kontrol.mkii.controller.KontrolProtocolControlSurface)1 MaschineMonitorEncoderCommand (de.mossgrabers.controller.ni.maschine.core.command.trigger.MaschineMonitorEncoderCommand)1 MainKnobRowModeCommand (de.mossgrabers.controller.ni.maschine.mk3.command.continuous.MainKnobRowModeCommand)1 TouchstripCommand (de.mossgrabers.controller.ni.maschine.mk3.command.continuous.TouchstripCommand)1 MaschineControlSurface (de.mossgrabers.controller.ni.maschine.mk3.controller.MaschineControlSurface)1 StudioEncoderModeManager (de.mossgrabers.controller.ni.maschine.mk3.controller.StudioEncoderModeManager)1 TapTempoInitMkICommand (de.mossgrabers.controller.novation.sl.command.continuous.TapTempoInitMkICommand)1 TapTempoMkICommand (de.mossgrabers.controller.novation.sl.command.continuous.TapTempoMkICommand)1 TouchpadCommand (de.mossgrabers.controller.novation.sl.command.continuous.TouchpadCommand)1 SLControlSurface (de.mossgrabers.controller.novation.sl.controller.SLControlSurface)1 IHwAbsoluteKnob (de.mossgrabers.framework.controller.hardware.IHwAbsoluteKnob)1 IParameterBank (de.mossgrabers.framework.daw.data.bank.IParameterBank)1 IMidiInput (de.mossgrabers.framework.daw.midi.IMidiInput)1 IMode (de.mossgrabers.framework.featuregroup.IMode)1 IView (de.mossgrabers.framework.featuregroup.IView)1 ViewManager (de.mossgrabers.framework.featuregroup.ViewManager)1