use of de.mossgrabers.framework.command.core.TriggerCommand in project DrivenByMoss by git-moss.
the class AbstractControllerSetup method test.
/**
* {@inheritDoc}
*/
@Override
public void test(final TestCallback callback) {
final TestFramework framework = new TestFramework(this.host);
this.getSurfaces().forEach(surface -> {
framework.scheduleFunction(() -> this.host.println("Testing controller: " + this.getClass().getName()));
final ViewManager viewManager = surface.getViewManager();
final ModeManager modeManager = surface.getModeManager();
final int max = this.model.getValueChanger().getUpperBound() - 1;
for (final Views viewID : Views.values()) {
if (viewManager.get(viewID) == null)
continue;
for (final Modes modeID : Modes.values()) {
if (modeManager.get(modeID) == null)
continue;
framework.scheduleFunction(() -> {
this.host.println("- View " + viewID + " Mode " + modeID);
viewManager.setActive(viewID);
modeManager.setActive(modeID);
for (final ButtonID buttonID : ButtonID.values()) {
final IHwButton button = surface.getButton(buttonID);
if (button == null)
continue;
button.trigger(ButtonEvent.DOWN);
button.trigger(ButtonEvent.LONG);
button.trigger(ButtonEvent.UP);
}
for (final ContinuousID continuousID : ContinuousID.values()) {
final IHwContinuousControl continuous = surface.getContinuous(continuousID);
if (continuous == null)
continue;
final TriggerCommand touchCommand = continuous.getTouchCommand();
if (touchCommand != null) {
touchCommand.execute(ButtonEvent.DOWN, 127);
touchCommand.execute(ButtonEvent.LONG, 127);
touchCommand.execute(ButtonEvent.UP, 0);
}
final ContinuousCommand command = continuous.getCommand();
if (command != null) {
command.execute(0);
command.execute(max);
command.execute(max / 2);
}
final PitchbendCommand pitchbendCommand = continuous.getPitchbendCommand();
if (pitchbendCommand != null) {
pitchbendCommand.onPitchbend(0, 0);
pitchbendCommand.onPitchbend(0, 127);
pitchbendCommand.onPitchbend(0, 64);
}
}
});
}
}
});
callback.startTesting();
framework.executeScheduler(callback);
}
use of de.mossgrabers.framework.command.core.TriggerCommand 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);
}
Aggregations