Search in sources :

Example 1 with MCUControlSurface

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);
    }
}
Also used : IMidiAccess(de.mossgrabers.framework.daw.midi.IMidiAccess) IMidiOutput(de.mossgrabers.framework.daw.midi.IMidiOutput) MCUDisplay(de.mossgrabers.mcu.controller.MCUDisplay) MCUSegmentDisplay(de.mossgrabers.mcu.controller.MCUSegmentDisplay) IMidiInput(de.mossgrabers.framework.daw.midi.IMidiInput) MCUControlSurface(de.mossgrabers.mcu.controller.MCUControlSurface)

Example 2 with MCUControlSurface

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));
    }
}
Also used : TrackMode(de.mossgrabers.mcu.mode.track.TrackMode) MasterMode(de.mossgrabers.mcu.mode.track.MasterMode) VolumeMode(de.mossgrabers.mcu.mode.track.VolumeMode) SendMode(de.mossgrabers.mcu.mode.track.SendMode) PanMode(de.mossgrabers.mcu.mode.track.PanMode) DeviceParamsMode(de.mossgrabers.mcu.mode.device.DeviceParamsMode) MCUControlSurface(de.mossgrabers.mcu.controller.MCUControlSurface) DeviceBrowserMode(de.mossgrabers.mcu.mode.device.DeviceBrowserMode) ModeManager(de.mossgrabers.framework.mode.ModeManager)

Example 3 with MCUControlSurface

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);
        }
    }
}
Also used : ViewManager(de.mossgrabers.framework.view.ViewManager) MCUControlSurface(de.mossgrabers.mcu.controller.MCUControlSurface) PlayPositionTempoCommand(de.mossgrabers.mcu.command.continuous.PlayPositionTempoCommand)

Example 4 with MCUControlSurface

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);
}
Also used : WindCommand(de.mossgrabers.framework.command.trigger.transport.WindCommand) ITransport(de.mossgrabers.framework.daw.ITransport) MCUControlSurface(de.mossgrabers.mcu.controller.MCUControlSurface) View(de.mossgrabers.framework.view.View) ControlView(de.mossgrabers.mcu.view.ControlView) ICursorDevice(de.mossgrabers.framework.daw.ICursorDevice)

Example 5 with MCUControlSurface

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);
        }
    }
}
Also used : IMidiOutput(de.mossgrabers.framework.daw.midi.IMidiOutput) ITrack(de.mossgrabers.framework.daw.data.ITrack) IChannelBank(de.mossgrabers.framework.daw.IChannelBank) MCUControlSurface(de.mossgrabers.mcu.controller.MCUControlSurface) IMasterTrack(de.mossgrabers.framework.daw.data.IMasterTrack)

Aggregations

MCUControlSurface (de.mossgrabers.mcu.controller.MCUControlSurface)10 ViewManager (de.mossgrabers.framework.view.ViewManager)4 ModeSelectCommand (de.mossgrabers.framework.command.trigger.ModeSelectCommand)2 IMidiOutput (de.mossgrabers.framework.daw.midi.IMidiOutput)2 SelectCommand (de.mossgrabers.mcu.command.trigger.SelectCommand)2 SendSelectCommand (de.mossgrabers.mcu.command.trigger.SendSelectCommand)2 MCUDisplay (de.mossgrabers.mcu.controller.MCUDisplay)2 DeviceBrowserMode (de.mossgrabers.mcu.mode.device.DeviceBrowserMode)2 DeviceParamsMode (de.mossgrabers.mcu.mode.device.DeviceParamsMode)2 MasterMode (de.mossgrabers.mcu.mode.track.MasterMode)2 PanMode (de.mossgrabers.mcu.mode.track.PanMode)2 SendMode (de.mossgrabers.mcu.mode.track.SendMode)2 TrackMode (de.mossgrabers.mcu.mode.track.TrackMode)2 VolumeMode (de.mossgrabers.mcu.mode.track.VolumeMode)2 ControlView (de.mossgrabers.mcu.view.ControlView)2 WindCommand (de.mossgrabers.framework.command.trigger.transport.WindCommand)1 IChannelBank (de.mossgrabers.framework.daw.IChannelBank)1 ICursorDevice (de.mossgrabers.framework.daw.ICursorDevice)1 ITransport (de.mossgrabers.framework.daw.ITransport)1 IMasterTrack (de.mossgrabers.framework.daw.data.IMasterTrack)1