Search in sources :

Example 1 with MaschineConfiguration

use of de.mossgrabers.controller.ni.maschine.mk3.MaschineConfiguration in project DrivenByMoss by git-moss.

the class MaschineControllerSetup method registerContinuousCommands.

/**
 * {@inheritDoc}
 */
@Override
protected void registerContinuousCommands() {
    final MaschineControlSurface surface = this.getSurface();
    final ModeManager modeManager = surface.getModeManager();
    final ViewManager viewManager = surface.getViewManager();
    final IHwRelativeKnob knob = this.addRelativeKnob(ContinuousID.MASTER_KNOB, "Encoder", new MainKnobRowModeCommand(this.model, surface), MaschineControlSurface.ENCODER);
    knob.bindTouch((event, velocity) -> {
        final IMode mode = modeManager.getActive();
        if (mode != null && event != ButtonEvent.LONG)
            mode.onKnobTouch(8, event == ButtonEvent.DOWN);
    }, surface.getMidiInput(), BindType.CC, 0, MaschineControlSurface.ENCODER_TOUCH);
    if (this.maschine.hasMCUDisplay()) {
        for (int i = 0; i < 8; i++) {
            final int index = i;
            final IHwRelativeKnob modeKnob = this.addRelativeKnob(ContinuousID.get(ContinuousID.KNOB1, i), "Knob " + (i + 1), new KnobRowModeCommand<>(i, this.model, surface), MaschineControlSurface.MODE_KNOB_1 + i);
            modeKnob.bindTouch((event, velocity) -> {
                final IMode mode = modeManager.getActive();
                if (mode != null && event != ButtonEvent.LONG)
                    mode.onKnobTouch(index, event == ButtonEvent.DOWN);
            }, surface.getMidiInput(), BindType.CC, 0, MaschineControlSurface.MODE_KNOB_TOUCH_1 + i);
            modeKnob.setIndexInGroup(i);
        }
    }
    final TouchstripCommand touchstripCommand = new TouchstripCommand(this.model, surface);
    this.addFader(ContinuousID.CROSSFADER, "Touchstrip", touchstripCommand, BindType.CC, MaschineControlSurface.TOUCHSTRIP, false);
    surface.getContinuous(ContinuousID.CROSSFADER).bindTouch(touchstripCommand, surface.getMidiInput(), BindType.CC, 0, MaschineControlSurface.TOUCHSTRIP_TOUCH);
    // Enable aftertouch
    final Views[] views = { Views.PLAY, Views.DRUM };
    for (final Views viewID : views) {
        final IView view = viewManager.get(viewID);
        view.registerAftertouchCommand(new AftertouchViewCommand<>(view, this.model, surface));
    }
    if (this.maschine == Maschine.STUDIO) {
        final IHwAbsoluteKnob masterKnob = this.addAbsoluteKnob(ContinuousID.MONITOR_KNOB, "Encoder", null, MaschineControlSurface.MONITOR_ENCODER);
        this.encoderManager = new StudioEncoderModeManager(masterKnob, this.model, surface);
        masterKnob.bind(this.encoderManager);
        final MaschineMonitorEncoderCommand<MaschineControlSurface, MaschineConfiguration> encoderCommandMaster = new MaschineMonitorEncoderCommand<>(this.encoderManager, EncoderMode.MASTER_VOLUME, this.model, surface);
        this.addButton(ButtonID.ROW4_1, "MST", encoderCommandMaster, MaschineControlSurface.MONITOR_MST, encoderCommandMaster::isLit);
        final MaschineMonitorEncoderCommand<MaschineControlSurface, MaschineConfiguration> encoderCommandSelectedTrack = new MaschineMonitorEncoderCommand<>(this.encoderManager, EncoderMode.SELECTED_TRACK_VOLUME, this.model, surface);
        this.addButton(ButtonID.ROW4_2, "GRP", encoderCommandSelectedTrack, MaschineControlSurface.MONITOR_GRP, encoderCommandSelectedTrack::isLit);
        final MaschineMonitorEncoderCommand<MaschineControlSurface, MaschineConfiguration> encoderCommandMetronome = new MaschineMonitorEncoderCommand<>(this.encoderManager, EncoderMode.METRONOME_VOLUME, this.model, surface);
        this.addButton(ButtonID.ROW4_3, "SND", encoderCommandMetronome, MaschineControlSurface.MONITOR_SND, encoderCommandMetronome::isLit);
        final MaschineMonitorEncoderCommand<MaschineControlSurface, MaschineConfiguration> encoderCommandCue = new MaschineMonitorEncoderCommand<>(this.encoderManager, EncoderMode.CUE_VOLUME, this.model, surface);
        this.addButton(ButtonID.ROW4_4, "CUE", encoderCommandCue, MaschineControlSurface.MONITOR_CUE, encoderCommandCue::isLit);
        final MaschineMonitorEncoderCommand<MaschineControlSurface, MaschineConfiguration> encoderCommandMasterPan = new MaschineMonitorEncoderCommand<>(this.encoderManager, EncoderMode.MASTER_PANORAMA, this.model, surface);
        this.addButton(ButtonID.ROW4_5, "IN1", encoderCommandMasterPan, MaschineControlSurface.MONITOR_IN1, encoderCommandMasterPan::isLit);
        final MaschineMonitorEncoderCommand<MaschineControlSurface, MaschineConfiguration> encoderCommandSelectedTrackPan = new MaschineMonitorEncoderCommand<>(this.encoderManager, EncoderMode.SELECTED_TRACK_PANORAMA, this.model, surface);
        this.addButton(ButtonID.ROW4_6, "IN2", encoderCommandSelectedTrackPan, MaschineControlSurface.MONITOR_IN2, encoderCommandSelectedTrackPan::isLit);
        final MaschineMonitorEncoderCommand<MaschineControlSurface, MaschineConfiguration> encoderCommandCueMix = new MaschineMonitorEncoderCommand<>(this.encoderManager, EncoderMode.CUE_MIX, this.model, surface);
        this.addButton(ButtonID.ROW4_8, "IN4", encoderCommandCueMix, MaschineControlSurface.MONITOR_IN4, encoderCommandCueMix::isLit);
        this.addButton(ButtonID.TOGGLE_VU, "IN3", (event, value) -> {
            if (event == ButtonEvent.UP)
                this.encoderManager.toggleMode();
        }, MaschineControlSurface.MONITOR_IN3, this.encoderManager::isParameterMode);
        // Activate the default mode
        this.encoderManager.setActiveEncoderMode(EncoderMode.MASTER_VOLUME);
    }
}
Also used : MainKnobRowModeCommand(de.mossgrabers.controller.ni.maschine.mk3.command.continuous.MainKnobRowModeCommand) ViewManager(de.mossgrabers.framework.featuregroup.ViewManager) MaschineControlSurface(de.mossgrabers.controller.ni.maschine.mk3.controller.MaschineControlSurface) IHwRelativeKnob(de.mossgrabers.framework.controller.hardware.IHwRelativeKnob) ModeManager(de.mossgrabers.framework.featuregroup.ModeManager) StudioEncoderModeManager(de.mossgrabers.controller.ni.maschine.mk3.controller.StudioEncoderModeManager) MaschineMonitorEncoderCommand(de.mossgrabers.controller.ni.maschine.core.command.trigger.MaschineMonitorEncoderCommand) Views(de.mossgrabers.framework.view.Views) IView(de.mossgrabers.framework.featuregroup.IView) IMode(de.mossgrabers.framework.featuregroup.IMode) TouchstripCommand(de.mossgrabers.controller.ni.maschine.mk3.command.continuous.TouchstripCommand) IHwAbsoluteKnob(de.mossgrabers.framework.controller.hardware.IHwAbsoluteKnob) StudioEncoderModeManager(de.mossgrabers.controller.ni.maschine.mk3.controller.StudioEncoderModeManager)

