Search in sources :

Example 6 with IMidiOutput

use of de.mossgrabers.framework.daw.midi.IMidiOutput 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)

Example 7 with IMidiOutput

use of de.mossgrabers.framework.daw.midi.IMidiOutput in project DrivenByMoss by git-moss.

the class SLControllerSetup method createSurface.

/**
 * {@inheritDoc}
 */
@Override
protected void createSurface() {
    final IMidiAccess midiAccess = this.factory.createMidiAccess();
    final IMidiOutput output = midiAccess.createOutput();
    final IMidiInput input = midiAccess.createInput(this.isMkII ? "Novation SL MkII (Drumpads)" : "Novation SL MkI (Drumpads)", "90????", "80????");
    midiAccess.createInput(1, this.isMkII ? "Novation SL MkII (Keyboard)" : "Novation SL MkI (Keyboard)", "80????", "90????", "B0????", "D0????", "E0????");
    final IHost hostProxy = this.model.getHost();
    final SLControlSurface surface = new SLControlSurface(hostProxy, this.colorManager, this.configuration, output, input, this.isMkII);
    surface.setDisplay(new SLDisplay(hostProxy, output));
    this.surfaces.add(surface);
}
Also used : IMidiAccess(de.mossgrabers.framework.daw.midi.IMidiAccess) IMidiOutput(de.mossgrabers.framework.daw.midi.IMidiOutput) IMidiInput(de.mossgrabers.framework.daw.midi.IMidiInput) IHost(de.mossgrabers.framework.daw.IHost) SLControlSurface(de.mossgrabers.sl.controller.SLControlSurface) SLDisplay(de.mossgrabers.sl.controller.SLDisplay)

Example 8 with IMidiOutput

use of de.mossgrabers.framework.daw.midi.IMidiOutput in project DrivenByMoss by git-moss.

the class DeviceParamsMode method setLEDs.

/**
 * Set the button LEDs.
 */
public void setLEDs() {
    final boolean hasDevice = this.model.hasSelectedDevice();
    final IMidiOutput output = this.surface.getOutput();
    for (int i = 0; i < 8; i++) {
        final int value = hasDevice ? this.model.getCursorDevice().getFXParam(i).getValue() : 0;
        output.sendCC(0x70 + i, Math.min(value * 11 / 127, 11));
    }
}
Also used : IMidiOutput(de.mossgrabers.framework.daw.midi.IMidiOutput)

Example 9 with IMidiOutput

use of de.mossgrabers.framework.daw.midi.IMidiOutput in project DrivenByMoss by git-moss.

the class GenericFlexiControllerSetup method createObservers.

/**
 * {@inheritDoc}
 */
