use of de.mossgrabers.framework.featuregroup.ModeManager in project DrivenByMoss by git-moss.
the class DrumView method handleSelectButton.
/**
* {@inheritDoc}
*/
@Override
public synchronized void handleSelectButton(final int playedPad) {
// Do we have drum pads?
final IDrumDevice primary = this.model.getDrumDevice();
if (!primary.hasDrumPads())
return;
final ICursorDevice cd = this.model.getCursorDevice();
final boolean isNested = cd.isNested();
if (isNested) {
// We have to move up to compare the main drum devices
cd.selectParent();
}
// Can only scroll to the channel if the cursor device is the primary device
if (primary.getPosition() != cd.getPosition())
return;
// Align the primary and cursor device drum bank view
final IDrumPadBank drumPadBank = primary.getDrumPadBank();
final int scrollPos = drumPadBank.getScrollPosition();
final IDrumPadBank cdDrumPadBank = cd.getDrumPadBank();
final int pageSize = cdDrumPadBank.getPageSize();
final int adjustedPage = playedPad / pageSize * pageSize;
cdDrumPadBank.scrollTo(scrollPos + adjustedPage, false);
// Do not reselect
final IDrumPad drumPad = drumPadBank.getItem(playedPad);
if (drumPad.isSelected()) {
// If the instrument of the pad was selected for editing, try to select it again
if (isNested) {
final IDrumPad selectedItem = cdDrumPadBank.getItem(playedPad % pageSize);
if (selectedItem != null)
selectedItem.enter();
}
return;
}
// Only activate layer mode if not one of the layer modes is already active
final ModeManager modeManager = this.surface.getModeManager();
if (!Modes.isLayerMode(modeManager.getActiveID()))
modeManager.setActive(Modes.DEVICE_LAYER);
drumPad.select();
this.updateNoteMapping();
}
use of de.mossgrabers.framework.featuregroup.ModeManager 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.ModeManager 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.ModeManager in project DrivenByMoss by git-moss.
the class TempoCommand method execute.
/**
* {@inheritDoc}
*/
@Override
public void execute(final ButtonEvent event, final int velocity) {
final ModeManager modeManager = this.surface.getModeManager();
// Switch Transpose/Pressure note edit parameters
if (modeManager.isActive(Modes.NOTE) && this.surface.getViewManager().isActive(Views.DRUM, Views.PLAY)) {
if (event == ButtonEvent.DOWN) {
final EditNoteMode mode = (EditNoteMode) modeManager.get(Modes.NOTE);
final boolean isTranspose = mode.getSelectedItem() == EditNoteMode.PITCH;
mode.selectItem(isTranspose ? EditNoteMode.PRESSURE : EditNoteMode.PITCH);
this.surface.getDisplay().notify(isTranspose ? "Pressure" : "Pitch");
}
return;
}
super.execute(event, velocity);
}
use of de.mossgrabers.framework.featuregroup.ModeManager in project DrivenByMoss by git-moss.
the class VolumePanSendCommand method execute.
/**
* {@inheritDoc}
*/
@Override
public void execute(final ButtonEvent event, final int velocity) {
final ModeManager modeManager = this.surface.getModeManager();
// Switch Gain/Velocity note edit parameters
if (modeManager.isActive(Modes.NOTE) && this.surface.getViewManager().isActive(Views.DRUM, Views.PLAY)) {
if (event == ButtonEvent.DOWN) {
final EditNoteMode mode = (EditNoteMode) modeManager.get(Modes.NOTE);
final boolean isVelocity = mode.getSelectedItem() == EditNoteMode.VELOCITY;
mode.selectItem(isVelocity ? EditNoteMode.GAIN : EditNoteMode.VELOCITY);
this.surface.getDisplay().notify(isVelocity ? "Gain" : "Velocity");
}
return;
}
// Toggle VU display
if (this.surface.isShiftPressed()) {
if (event == ButtonEvent.DOWN) {
this.surface.setStopConsumed();
((MaschineVolumeMode) modeManager.get(Modes.VOLUME)).toggleDisplayVU();
}
return;
}
super.execute(event, velocity);
}
Aggregations