Example 2 with MaschineConfiguration

use of de.mossgrabers.controller.ni.maschine.mk3.MaschineConfiguration in project DrivenByMoss by git-moss.

the class RibbonCommand method execute.

/**
 * {@inheritDoc}
 */
@Override
public void execute(final ButtonEvent event, final int velocity) {
    if (event != ButtonEvent.DOWN)
        return;
    final MaschineConfiguration configuration = this.surface.getConfiguration();
    final RibbonMode ribbonMode = configuration.getRibbonMode();
    RibbonMode m = this.activeMode;
    // If the current mode is part of these modes select the next one
    int index = this.modes.indexOf(ribbonMode);
    if (index >= 0) {
        index++;
        if (index >= this.modes.size())
            index = 0;
        m = this.modes.get(index);
    }
    this.activeMode = m;
    this.surface.getDisplay().notify(m.getName());
    configuration.setRibbonMode(m);
    ((TouchstripCommand) this.surface.getContinuous(ContinuousID.CROSSFADER).getTouchCommand()).resetRibbonValue(m);
}
Also used : MaschineConfiguration(de.mossgrabers.controller.ni.maschine.mk3.MaschineConfiguration) RibbonMode(de.mossgrabers.controller.ni.maschine.core.RibbonMode) TouchstripCommand(de.mossgrabers.controller.ni.maschine.mk3.command.continuous.TouchstripCommand)