@Override
protected void createObservers() {
    super.createObservers();
    final GenericFlexiControlSurface surface = this.getSurface();
    this.configuration.addSettingObserver(GenericFlexiConfiguration.SLOT_CHANGE, surface::updateKeyTranslation);
    this.configuration.addSettingObserver(GenericFlexiConfiguration.SELECTED_MODE, this::selectMode);
    final ITrackBank trackBank = this.model.getTrackBank();
    trackBank.addSelectionObserver((index, selected) -> this.handleTrackChange(selected));
    final ITrackBank effectTrackBank = this.model.getEffectTrackBank();
    if (effectTrackBank != null)
        effectTrackBank.addSelectionObserver((index, selected) -> this.handleTrackChange(selected));
    surface.getModeManager().addChangeListener((oldMode, newMode) -> this.updateIndication());
    // Handle configuration changes
    this.createNoteRepeatObservers(this.configuration, surface);
    this.configuration.registerDeactivatedItemsHandler(this.model);
    this.configuration.addSettingObserver(GenericFlexiConfiguration.ENABLED_MPE_ZONES, () -> surface.scheduleTask(() -> {
        final INoteInput input = surface.getMidiInput().getDefaultNoteInput();
        final IMidiOutput output = surface.getMidiOutput();
        final boolean mpeEnabled = this.configuration.isMPEEndabled();
        input.enableMPE(mpeEnabled);
        // Enable MPE zone 1 with all 15 channels
        output.configureMPE(AbstractMidiOutput.ZONE_1, mpeEnabled ? 15 : 0);
        // Disable MPE zone
        output.configureMPE(AbstractMidiOutput.ZONE_2, 0);
    }, 2000));
    this.configuration.addSettingObserver(GenericFlexiConfiguration.MPE_PITCHBEND_RANGE, () -> surface.scheduleTask(() -> {
        final INoteInput input = surface.getMidiInput().getDefaultNoteInput();
        final IMidiOutput output = surface.getMidiOutput();
        final int mpePitchBendRange = this.configuration.getMPEPitchBendRange();
        input.setMPEPitchBendSensitivity(mpePitchBendRange);
        output.sendMPEPitchbendRange(AbstractMidiOutput.ZONE_1, mpePitchBendRange);
    }, 2000));
    this.activateBrowserObserver(Modes.BROWSER);
}
Also used : GenericFlexiControlSurface(de.mossgrabers.controller.generic.controller.GenericFlexiControlSurface) ModesHandler(de.mossgrabers.controller.generic.flexihandler.ModesHandler) SignedBitRelativeValueChanger(de.mossgrabers.framework.controller.valuechanger.SignedBitRelativeValueChanger) TwosComplementValueChanger(de.mossgrabers.framework.controller.valuechanger.TwosComplementValueChanger) ITrack(de.mossgrabers.framework.daw.data.ITrack) TrackSendMode(de.mossgrabers.framework.mode.track.TrackSendMode) DeviceID(de.mossgrabers.framework.daw.constants.DeviceID) AbstractControllerSetup(de.mossgrabers.framework.controller.AbstractControllerSetup) IEnumSetting(de.mossgrabers.framework.configuration.IEnumSetting) INoteInput(de.mossgrabers.framework.daw.midi.INoteInput) BrowserMode(de.mossgrabers.framework.mode.device.BrowserMode) GenericFlexiControlSurface(de.mossgrabers.controller.generic.controller.GenericFlexiControlSurface) Locale(java.util.Locale) MasterHandler(de.mossgrabers.controller.generic.flexihandler.MasterHandler) ProgramBank(de.mossgrabers.controller.generic.flexihandler.utils.ProgramBank) ParseException(java.text.ParseException) IValueObserver(de.mossgrabers.framework.observer.IValueObserver) FxTrackHandler(de.mossgrabers.controller.generic.flexihandler.FxTrackHandler) DeviceHandler(de.mossgrabers.controller.generic.flexihandler.DeviceHandler) Modes(de.mossgrabers.framework.mode.Modes) ModeManager(de.mossgrabers.framework.featuregroup.ModeManager) TrackHandler(de.mossgrabers.controller.generic.flexihandler.TrackHandler) Set(java.util.Set) IValueChanger(de.mossgrabers.framework.controller.valuechanger.IValueChanger) EqHandler(de.mossgrabers.controller.generic.flexihandler.EqHandler) ClipHandler(de.mossgrabers.controller.generic.flexihandler.ClipHandler) ISettingsUI(de.mossgrabers.framework.configuration.ISettingsUI) List(java.util.List) ActionHandler(de.mossgrabers.controller.generic.flexihandler.ActionHandler) UserHandler(de.mossgrabers.controller.generic.flexihandler.UserHandler) IMidiInput(de.mossgrabers.framework.daw.midi.IMidiInput) Optional(java.util.Optional) FileEx(de.mossgrabers.framework.utils.FileEx) TransportHandler(de.mossgrabers.controller.generic.flexihandler.TransportHandler) ITrackBank(de.mossgrabers.framework.daw.data.bank.ITrackBank) FlexiCommand(de.mossgrabers.controller.generic.controller.FlexiCommand) MidiCCHandler(de.mossgrabers.controller.generic.flexihandler.MidiCCHandler) ISetupFactory(de.mossgrabers.framework.controller.ISetupFactory) OffsetBinaryRelativeValueChanger(de.mossgrabers.framework.controller.valuechanger.OffsetBinaryRelativeValueChanger) TrackVolumeMode(de.mossgrabers.framework.mode.track.TrackVolumeMode) ModelSetup(de.mossgrabers.framework.daw.ModelSetup) TrackPanMode(de.mossgrabers.framework.mode.track.TrackPanMode) Scales(de.mossgrabers.framework.scale.Scales) AbstractMidiOutput(de.mossgrabers.framework.daw.midi.AbstractMidiOutput) ArrayList(java.util.ArrayList) MarkerHandler(de.mossgrabers.controller.generic.flexihandler.MarkerHandler) LayoutHandler(de.mossgrabers.controller.generic.flexihandler.LayoutHandler) IMasterTrack(de.mossgrabers.framework.daw.data.IMasterTrack) IHost(de.mossgrabers.framework.daw.IHost) ParameterMode(de.mossgrabers.framework.mode.device.ParameterMode) IMidiOutput(de.mossgrabers.framework.daw.midi.IMidiOutput) IMidiAccess(de.mossgrabers.framework.daw.midi.IMidiAccess) IOException(java.io.IOException) NoteInputHandler(de.mossgrabers.controller.generic.flexihandler.NoteInputHandler) ISendBank(de.mossgrabers.framework.daw.data.bank.ISendBank) IParameterBank(de.mossgrabers.framework.daw.data.bank.IParameterBank) BrowserHandler(de.mossgrabers.controller.generic.flexihandler.BrowserHandler) SceneHandler(de.mossgrabers.controller.generic.flexihandler.SceneHandler) ColorManager(de.mossgrabers.framework.controller.color.ColorManager) TrackMode(de.mossgrabers.framework.mode.track.TrackMode) Collections(java.util.Collections) GlobalHandler(de.mossgrabers.controller.generic.flexihandler.GlobalHandler) IMidiOutput(de.mossgrabers.framework.daw.midi.IMidiOutput) ITrackBank(de.mossgrabers.framework.daw.data.bank.ITrackBank) INoteInput(de.mossgrabers.framework.daw.midi.INoteInput)

