use of de.mossgrabers.push.controller.PushControlSurface in project DrivenByMoss by git-moss.
the class PushControllerSetup method handleTrackChange.
/**
* Handle a track selection change.
*
* @param index The index of the track
* @param isSelected Has the track been selected?
*/
private void handleTrackChange(final int index, final boolean isSelected) {
if (!isSelected)
return;
final PushControlSurface surface = this.getSurface();
final ViewManager viewManager = surface.getViewManager();
final ModeManager modeManager = surface.getModeManager();
// Recall last used view (if we are not in session mode)
if (!viewManager.isActiveView(Views.VIEW_SESSION)) {
final ITrack selectedTrack = this.model.getCurrentTrackBank().getSelectedTrack();
if (selectedTrack != null) {
final Integer preferredView = viewManager.getPreferredView(selectedTrack.getPosition());
viewManager.setActiveView(preferredView == null ? this.configuration.getDefaultNoteView() : preferredView);
}
}
if (modeManager.isActiveMode(Modes.MODE_MASTER))
modeManager.setActiveMode(Modes.MODE_TRACK);
if (viewManager.isActiveView(Views.VIEW_PLAY))
viewManager.getActiveView().updateNoteMapping();
// Reset drum octave because the drum pad bank is also reset
this.scales.setDrumOctave(0);
if (viewManager.isActiveView(Views.VIEW_DRUM))
viewManager.getView(Views.VIEW_DRUM).updateNoteMapping();
}
use of de.mossgrabers.push.controller.PushControlSurface in project DrivenByMoss by git-moss.
the class PushControllerSetup method updateRibbonMode.
private void updateRibbonMode() {
final PushControlSurface surface = this.getSurface();
surface.setRibbonValue(0);
switch(this.configuration.getRibbonMode()) {
case PushConfiguration.RIBBON_MODE_CC:
case PushConfiguration.RIBBON_MODE_FADER:
surface.setRibbonMode(PushControlSurface.PUSH_RIBBON_VOLUME);
break;
default:
surface.setRibbonMode(PushControlSurface.PUSH_RIBBON_PITCHBEND);
break;
}
}
use of de.mossgrabers.push.controller.PushControlSurface in project DrivenByMoss by git-moss.
the class PushControllerSetup method startup.
/**
* {@inheritDoc}
*/
@Override
public void startup() {
final PushControlSurface surface = this.getSurface();
surface.getViewManager().setActiveView(this.configuration.getDefaultNoteView());
surface.sendPressureMode(true);
surface.getOutput().sendIdentityRequest();
}
use of de.mossgrabers.push.controller.PushControlSurface in project DrivenByMoss by git-moss.
the class PushControllerSetup method createObservers.
/**
* {@inheritDoc}
*/
@Override
protected void createObservers() {
final PushControlSurface surface = this.getSurface();
if (this.configuration.isPush2()) {
this.configuration.addSettingObserver(PushConfiguration.DISPLAY_BRIGHTNESS, surface::sendDisplayBrightness);
this.configuration.addSettingObserver(PushConfiguration.LED_BRIGHTNESS, surface::sendLEDBrightness);
this.configuration.addSettingObserver(PushConfiguration.PAD_SENSITIVITY, () -> {
surface.sendPadVelocityCurve();
surface.sendPadThreshold();
});
this.configuration.addSettingObserver(PushConfiguration.PAD_GAIN, () -> {
surface.sendPadVelocityCurve();
surface.sendPadThreshold();
});
this.configuration.addSettingObserver(PushConfiguration.PAD_DYNAMICS, () -> {
surface.sendPadVelocityCurve();
surface.sendPadThreshold();
});
} else {
this.configuration.addSettingObserver(PushConfiguration.VELOCITY_CURVE, surface::sendPadSensitivity);
this.configuration.addSettingObserver(PushConfiguration.PAD_THRESHOLD, surface::sendPadSensitivity);
}
surface.getModeManager().addModeListener((oldMode, newMode) -> {
this.updateMode(null);
this.updateMode(newMode);
});
surface.getViewManager().addViewChangeListener((previousViewId, activeViewId) -> {
// Update button states
final View view = surface.getViewManager().getActiveView();
for (final int button : surface.getButtons()) {
if (surface.shouldUpdateButton(button))
surface.setButton(button, view.usesButton(button) ? ColorManager.BUTTON_STATE_ON : ColorManager.BUTTON_STATE_OFF);
}
// Update ribbon mode
if (Views.VIEW_SESSION.equals(activeViewId))
surface.setRibbonMode(PushControlSurface.PUSH_RIBBON_PAN);
else
this.updateRibbonMode();
});
this.configuration.addSettingObserver(PushConfiguration.RIBBON_MODE, this::updateRibbonMode);
this.configuration.addSettingObserver(PushConfiguration.SEND_PORT, () -> ((PushDisplay) surface.getDisplay()).setCommunicationPort(this.configuration.getSendPort()));
this.configuration.addSettingObserver(PushConfiguration.DEBUG_MODE, () -> {
final ModeManager modeManager = surface.getModeManager();
final Integer debugMode = this.configuration.getDebugMode();
if (modeManager.getMode(debugMode) != null)
modeManager.setActiveMode(debugMode);
else
this.host.error("Mode " + debugMode + " not registered.");
});
this.createScaleObservers(this.configuration);
}
use of de.mossgrabers.push.controller.PushControlSurface in project DrivenByMoss by git-moss.
the class PushControllerSetup method updateIndication.
private void updateIndication(final Integer mode) {
final ITrackBank tb = this.model.getTrackBank();
final IChannelBank tbe = this.model.getEffectTrackBank();
final PushControlSurface surface = this.getSurface();
final boolean isSession = surface.getViewManager().isActiveView(Views.VIEW_SESSION);
final boolean isEffect = this.model.isEffectTrackBankActive();
final boolean isPan = Modes.MODE_PAN.equals(mode);
final boolean isVolume = Modes.MODE_VOLUME.equals(mode);
tb.setIndication(!isEffect && isSession);
if (tbe != null)
tbe.setIndication(isEffect && isSession);
final ICursorDevice cursorDevice = this.model.getCursorDevice();
final ITrack selectedTrack = tb.getSelectedTrack();
for (int i = 0; i < tb.getNumTracks(); i++) {
final boolean hasTrackSel = selectedTrack != null && selectedTrack.getIndex() == i && Modes.MODE_TRACK.equals(mode);
final ITrack track = tb.getTrack(i);
track.setVolumeIndication(!isEffect && (isVolume || hasTrackSel));
track.setPanIndication(!isEffect && (isPan || hasTrackSel));
for (int j = 0; j < tb.getNumSends(); j++) track.getSend(j).setIndication(!isEffect && (mode.intValue() - Modes.MODE_SEND1.intValue() == j || hasTrackSel));
if (tbe != null) {
final ITrack fxTrack = tbe.getTrack(i);
fxTrack.setVolumeIndication(isEffect);
fxTrack.setPanIndication(isEffect && isPan);
}
cursorDevice.indicateParameter(i, true);
}
}
Aggregations