use of de.mossgrabers.mcu.controller.MCUControlSurface in project DrivenByMoss by git-moss.
the class MCUControllerSetup method createSurface.
/**
* {@inheritDoc}
*/
@Override
protected void createSurface() {
final IMidiAccess midiAccess = this.factory.createMidiAccess();
for (int i = 0; i < this.numMCUDevices; i++) {
final IMidiOutput output = midiAccess.createOutput(i);
final IMidiInput input = midiAccess.createInput(i, null);
final MCUControlSurface surface = new MCUControlSurface(this.surfaces, this.model.getHost(), this.colorManager, this.configuration, output, input, 8 * (this.numMCUDevices - i - 1), i == 0);
this.surfaces.add(surface);
surface.setDisplay(new MCUDisplay(this.model.getHost(), output, true, false));
surface.setSecondDisplay(new MCUDisplay(this.model.getHost(), output, false, i == 0));
surface.setSegmentDisplay(new MCUSegmentDisplay(output));
surface.getModeManager().setDefaultMode(Modes.MODE_VOLUME);
}
}
use of de.mossgrabers.mcu.controller.MCUControlSurface in project DrivenByMoss by git-moss.
the class MCUControllerSetup method createModes.
/**
* {@inheritDoc}
*/
@Override
protected void createModes() {
for (int index = 0; index < this.numMCUDevices; index++) {
final MCUControlSurface surface = this.getSurface(index);
final ModeManager modeManager = surface.getModeManager();
modeManager.registerMode(Modes.MODE_TRACK, new TrackMode(surface, this.model));
modeManager.registerMode(Modes.MODE_VOLUME, new VolumeMode(surface, this.model));
modeManager.registerMode(Modes.MODE_PAN, new PanMode(surface, this.model));
final SendMode modeSend = new SendMode(surface, this.model);
for (int i = 0; i < 8; i++) modeManager.registerMode(Integer.valueOf(Modes.MODE_SEND1.intValue() + i), modeSend);
modeManager.registerMode(Modes.MODE_DEVICE_PARAMS, new DeviceParamsMode(surface, this.model));
modeManager.registerMode(Modes.MODE_BROWSER, new DeviceBrowserMode(surface, this.model));
modeManager.registerMode(Modes.MODE_MASTER, new MasterMode(surface, this.model, false));
}
}
use of de.mossgrabers.mcu.controller.MCUControlSurface in project DrivenByMoss by git-moss.
the class MCUControllerSetup method registerContinuousCommands.
/**
* {@inheritDoc}
*/
@Override
protected void registerContinuousCommands() {
MCUControlSurface surface = this.getSurface();
ViewManager viewManager = surface.getViewManager();
viewManager.registerContinuousCommand(Commands.CONT_COMMAND_PLAY_POSITION, new PlayPositionTempoCommand(this.model, surface));
surface.assignContinuousCommand(MCUControlSurface.MCU_CC_JOG, 1, Commands.CONT_COMMAND_PLAY_POSITION);
for (int index = 0; index < this.numMCUDevices; index++) {
surface = this.getSurface(index);
viewManager = surface.getViewManager();
for (int i = 0; i < 8; i++) {
final Integer commandID = Integer.valueOf(Commands.CONT_COMMAND_KNOB1.intValue() + i);
viewManager.registerContinuousCommand(commandID, new KnobRowModeCommand<>(i, this.model, surface));
surface.assignContinuousCommand(MCUControlSurface.MCU_CC_VPOT1 + i, 1, commandID);
}
}
}
use of de.mossgrabers.mcu.controller.MCUControlSurface in project DrivenByMoss by git-moss.
the class MCUControllerSetup method updateButtons.
@SuppressWarnings("unchecked")
private void updateButtons() {
final MCUControlSurface surface = this.getSurface();
final Integer mode = surface.getModeManager().getActiveModeId();
if (mode == null)
return;
this.updateVUandFaders();
this.updateSegmentDisplay();
// Set button states
final ITransport t = this.model.getTransport();
final boolean isShift = surface.isShiftPressed();
final boolean isFlipRecord = this.configuration.isFlipRecord();
final boolean isRecordShifted = isShift && !isFlipRecord || !isShift && isFlipRecord;
final boolean isTrackOn = Modes.MODE_TRACK.equals(mode) || Modes.MODE_VOLUME.equals(mode);
final boolean isPanOn = Modes.MODE_PAN.equals(mode);
final boolean isSendOn = mode.intValue() >= Modes.MODE_SEND1.intValue() && mode.intValue() <= Modes.MODE_SEND8.intValue();
final boolean isDeviceOn = Modes.MODE_DEVICE_PARAMS.equals(mode);
final boolean isLEDOn = surface.isPressed(MCUControlSurface.MCU_OPTION) ? this.model.isCursorTrackPinned() : isTrackOn;
surface.updateButton(MCUControlSurface.MCU_MODE_IO, isLEDOn ? MCU_BUTTON_STATE_ON : MCU_BUTTON_STATE_OFF);
surface.updateButton(MCUControlSurface.MCU_MODE_PAN, isPanOn ? MCU_BUTTON_STATE_ON : MCU_BUTTON_STATE_OFF);
surface.updateButton(MCUControlSurface.MCU_MODE_SENDS, isSendOn ? MCU_BUTTON_STATE_ON : MCU_BUTTON_STATE_OFF);
final ICursorDevice cursorDevice = this.model.getCursorDevice();
final boolean isOn = surface.isPressed(MCUControlSurface.MCU_OPTION) ? cursorDevice.isPinned() : isDeviceOn;
surface.updateButton(MCUControlSurface.MCU_MODE_PLUGIN, isOn ? MCU_BUTTON_STATE_ON : MCU_BUTTON_STATE_OFF);
surface.updateButton(MCUControlSurface.MCU_USER, Modes.MODE_BROWSER.equals(mode) ? MCU_BUTTON_STATE_ON : MCU_BUTTON_STATE_OFF);
final ITransport transport = this.model.getTransport();
final String automationWriteMode = transport.getAutomationWriteMode();
final boolean writingArrangerAutomation = transport.isWritingArrangerAutomation();
surface.updateButton(MCUControlSurface.MCU_F6, transport.isPunchInEnabled() ? MCU_BUTTON_STATE_ON : MCU_BUTTON_STATE_OFF);
surface.updateButton(MCUControlSurface.MCU_F7, transport.isPunchOutEnabled() ? MCU_BUTTON_STATE_ON : MCU_BUTTON_STATE_OFF);
surface.updateButton(MCUControlSurface.MCU_READ, !writingArrangerAutomation ? MCU_BUTTON_STATE_ON : MCU_BUTTON_STATE_OFF);
final int writeState = writingArrangerAutomation && ITransport.AUTOMATION_MODES_VALUES[2].equals(automationWriteMode) ? MCU_BUTTON_STATE_ON : MCU_BUTTON_STATE_OFF;
surface.updateButton(MCUControlSurface.MCU_WRITE, writeState);
surface.updateButton(MCUControlSurface.MCU_GROUP, writeState);
surface.updateButton(MCUControlSurface.MCU_TRIM, transport.isWritingClipLauncherAutomation() ? MCU_BUTTON_STATE_ON : MCU_BUTTON_STATE_OFF);
surface.updateButton(MCUControlSurface.MCU_TOUCH, writingArrangerAutomation && ITransport.AUTOMATION_MODES_VALUES[1].equals(automationWriteMode) ? MCU_BUTTON_STATE_ON : MCU_BUTTON_STATE_OFF);
surface.updateButton(MCUControlSurface.MCU_LATCH, writingArrangerAutomation && ITransport.AUTOMATION_MODES_VALUES[0].equals(automationWriteMode) ? MCU_BUTTON_STATE_ON : MCU_BUTTON_STATE_OFF);
final View view = surface.getViewManager().getView(Views.VIEW_CONTROL);
surface.updateButton(MCUControlSurface.MCU_REWIND, ((WindCommand<MCUControlSurface, MCUConfiguration>) view.getTriggerCommand(Commands.COMMAND_REWIND)).isRewinding() ? MCU_BUTTON_STATE_ON : MCU_BUTTON_STATE_OFF);
surface.updateButton(MCUControlSurface.MCU_FORWARD, ((WindCommand<MCUControlSurface, MCUConfiguration>) view.getTriggerCommand(Commands.COMMAND_FORWARD)).isForwarding() ? MCU_BUTTON_STATE_ON : MCU_BUTTON_STATE_OFF);
surface.updateButton(MCUControlSurface.MCU_REPEAT, t.isLoop() ? MCU_BUTTON_STATE_ON : MCU_BUTTON_STATE_OFF);
surface.updateButton(MCUControlSurface.MCU_STOP, !t.isPlaying() ? MCU_BUTTON_STATE_ON : MCU_BUTTON_STATE_OFF);
surface.updateButton(MCUControlSurface.MCU_PLAY, t.isPlaying() ? MCU_BUTTON_STATE_ON : MCU_BUTTON_STATE_OFF);
surface.updateButton(MCUControlSurface.MCU_RECORD, isRecordShifted ? t.isLauncherOverdub() ? MCU_BUTTON_STATE_ON : MCU_BUTTON_STATE_OFF : t.isRecording() ? MCU_BUTTON_STATE_ON : MCU_BUTTON_STATE_OFF);
surface.updateButton(MCUControlSurface.MCU_NAME_VALUE, surface.getConfiguration().isDisplayTrackNames() ? MCU_BUTTON_STATE_ON : MCU_BUTTON_STATE_OFF);
surface.updateButton(MCUControlSurface.MCU_ZOOM, surface.getConfiguration().isZoomState() ? MCU_BUTTON_STATE_ON : MCU_BUTTON_STATE_OFF);
surface.updateButton(MCUControlSurface.MCU_SCRUB, surface.getModeManager().isActiveMode(Modes.MODE_DEVICE_PARAMS) ? MCU_BUTTON_STATE_ON : MCU_BUTTON_STATE_OFF);
surface.updateButton(MCUControlSurface.MCU_MIDI_TRACKS, MCU_BUTTON_STATE_OFF);
surface.updateButton(MCUControlSurface.MCU_INPUTS, MCU_BUTTON_STATE_OFF);
surface.updateButton(MCUControlSurface.MCU_AUDIO_TRACKS, surface.isShiftPressed() && cursorDevice.isWindowOpen() ? MCU_BUTTON_STATE_ON : MCU_BUTTON_STATE_OFF);
surface.updateButton(MCUControlSurface.MCU_AUDIO_INSTR, MCU_BUTTON_STATE_OFF);
surface.updateButton(MCUControlSurface.MCU_CLICK, (isShift ? t.isMetronomeTicksOn() : t.isMetronomeOn()) ? MCU_BUTTON_STATE_ON : MCU_BUTTON_STATE_OFF);
surface.updateButton(MCUControlSurface.MCU_SOLO, this.model.getGroove().getParameters()[0].getValue() > 0 ? MCU_BUTTON_STATE_ON : MCU_BUTTON_STATE_OFF);
surface.updateButton(MCUControlSurface.MCU_REPLACE, (isShift ? t.isLauncherOverdub() : t.isArrangerOverdub()) ? MCU_BUTTON_STATE_ON : MCU_BUTTON_STATE_OFF);
surface.updateButton(MCUControlSurface.MCU_FLIP, this.model.isEffectTrackBankActive() ? MCU_BUTTON_STATE_ON : MCU_BUTTON_STATE_OFF);
final boolean displayTicks = this.configuration.isDisplayTicks();
surface.updateButton(MCUControlSurface.MCU_SMPTE_BEATS, displayTicks ? MCU_BUTTON_STATE_OFF : MCU_BUTTON_STATE_ON);
surface.updateButton(MCUControlSurface.MCU_SMPTE_LED, displayTicks ? MCU_BUTTON_STATE_ON : MCU_BUTTON_STATE_OFF);
surface.updateButton(MCUControlSurface.MCU_BEATS_LED, displayTicks ? MCU_BUTTON_STATE_OFF : MCU_BUTTON_STATE_ON);
surface.updateButton(MCUControlSurface.MCU_MARKER, this.model.getArranger().areCueMarkersVisible() ? MCU_BUTTON_STATE_ON : MCU_BUTTON_STATE_OFF);
}
use of de.mossgrabers.mcu.controller.MCUControlSurface 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);
}
}
}
Aggregations