Example 10 with IMidiOutput

use of de.mossgrabers.framework.daw.midi.IMidiOutput in project DrivenByMoss by git-moss.

the class MCUControlSurface method switchVuMode.

// LEDs on/LEDs and VU-meter on display on/VU-meter on display on/all off
public void switchVuMode(final int mode) {
    // Always horizontal
    this.output.sendSysex(new StringBuilder(SYSEX_HDR).append("21 00 F7").toString());
    if (this.activeVuMode != mode) {
        if (this.activeVuMode < 5)
            this.activeVuMode = mode;
        else
            this.activeVuMode = VUMODE_LED;
    }
    final IMidiOutput out = this.getMidiOutput();
    // message
    switch(this.activeVuMode) {
        case VUMODE_LED:
            for (int i = 0; i < 8; i++) {
                // resets the leds (and vu-meters on the display?)
                out.sendChannelAftertouch(0 + (i << 4), 0);
                out.sendSysex(SYSEX_HDR + "20 0" + i + " 01 F7");
            }
            break;
        case VUMODE_LED_AND_LCD:
            for (int i = 0; i < 8; i++) {
                out.sendChannelAftertouch(0 + (i << 4), 0);
                out.sendSysex(SYSEX_HDR + "20 0" + i + " 03 F7");
            }
            break;
        case VUMODE_LCD:
            for (int i = 0; i < 8; i++) {
                out.sendChannelAftertouch(0 + (i << 4), 0);
                out.sendSysex(SYSEX_HDR + "20 0" + i + " 06 F7");
            }
            break;
        case VUMODE_OFF:
            for (int i = 0; i < 8; i++) {
                out.sendChannelAftertouch(0 + (i << 4), 0);
                out.sendSysex(SYSEX_HDR + "20 0" + i + " 00 F7");
            }
            break;
        default:
            // Not used
            break;
    }
}
Also used : IMidiOutput(de.mossgrabers.framework.daw.midi.IMidiOutput)

Aggregations

IMidiOutput (de.mossgrabers.framework.daw.midi.IMidiOutput)28 IMidiAccess (de.mossgrabers.framework.daw.midi.IMidiAccess)16 IMidiInput (de.mossgrabers.framework.daw.midi.IMidiInput)16 ITrack (de.mossgrabers.framework.daw.data.ITrack)6 ColorManager (de.mossgrabers.framework.controller.color.ColorManager)4 DummyDisplay (de.mossgrabers.framework.controller.display.DummyDisplay)4 IChannelBank (de.mossgrabers.framework.daw.IChannelBank)4 IHost (de.mossgrabers.framework.daw.IHost)4 GenericFlexiControlSurface (de.mossgrabers.controller.generic.controller.GenericFlexiControlSurface)3 ProgramBank (de.mossgrabers.controller.generic.flexihandler.utils.ProgramBank)2 MaschineControlSurface (de.mossgrabers.controller.ni.maschine.mk3.controller.MaschineControlSurface)2 LaunchkeyMk3ControlSurface (de.mossgrabers.controller.novation.launchkey.maxi.controller.LaunchkeyMk3ControlSurface)2 IEnumSetting (de.mossgrabers.framework.configuration.IEnumSetting)2 IMasterTrack (de.mossgrabers.framework.daw.data.IMasterTrack)2 MCUControlSurface (de.mossgrabers.mcu.controller.MCUControlSurface)2 ArrayList (java.util.ArrayList)2 APCControlSurface (de.mossgrabers.apc.controller.APCControlSurface)1 APCminiControlSurface (de.mossgrabers.apcmini.controller.APCminiControlSurface)1 BeatstepControlSurface (de.mossgrabers.beatstep.controller.BeatstepControlSurface)1 BeatstepControlSurface (de.mossgrabers.controller.arturia.beatstep.controller.BeatstepControlSurface)1