use of de.mossgrabers.framework.featuregroup.IMode 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);
}
}
use of de.mossgrabers.framework.featuregroup.IMode in project DrivenByMoss by git-moss.
the class MaschineControllerSetup method getEncoderColor.
private int getEncoderColor(final ButtonID arrowButton) {
final MaschineControlSurface surface = this.getSurface();
final ModeManager modeManager = surface.getModeManager();
final Modes modeID = modeManager.getActiveID();
if (modeID == null)
return MaschineColorManager.COLOR_BLACK;
final IMode mode = modeManager.getActive();
boolean isOn;
switch(arrowButton) {
case ARROW_LEFT:
isOn = mode.hasPreviousItem();
break;
case ARROW_RIGHT:
isOn = mode.hasNextItem();
break;
case ARROW_UP:
isOn = mode.hasNextItemPage();
break;
case ARROW_DOWN:
isOn = mode.hasPreviousItemPage();
break;
// Never reached
default:
return MaschineColorManager.COLOR_BLACK;
}
if (!isOn)
return MaschineColorManager.COLOR_BLACK;
switch(modeID) {
case VOLUME:
return surface.isPressed(arrowButton) ? MaschineColorManager.COLOR_BLUE : MaschineColorManager.COLOR_BLUE_LO;
case PAN:
return surface.isPressed(arrowButton) ? MaschineColorManager.COLOR_SKY : MaschineColorManager.COLOR_SKY_LO;
case SEND1:
case SEND2:
case SEND3:
case SEND4:
case SEND5:
case SEND6:
case SEND7:
case SEND8:
return surface.isPressed(arrowButton) ? MaschineColorManager.COLOR_WHITE : MaschineColorManager.COLOR_YELLOW;
case DEVICE_PARAMS:
case USER:
return surface.isPressed(arrowButton) ? MaschineColorManager.COLOR_PINK : MaschineColorManager.COLOR_PINK_LO;
case BROWSER:
return surface.isPressed(arrowButton) ? MaschineColorManager.COLOR_AMBER : MaschineColorManager.COLOR_AMBER_LO;
case NOTE:
return surface.isPressed(arrowButton) ? MaschineColorManager.COLOR_GREEN : MaschineColorManager.COLOR_GREEN_LO;
default:
return MaschineColorManager.COLOR_BLACK;
}
}
use of de.mossgrabers.framework.featuregroup.IMode in project DrivenByMoss by git-moss.
the class AssignableCommand method execute.
/**
* {@inheritDoc}
*/
@Override
public void execute(final ButtonEvent event, final int velocity) {
final MCUConfiguration configuration = this.surface.getConfiguration();
switch(this.getSetting()) {
case MCUConfiguration.FOOTSWITCH_2_PREV_MODE:
if (event == ButtonEvent.DOWN)
this.switcher.scrollDown();
break;
case MCUConfiguration.FOOTSWITCH_2_NEXT_MODE:
if (event == ButtonEvent.DOWN)
this.switcher.scrollUp();
break;
case MCUConfiguration.FOOTSWITCH_2_SHOW_MARKER_MODE:
if (event != ButtonEvent.DOWN)
return;
final ModeManager modeManager = this.surface.getModeManager();
if (modeManager.isActive(Modes.MARKERS))
modeManager.restore();
else
modeManager.setActive(Modes.MARKERS);
final IMode mode = modeManager.getActive();
if (mode != null)
this.surface.getDisplay().notify(mode.getName());
break;
case MCUConfiguration.FOOTSWITCH_2_USE_FADERS_LIKE_EDIT_KNOBS:
this.flipCommand.executeNormal(event);
break;
case MCUConfiguration.FOOTSWITCH_2_TOGGLE_MOTOR_FADERS_ON_OFF:
if (event != ButtonEvent.DOWN)
return;
configuration.toggleMotorFaders();
this.mvHelper.delayDisplay(() -> "Motor Faders: " + (configuration.hasMotorFaders() ? "On" : "Off"));
break;
case MCUConfiguration.FOOTSWITCH_2_ACTION:
if (event != ButtonEvent.DOWN)
return;
final String assignableActionID = configuration.getAssignableAction(this.index);
if (assignableActionID != null)
this.model.getApplication().invokeAction(assignableActionID);
break;
default:
super.execute(event, velocity);
break;
}
}
use of de.mossgrabers.framework.featuregroup.IMode in project DrivenByMoss by git-moss.
the class CursorCommand method updateArrowStates.
/**
* {@inheritDoc}
*/
@Override
protected void updateArrowStates() {
final ISceneBank sceneBank = this.getSceneBank();
this.canScrollUp = sceneBank.canScrollBackwards();
this.canScrollDown = sceneBank.canScrollForwards();
final IMode mode = this.surface.getModeManager().getActive();
final boolean shiftPressed = this.surface.isShiftPressed();
this.canScrollLeft = mode != null && (shiftPressed ? mode.hasPreviousItemPage() : mode.hasPreviousItem());
this.canScrollRight = mode != null && (shiftPressed ? mode.hasNextItemPage() : mode.hasNextItem());
}
use of de.mossgrabers.framework.featuregroup.IMode in project DrivenByMoss by git-moss.
the class ModeCursorCommand method updateArrowStates.
/**
* Update the states of the arrow buttons. Override to update arrow states.
*/
protected void updateArrowStates() {
final IMode mode = this.surface.getModeManager().getActive();
this.canScrollLeft = mode != null && mode.hasPreviousItem();
this.canScrollRight = mode != null && mode.hasNextItem();
this.canScrollUp = mode != null && mode.hasNextItemPage();
this.canScrollDown = mode != null && mode.hasPreviousItemPage();
}
Aggregations