use of de.mossgrabers.framework.mode.ModeManager in project DrivenByMoss by git-moss.
the class SessionView method onGridNote.
/**
* {@inheritDoc}
*/
@Override
public void onGridNote(final int note, final int velocity) {
if (velocity == 0) {
final TriggerCommand triggerCommand = this.surface.getViewManager().getView(Views.VIEW_SESSION).getTriggerCommand(Commands.COMMAND_SELECT_SESSION_VIEW);
((SelectSessionViewCommand) triggerCommand).setTemporary();
return;
}
final int index = note - 36;
int t = index % this.columns;
int s = this.rows - 1 - index / this.columns;
final boolean flipSession = this.surface.getConfiguration().isFlipSession();
if (flipSession) {
final int dummy = t;
t = s;
s = dummy;
}
final IChannelBank tb = this.model.getCurrentTrackBank();
// Birds-eye-view navigation
if (this.surface.isShiftPressed()) {
// Calculate page offsets
final int numTracks = tb.getNumTracks();
final int numScenes = tb.getNumScenes();
final int trackPosition = tb.getTrack(0).getPosition() / numTracks;
final int scenePosition = tb.getScenePosition() / numScenes;
final int selX = flipSession ? scenePosition : trackPosition;
final int selY = flipSession ? trackPosition : scenePosition;
final int padsX = flipSession ? this.rows : this.columns;
final int padsY = flipSession ? this.columns : this.rows;
final int offsetX = selX / padsX * padsX;
final int offsetY = selY / padsY * padsY;
tb.scrollToChannel(offsetX * numTracks + t * padsX);
tb.scrollToScene(offsetY * numScenes + s * padsY);
return;
}
// Duplicate a clip
final ITrack track = tb.getTrack(t);
if (this.surface.isPressed(PushControlSurface.PUSH_BUTTON_DUPLICATE)) {
this.surface.setButtonConsumed(PushControlSurface.PUSH_BUTTON_DUPLICATE);
if (track.doesExist())
track.getSlot(s).duplicate();
return;
}
// Stop clip
if (this.surface.isPressed(PushControlSurface.PUSH_BUTTON_CLIP_STOP)) {
this.surface.setButtonConsumed(PushControlSurface.PUSH_BUTTON_CLIP_STOP);
track.stop();
return;
}
// Browse for clips
if (this.surface.isPressed(PushControlSurface.PUSH_BUTTON_BROWSE)) {
this.surface.setButtonConsumed(PushControlSurface.PUSH_BUTTON_BROWSE);
if (!track.doesExist())
return;
track.getSlot(s).browse();
final ModeManager modeManager = this.surface.getModeManager();
if (!modeManager.isActiveMode(Modes.MODE_BROWSER))
modeManager.setActiveMode(Modes.MODE_BROWSER);
return;
}
super.onGridNote(note, velocity);
}
use of de.mossgrabers.framework.mode.ModeManager in project DrivenByMoss by git-moss.
the class SLControllerSetup method createModes.
/**
* {@inheritDoc}
*/
@Override
protected void createModes() {
final SLControlSurface surface = this.getSurface();
final ModeManager modeManager = surface.getModeManager();
modeManager.registerMode(Modes.MODE_FIXED, new FixedMode(surface, this.model));
modeManager.registerMode(Modes.MODE_FRAME, new FrameMode(surface, this.model));
modeManager.registerMode(Modes.MODE_FUNCTIONS, new FunctionMode(surface, this.model));
modeManager.registerMode(Modes.MODE_MASTER, new MasterMode(surface, this.model));
modeManager.registerMode(Modes.MODE_PLAY_OPTIONS, new PlayOptionsMode(surface, this.model));
modeManager.registerMode(Modes.MODE_SESSION, new SessionMode(surface, this.model));
modeManager.registerMode(Modes.MODE_TRACK, new TrackMode(surface, this.model));
modeManager.registerMode(Modes.MODE_TRACK_TOGGLES, new TrackTogglesMode(surface, this.model));
modeManager.registerMode(Modes.MODE_VIEW_SELECT, new ViewSelectMode(surface, this.model));
modeManager.registerMode(Modes.MODE_VOLUME, new VolumeMode(surface, this.model));
modeManager.registerMode(Modes.MODE_PARAMS, new DeviceParamsMode(surface, this.model));
modeManager.registerMode(Modes.MODE_BROWSER, new DevicePresetsMode(surface, this.model));
}
use of de.mossgrabers.framework.mode.ModeManager in project DrivenByMoss by git-moss.
the class ShiftCommand method execute.
/**
* {@inheritDoc}
*/
@Override
public void execute(final ButtonEvent event) {
final boolean isUp = event == ButtonEvent.UP;
this.surface.updateButton(PushControlSurface.PUSH_BUTTON_SHIFT, isUp ? ColorManager.BUTTON_STATE_ON : ColorManager.BUTTON_STATE_HI);
final ModeManager modeManager = this.surface.getModeManager();
final Integer cm = modeManager.getActiveModeId();
if (event == ButtonEvent.DOWN && Modes.MODE_SCALES.equals(cm))
modeManager.setActiveMode(Modes.MODE_SCALE_LAYOUT);
else if (isUp && Modes.MODE_SCALE_LAYOUT.equals(cm))
modeManager.restoreMode();
this.model.getValueChanger().setSpeed(this.surface.isShiftPressed());
}
use of de.mossgrabers.framework.mode.ModeManager in project DrivenByMoss by git-moss.
the class TrackCommand method execute.
/**
* {@inheritDoc}
*/
@Override
public void execute(final ButtonEvent event) {
if (event != ButtonEvent.DOWN)
return;
final PushConfiguration config = this.surface.getConfiguration();
if (this.surface.isShiftPressed()) {
config.setVUMetersEnabled(!config.isEnableVUMeters());
return;
}
final ModeManager modeManager = this.surface.getModeManager();
final Integer currentMode = modeManager.getActiveModeId();
if (currentMode != null) {
if (config.isPush2()) {
if (Modes.MODE_TRACK.equals(currentMode) || Modes.MODE_VOLUME.equals(currentMode) || Modes.MODE_CROSSFADER.equals(currentMode) || Modes.MODE_PAN.equals(currentMode)) {
this.model.toggleCurrentTrackBank();
} else if (currentMode.intValue() >= Modes.MODE_SEND1.intValue() && currentMode.intValue() <= Modes.MODE_SEND8.intValue()) {
modeManager.setActiveMode(Modes.MODE_TRACK);
this.model.toggleCurrentTrackBank();
} else
modeManager.setActiveMode(config.getCurrentMixMode());
} else {
// Layer mode selection for Push 1
if (this.surface.isSelectPressed() && Modes.isLayerMode(currentMode)) {
modeManager.setActiveMode(Modes.MODE_DEVICE_LAYER);
return;
}
if (currentMode == Modes.MODE_TRACK)
this.model.toggleCurrentTrackBank();
else
modeManager.setActiveMode(Modes.MODE_TRACK);
}
} else
modeManager.setActiveMode(Modes.MODE_TRACK);
config.setDebugMode(modeManager.getActiveModeId());
final IChannelBank tb = this.model.getCurrentTrackBank();
final ITrack track = tb.getSelectedTrack();
if (track == null)
tb.getTrack(0).select();
}
use of de.mossgrabers.framework.mode.ModeManager in project DrivenByMoss by git-moss.
the class FaderCommand method execute.
/**
* {@inheritDoc}
*/
@Override
public void execute(final int value) {
final IMasterTrack masterTrack = this.model.getMasterTrack();
if (masterTrack.isSelected()) {
if (this.index == 0)
masterTrack.setVolume(value);
} else
this.model.getCurrentTrackBank().getTrack(this.index).setVolume(value);
final ModeManager modeManager = this.surface.getModeManager();
if (!modeManager.isActiveMode(Modes.MODE_VOLUME))
modeManager.setActiveMode(Modes.MODE_VOLUME);
}
Aggregations