use of de.mossgrabers.framework.daw.data.ITrack in project DrivenByMoss by git-moss.
the class MCUControllerSetup method updateVUandFaders.
private void updateVUandFaders() {
final double upperBound = this.valueChanger.getUpperBound();
final boolean enableVUMeters = this.configuration.isEnableVUMeters();
final boolean hasMotorFaders = this.configuration.hasMotorFaders();
final IChannelBank tb = this.model.getCurrentTrackBank();
IMidiOutput output;
for (int index = 0; index < this.numMCUDevices; index++) {
final MCUControlSurface surface = this.getSurface(index);
output = surface.getOutput();
final int extenderOffset = surface.getExtenderOffset();
for (int i = 0; i < 8; i++) {
final int channel = extenderOffset + i;
final ITrack track = tb.getTrack(channel);
// Update VU LEDs of channel
if (enableVUMeters) {
final int vu = track.getVu();
if (vu != this.vuValues[channel]) {
this.vuValues[channel] = vu;
final int scaledValue = (int) Math.round(vu * 12 / upperBound);
output.sendChannelAftertouch(0x10 * i + scaledValue, 0);
}
}
// Update motor fader of channel
if (hasMotorFaders)
this.updateFaders(output, i, channel, track);
}
}
final IMasterTrack masterTrack = this.model.getMasterTrack();
final MCUControlSurface surface = this.getSurface();
output = surface.getOutput();
// Stereo VU of master channel
if (enableVUMeters) {
int vu = masterTrack.getVuLeft();
if (vu != this.masterVuValues[0]) {
this.masterVuValues[0] = vu;
final int scaledValue = (int) Math.round(vu * 12 / upperBound);
output.sendChannelAftertouch(1, scaledValue, 0);
}
vu = masterTrack.getVuRight();
if (vu != this.masterVuValues[1]) {
this.masterVuValues[1] = vu;
final int scaledValue = (int) Math.round(vu * 12 / upperBound);
output.sendChannelAftertouch(1, 0x10 + scaledValue, 0);
}
}
// Update motor fader of master channel
if (hasMotorFaders) {
final int volume = surface.isShiftPressed() ? this.model.getTransport().getMetronomeVolume() : masterTrack.getVolume();
if (volume != this.masterFaderValue) {
this.masterFaderValue = volume;
output.sendPitchbend(8, volume % 127, volume / 127);
}
}
}
use of de.mossgrabers.framework.daw.data.ITrack in project DrivenByMoss by git-moss.
the class MCUControllerSetup method updateIndication.
private void updateIndication(final Integer mode) {
final ITrackBank tb = this.model.getTrackBank();
final IChannelBank tbe = this.model.getEffectTrackBank();
final boolean isEffect = this.model.isEffectTrackBankActive();
final boolean isPan = Modes.MODE_PAN.equals(mode);
final boolean isTrack = Modes.MODE_TRACK.equals(mode);
final boolean isDevice = Modes.MODE_DEVICE_PARAMS.equals(mode);
tb.setIndication(!isEffect);
tbe.setIndication(isEffect);
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 && isTrack;
final ITrack track = tb.getTrack(i);
track.setVolumeIndication(!isEffect && (isTrack || 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));
final ITrack fxTrack = tbe.getTrack(i);
fxTrack.setVolumeIndication(isEffect);
fxTrack.setPanIndication(isEffect && isPan);
}
for (int i = 0; i < cursorDevice.getNumParameters(); i++) cursorDevice.indicateParameter(i, isDevice);
}
use of de.mossgrabers.framework.daw.data.ITrack in project DrivenByMoss by git-moss.
the class LaunchpadControllerSetup 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;
// Recall last used view (if we are not in session mode)
final ViewManager viewManager = this.getSurface().getViewManager();
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 ? Views.VIEW_PLAY : preferredView);
}
}
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.framework.daw.data.ITrack in project DrivenByMoss by git-moss.
the class LaunchpadControllerSetup method updateButtons.
private void updateButtons() {
final LaunchpadControlSurface surface = this.getSurface();
final ViewManager viewManager = surface.getViewManager();
final View activeView = viewManager.getActiveView();
if (activeView != null) {
((LaunchpadCursorCommand) activeView.getTriggerCommand(Commands.COMMAND_ARROW_DOWN)).updateArrows();
((SceneView) activeView).updateSceneButtons();
}
if (!this.isPro) {
surface.setButton(LaunchpadControlSurface.LAUNCHPAD_MKII_BUTTON_USER, surface.isUserPressed() ? LaunchpadColors.LAUNCHPAD_COLOR_WHITE : LaunchpadColors.LAUNCHPAD_COLOR_GREY_LO);
return;
}
surface.setButton(LaunchpadControlSurface.LAUNCHPAD_PRO_BUTTON_USER, LaunchpadColors.LAUNCHPAD_COLOR_BLACK);
final boolean isShift = surface.isShiftPressed();
final ITrack selTrack = this.model.getCurrentTrackBank().getSelectedTrack();
final int index = selTrack == null ? -1 : selTrack.getIndex();
final ModeManager modeManager = surface.getModeManager();
final ITransport transport = this.model.getTransport();
surface.setButton(LaunchpadControlSurface.LAUNCHPAD_BUTTON_SHIFT, isShift ? LaunchpadColors.LAUNCHPAD_COLOR_WHITE : LaunchpadColors.LAUNCHPAD_COLOR_GREY_LO);
surface.setButton(LaunchpadControlSurface.LAUNCHPAD_BUTTON_CLICK, isShift ? LaunchpadColors.LAUNCHPAD_COLOR_GREEN_SPRING : transport.isMetronomeOn() ? LaunchpadColors.LAUNCHPAD_COLOR_GREEN_HI : LaunchpadColors.LAUNCHPAD_COLOR_GREEN_LO);
surface.setButton(LaunchpadControlSurface.LAUNCHPAD_BUTTON_UNDO, isShift ? LaunchpadColors.LAUNCHPAD_COLOR_GREEN_SPRING : LaunchpadColors.LAUNCHPAD_COLOR_GREEN_LO);
surface.setButton(LaunchpadControlSurface.LAUNCHPAD_BUTTON_DELETE, isShift ? LaunchpadColors.LAUNCHPAD_COLOR_BLACK : LaunchpadColors.LAUNCHPAD_COLOR_GREEN_LO);
surface.setButton(LaunchpadControlSurface.LAUNCHPAD_BUTTON_QUANTIZE, isShift ? LaunchpadColors.LAUNCHPAD_COLOR_BLACK : LaunchpadColors.LAUNCHPAD_COLOR_GREEN_LO);
surface.setButton(LaunchpadControlSurface.LAUNCHPAD_BUTTON_DUPLICATE, isShift ? LaunchpadColors.LAUNCHPAD_COLOR_GREEN_SPRING : LaunchpadColors.LAUNCHPAD_COLOR_GREEN_LO);
surface.setButton(LaunchpadControlSurface.LAUNCHPAD_BUTTON_DOUBLE, isShift ? LaunchpadColors.LAUNCHPAD_COLOR_GREEN_SPRING : LaunchpadColors.LAUNCHPAD_COLOR_GREEN_LO);
final boolean flipRecord = surface.getConfiguration().isFlipRecord();
surface.setButton(LaunchpadControlSurface.LAUNCHPAD_BUTTON_RECORD, isShift && !flipRecord || !isShift && flipRecord ? transport.isLauncherOverdub() ? LaunchpadColors.LAUNCHPAD_COLOR_ROSE : LaunchpadColors.LAUNCHPAD_COLOR_RED_AMBER : transport.isRecording() ? LaunchpadColors.LAUNCHPAD_COLOR_RED_HI : LaunchpadColors.LAUNCHPAD_COLOR_RED_LO);
surface.setButton(LaunchpadControlSurface.LAUNCHPAD_BUTTON_REC_ARM, modeManager.isActiveMode(Modes.MODE_REC_ARM) ? LaunchpadColors.LAUNCHPAD_COLOR_RED : index == 0 ? LaunchpadColors.LAUNCHPAD_COLOR_WHITE : LaunchpadColors.LAUNCHPAD_COLOR_GREY_LO);
surface.setButton(LaunchpadControlSurface.LAUNCHPAD_BUTTON_TRACK, modeManager.isActiveMode(Modes.MODE_TRACK_SELECT) ? LaunchpadColors.LAUNCHPAD_COLOR_GREEN : index == 1 ? LaunchpadColors.LAUNCHPAD_COLOR_WHITE : LaunchpadColors.LAUNCHPAD_COLOR_GREY_LO);
surface.setButton(LaunchpadControlSurface.LAUNCHPAD_BUTTON_MUTE, modeManager.isActiveMode(Modes.MODE_MUTE) ? LaunchpadColors.LAUNCHPAD_COLOR_YELLOW : index == 2 ? LaunchpadColors.LAUNCHPAD_COLOR_WHITE : LaunchpadColors.LAUNCHPAD_COLOR_GREY_LO);
surface.setButton(LaunchpadControlSurface.LAUNCHPAD_BUTTON_SOLO, modeManager.isActiveMode(Modes.MODE_SOLO) ? LaunchpadColors.LAUNCHPAD_COLOR_BLUE : index == 3 ? LaunchpadColors.LAUNCHPAD_COLOR_WHITE : LaunchpadColors.LAUNCHPAD_COLOR_GREY_LO);
surface.setButton(LaunchpadControlSurface.LAUNCHPAD_BUTTON_VOLUME, viewManager.isActiveView(Views.VIEW_VOLUME) ? LaunchpadColors.LAUNCHPAD_COLOR_CYAN : index == 4 ? LaunchpadColors.LAUNCHPAD_COLOR_WHITE : LaunchpadColors.LAUNCHPAD_COLOR_GREY_LO);
surface.setButton(LaunchpadControlSurface.LAUNCHPAD_BUTTON_PAN, viewManager.isActiveView(Views.VIEW_PAN) ? LaunchpadColors.LAUNCHPAD_COLOR_SKY : index == 5 ? LaunchpadColors.LAUNCHPAD_COLOR_WHITE : LaunchpadColors.LAUNCHPAD_COLOR_GREY_LO);
surface.setButton(LaunchpadControlSurface.LAUNCHPAD_BUTTON_SENDS, viewManager.isActiveView(Views.VIEW_SENDS) ? LaunchpadColors.LAUNCHPAD_COLOR_ORCHID : index == 6 ? LaunchpadColors.LAUNCHPAD_COLOR_WHITE : LaunchpadColors.LAUNCHPAD_COLOR_GREY_LO);
surface.setButton(LaunchpadControlSurface.LAUNCHPAD_BUTTON_STOP_CLIP, modeManager.isActiveMode(Modes.MODE_STOP_CLIP) ? LaunchpadColors.LAUNCHPAD_COLOR_ROSE : index == 7 ? LaunchpadColors.LAUNCHPAD_COLOR_WHITE : LaunchpadColors.LAUNCHPAD_COLOR_GREY_LO);
// Update the front LED with the color of the current track
final ITrack track = index == -1 ? null : this.model.getCurrentTrackBank().getTrack(index);
final int color = track != null && track.doesExist() ? this.colorManager.getColor(BitwigColors.getColorIndex(track.getColor())) : 0;
surface.sendLaunchpadSysEx("0A 63 " + StringUtils.toHexStr(color));
}
use of de.mossgrabers.framework.daw.data.ITrack in project DrivenByMoss by git-moss.
the class PanMode method updateKnobLEDs.
/**
* {@inheritDoc}
*/
@Override
protected void updateKnobLEDs() {
final IChannelBank tb = this.model.getCurrentTrackBank();
final int upperBound = this.model.getValueChanger().getUpperBound();
final int extenderOffset = this.surface.getExtenderOffset();
for (int i = 0; i < 8; i++) {
final ITrack t = tb.getTrack(extenderOffset + i);
this.surface.setKnobLED(i, MCUControlSurface.KNOB_LED_MODE_BOOST_CUT, t.doesExist() ? Math.max(t.getPan(), 1) : upperBound / 2, upperBound);
}
}
Aggregations