Example 3 with MaschineConfiguration

use of de.mossgrabers.controller.ni.maschine.mk3.MaschineConfiguration in project DrivenByMoss by git-moss.

the class TouchstripCommand method execute.

/**
 * {@inheritDoc}
 */
@Override
public void execute(final int value) {
    this.ribbonValue = value;
    final MaschineConfiguration config = this.surface.getConfiguration();
    final RibbonMode ribbonMode = config.getRibbonMode();
    switch(ribbonMode) {
        case PITCH_DOWN:
            this.surface.sendMidiEvent(0xE0, 0, (127 - value) / 2);
            break;
        case PITCH_UP:
            this.surface.sendMidiEvent(0xE0, 0, 64 + value / 2);
            break;
        case PITCH_DOWN_UP:
            this.surface.sendMidiEvent(0xE0, 0, value);
            break;
        case CC_1:
            this.surface.sendMidiEvent(0xB0, 1, value);
            break;
        case CC_11:
            this.surface.sendMidiEvent(0xB0, 11, value);
            break;
        case MASTER_VOLUME:
            this.model.getMasterTrack().setVolume(this.model.getValueChanger().toDAWValue(value));
            break;
        case NOTE_REPEAT_PERIOD:
        case NOTE_REPEAT_LENGTH:
            final Resolution[] values = Resolution.values();
            final double scaled = (127 - value) / 127.0;
            final int index = (int) Math.round(scaled * (values.length - 1));
            final double resolutionValue = values[values.length - 1 - index].getValue();
            final INoteRepeat noteRepeat = this.surface.getMidiInput().getDefaultNoteInput().getNoteRepeat();
            if (ribbonMode == RibbonMode.NOTE_REPEAT_PERIOD)
                noteRepeat.setPeriod(resolutionValue);
            else
                noteRepeat.setNoteLength(resolutionValue);
            break;
        default:
            // Not used
            break;
    }
}
Also used : MaschineConfiguration(de.mossgrabers.controller.ni.maschine.mk3.MaschineConfiguration) RibbonMode(de.mossgrabers.controller.ni.maschine.core.RibbonMode) INoteRepeat(de.mossgrabers.framework.daw.midi.INoteRepeat) Resolution(de.mossgrabers.framework.daw.constants.Resolution)

Example 4 with MaschineConfiguration

use of de.mossgrabers.controller.ni.maschine.mk3.MaschineConfiguration in project DrivenByMoss by git-moss.

the class ToggleFixedVelCommand method execute.

/**
 * {@inheritDoc}
 */
@Override
public void execute(final ButtonEvent event, final int velocity) {
    if (event != ButtonEvent.UP)
        return;
    final MaschineConfiguration configuration = this.surface.getConfiguration();
    final boolean enabled = !configuration.isAccentActive();
    configuration.setAccentEnabled(enabled);
    this.surface.getDisplay().notify("Fixed Velocity: " + (enabled ? "On" : "Off"));
}
Also used : MaschineConfiguration(de.mossgrabers.controller.ni.maschine.mk3.MaschineConfiguration)

Example 5 with MaschineConfiguration

use of de.mossgrabers.controller.ni.maschine.mk3.MaschineConfiguration in project DrivenByMoss by git-moss.

the class NoteRepeatMode method onKnobTouch.

/**
 * {@inheritDoc}
 */
@Override
public void onKnobTouch(final int index, final boolean isTouched) {
    if (isTouched && this.surface.isDeletePressed()) {
        this.surface.setTriggerConsumed(ButtonID.DELETE);
        final MaschineConfiguration configuration = this.surface.getConfiguration();
        switch(index) {
            case 0:
            case 1:
                configuration.setNoteRepeatPeriod(Resolution.values()[4]);
                break;
            case 2:
            case 3:
                if (this.host.supports(Capability.NOTE_REPEAT_LENGTH))
                    configuration.setNoteRepeatLength(Resolution.values()[4]);
                break;
            case 4:
            case 5:
                if (this.host.supports(Capability.NOTE_REPEAT_MODE))
                    this.noteRepeat.setMode(ArpeggiatorMode.UP);
                break;
            case 6:
            case 7:
                if (this.host.supports(Capability.NOTE_REPEAT_OCTAVES))
                    this.noteRepeat.setOctaves(1);
                break;
            default:
                // Unused
                break;
        }
    }
}
Also used : MaschineConfiguration(de.mossgrabers.controller.ni.maschine.mk3.MaschineConfiguration)

Aggregations

MaschineConfiguration (de.mossgrabers.controller.ni.maschine.mk3.MaschineConfiguration)10 RibbonMode (de.mossgrabers.controller.ni.maschine.core.RibbonMode)3 TouchstripCommand (de.mossgrabers.controller.ni.maschine.mk3.command.continuous.TouchstripCommand)2 MaschineControlSurface (de.mossgrabers.controller.ni.maschine.mk3.controller.MaschineControlSurface)2 StudioEncoderModeManager (de.mossgrabers.controller.ni.maschine.mk3.controller.StudioEncoderModeManager)2 IHost (de.mossgrabers.framework.daw.IHost)2 ITrack (de.mossgrabers.framework.daw.data.ITrack)2 ModeManager (de.mossgrabers.framework.featuregroup.ModeManager)2 ViewManager (de.mossgrabers.framework.featuregroup.ViewManager)2 MaschineMonitorEncoderCommand (de.mossgrabers.controller.ni.maschine.core.command.trigger.MaschineMonitorEncoderCommand)1 MainKnobRowModeCommand (de.mossgrabers.controller.ni.maschine.mk3.command.continuous.MainKnobRowModeCommand)1 AddDeviceCommand (de.mossgrabers.controller.ni.maschine.mk3.command.trigger.AddDeviceCommand)1 KeyboardCommand (de.mossgrabers.controller.ni.maschine.mk3.command.trigger.KeyboardCommand)1 MaschineSelectButtonCommand (de.mossgrabers.controller.ni.maschine.mk3.command.trigger.MaschineSelectButtonCommand)1 MaschineStopCommand (de.mossgrabers.controller.ni.maschine.mk3.command.trigger.MaschineStopCommand)1 PadModeCommand (de.mossgrabers.controller.ni.maschine.mk3.command.trigger.PadModeCommand)1 ProjectButtonCommand (de.mossgrabers.controller.ni.maschine.mk3.command.trigger.ProjectButtonCommand)1 RibbonCommand (de.mossgrabers.controller.ni.maschine.mk3.command.trigger.RibbonCommand)1 SwingCommand (de.mossgrabers.controller.ni.maschine.mk3.command.trigger.SwingCommand)1 TempoCommand (de.mossgrabers.controller.ni.maschine.mk3.command.trigger.TempoCommand)1