Search in sources :

Example 1 with INoteRepeat

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

the class TouchstripCommand method onPitchbend.

/**
 * {@inheritDoc}
 */
@Override
public void onPitchbend(final int data1, final int data2) {
    if (this.surface.getViewManager().isActive(Views.SESSION)) {
        final int value = this.surface.isShiftPressed() ? 63 : data2;
        this.model.getTransport().setCrossfade(this.model.getValueChanger().toDAWValue(value));
        this.surface.setRibbonValue(value);
        return;
    }
    // Don't get in the way of configuration
    if (this.surface.isShiftPressed())
        return;
    final PushConfiguration config = this.surface.getConfiguration();
    final double scaled = data2 / 127.0;
    // Check if Note Repeat is active and its settings should be changed
    final int ribbonNoteRepeat = config.getRibbonNoteRepeat();
    if (config.isNoteRepeatActive() && ribbonNoteRepeat > PushConfiguration.NOTE_REPEAT_OFF) {
        final Resolution[] values = Resolution.values();
        final int index = (int) Math.round(scaled * (values.length - 1));
        final double value = values[values.length - 1 - index].getValue();
        final INoteRepeat noteRepeat = this.surface.getMidiInput().getDefaultNoteInput().getNoteRepeat();
        if (ribbonNoteRepeat == PushConfiguration.NOTE_REPEAT_PERIOD)
            noteRepeat.setPeriod(value);
        else
            noteRepeat.setNoteLength(value);
        return;
    }
    switch(config.getRibbonMode()) {
        case PushConfiguration.RIBBON_MODE_PITCH:
            this.surface.sendMidiEvent(0xE0, data1, data2);
            break;
        case PushConfiguration.RIBBON_MODE_CC:
            this.surface.sendMidiEvent(0xB0, config.getRibbonModeCCVal(), data2);
            this.pitchValue = data2;
            break;
        case PushConfiguration.RIBBON_MODE_CC_PB:
            if (data2 > 64)
                this.surface.sendMidiEvent(0xE0, data1, data2);
            else if (data2 < 64)
                this.surface.sendMidiEvent(0xB0, config.getRibbonModeCCVal(), 127 - data2 * 2);
            else {
                this.surface.sendMidiEvent(0xE0, data1, data2);
                this.surface.sendMidiEvent(0xB0, config.getRibbonModeCCVal(), 0);
            }
            break;
        case PushConfiguration.RIBBON_MODE_PB_CC:
            if (data2 > 64)
                this.surface.sendMidiEvent(0xB0, config.getRibbonModeCCVal(), (data2 - 64) * 2);
            else if (data2 < 64)
                this.surface.sendMidiEvent(0xE0, data1, data2);
            else {
                this.surface.sendMidiEvent(0xE0, data1, data2);
                this.surface.sendMidiEvent(0xB0, config.getRibbonModeCCVal(), 0);
            }
            break;
        case PushConfiguration.RIBBON_MODE_FADER:
            this.model.getCursorTrack().setVolume(this.model.getValueChanger().toDAWValue(data2));
            return;
        default:
            // Not used
            break;
    }
    this.surface.getMidiOutput().sendPitchbend(data1, data2);
}
Also used : PushConfiguration(de.mossgrabers.controller.ableton.push.PushConfiguration) INoteRepeat(de.mossgrabers.framework.daw.midi.INoteRepeat) Resolution(de.mossgrabers.framework.daw.constants.Resolution)

Example 2 with INoteRepeat

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

the class DrumView method getButtonColor.

/**
 * {@inheritDoc}
 */
@Override
public int getButtonColor(final ButtonID buttonID) {
    final int ordinal = buttonID.ordinal();
    if (ordinal < ButtonID.SCENE1.ordinal() || ordinal > ButtonID.SCENE8.ordinal())
        return 0;
    final int scene = ordinal - ButtonID.SCENE1.ordinal();
    if (ButtonID.isSceneButton(buttonID)) {
        final INoteRepeat noteRepeat = this.surface.getMidiInput().getDefaultNoteInput().getNoteRepeat();
        if (this.noteRepeatPeriodOn) {
            final int periodIndex = Resolution.getMatch(noteRepeat.getPeriod());
            return buttonID == ButtonID.get(ButtonID.SCENE1, 7 - periodIndex) ? LaunchpadColorManager.LAUNCHPAD_COLOR_PINK_HI : LaunchpadColorManager.LAUNCHPAD_COLOR_SKY_LO;
        }
        if (this.noteRepeatLengthOn) {
            final int lengthIndex = Resolution.getMatch(noteRepeat.getNoteLength());
            return buttonID == ButtonID.get(ButtonID.SCENE1, 7 - lengthIndex) ? LaunchpadColorManager.LAUNCHPAD_COLOR_SKY_HI : LaunchpadColorManager.LAUNCHPAD_COLOR_PINK_LO;
        }
    }
    if (!this.isActive())
        return LaunchpadColorManager.LAUNCHPAD_COLOR_BLACK;
    return scene == 7 - this.selectedResolutionIndex ? LaunchpadColorManager.LAUNCHPAD_COLOR_YELLOW : LaunchpadColorManager.LAUNCHPAD_COLOR_GREEN;
}
Also used : INoteRepeat(de.mossgrabers.framework.daw.midi.INoteRepeat)

Example 3 with INoteRepeat

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

the class DrumView method drawPages.

/**
 * {@inheritDoc}
 */
@Override
protected void drawPages(final INoteClip clip, final boolean isActive) {
    super.drawPages(clip, isActive);
    // Draw the extra buttons
    final IPadGrid padGrid = this.surface.getPadGrid();
    if (this.extraButtonsOn) {
        padGrid.lightEx(4, 6, this.isSelectTrigger() ? LaunchpadColorManager.LAUNCHPAD_COLOR_WHITE : LaunchpadColorManager.LAUNCHPAD_COLOR_GREY_LO);
        padGrid.lightEx(5, 6, this.isMuteTrigger() ? LaunchpadColorManager.LAUNCHPAD_COLOR_YELLOW_HI : LaunchpadColorManager.LAUNCHPAD_COLOR_YELLOW_LO);
        padGrid.lightEx(6, 6, this.isSoloTrigger() ? LaunchpadColorManager.LAUNCHPAD_COLOR_BLUE_HI : LaunchpadColorManager.LAUNCHPAD_COLOR_BLUE_LO);
        padGrid.lightEx(7, 6, this.isBrowseTrigger() ? LaunchpadColorManager.LAUNCHPAD_COLOR_CYAN_HI : LaunchpadColorManager.LAUNCHPAD_COLOR_CYAN_LO);
        final INoteRepeat noteRepeat = this.surface.getMidiInput().getDefaultNoteInput().getNoteRepeat();
        padGrid.lightEx(4, 7, noteRepeat.isActive() ? LaunchpadColorManager.LAUNCHPAD_COLOR_ORCHID_HI : LaunchpadColorManager.LAUNCHPAD_COLOR_ORCHID_LO);
        padGrid.lightEx(5, 7, this.noteRepeatPeriodOn ? LaunchpadColorManager.LAUNCHPAD_COLOR_SKY_HI : LaunchpadColorManager.LAUNCHPAD_COLOR_SKY_LO);
        padGrid.lightEx(6, 7, this.noteRepeatLengthOn ? LaunchpadColorManager.LAUNCHPAD_COLOR_PINK_HI : LaunchpadColorManager.LAUNCHPAD_COLOR_PINK_LO);
    }
    padGrid.lightEx(7, 7, this.extraButtonsOn ? LaunchpadColorManager.LAUNCHPAD_COLOR_RED_HI : LaunchpadColorManager.LAUNCHPAD_COLOR_RED_LO);
}
Also used : IPadGrid(de.mossgrabers.framework.controller.grid.IPadGrid) INoteRepeat(de.mossgrabers.framework.daw.midi.INoteRepeat)

Example 4 with INoteRepeat

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

the class NoteRepeatSceneHelper method handleNoteRepeatSelection.

/**
 * Handle the note repeat selection (period and note length).
 *
 * @param surface The surface
 * @param sceneIndex The index of the scene
 */
public static void handleNoteRepeatSelection(final PushControlSurface surface, final int sceneIndex) {
    surface.setTriggerConsumed(ButtonID.REPEAT);
    final INoteRepeat noteRepeat = surface.getMidiInput().getDefaultNoteInput().getNoteRepeat();
    if (surface.isShiftPressed())
        noteRepeat.setNoteLength(Resolution.getValueAt(sceneIndex));
    else
        noteRepeat.setPeriod(Resolution.getValueAt(sceneIndex));
}
Also used : INoteRepeat(de.mossgrabers.framework.daw.midi.INoteRepeat)

Example 5 with INoteRepeat

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

the class TouchstripCommand method updateValue.

/**
 * Update the LED value of the ribbon strip.
 */
public void updateValue() {
    final RibbonMode ribbonMode = this.surface.getConfiguration().getRibbonMode();
    switch(ribbonMode) {
        case PITCH_DOWN:
        case PITCH_UP:
        case PITCH_DOWN_UP:
        case CC_1:
        case CC_11:
            this.surface.setRibbonValue(this.ribbonValue);
            break;
        case MASTER_VOLUME:
            final ITrack t = this.model.getMasterTrack();
            this.surface.setRibbonValue(t == null ? 0 : this.model.getValueChanger().toMidiValue(t.getVolume()));
            break;
        case NOTE_REPEAT_PERIOD:
        case NOTE_REPEAT_LENGTH:
            final Resolution[] values = Resolution.values();
            final INoteRepeat noteRepeat = this.surface.getMidiInput().getDefaultNoteInput().getNoteRepeat();
            final double value = ribbonMode == RibbonMode.NOTE_REPEAT_PERIOD ? noteRepeat.getPeriod() : noteRepeat.getNoteLength();
            final int index = Resolution.getMatch(value);
            this.surface.setRibbonValue((int) Math.round(index * 127.0 / (values.length - 1)));
            break;
        default:
            // Not used
            break;
    }
}
Also used : RibbonMode(de.mossgrabers.controller.ni.maschine.core.RibbonMode) ITrack(de.mossgrabers.framework.daw.data.ITrack) INoteRepeat(de.mossgrabers.framework.daw.midi.INoteRepeat) Resolution(de.mossgrabers.framework.daw.constants.Resolution)

Aggregations

INoteRepeat (de.mossgrabers.framework.daw.midi.INoteRepeat)14 Resolution (de.mossgrabers.framework.daw.constants.Resolution)5 INoteInput (de.mossgrabers.framework.daw.midi.INoteInput)4 IPadGrid (de.mossgrabers.framework.controller.grid.IPadGrid)3 PushConfiguration (de.mossgrabers.controller.ableton.push.PushConfiguration)2 RibbonMode (de.mossgrabers.controller.ni.maschine.core.RibbonMode)2 ITrack (de.mossgrabers.framework.daw.data.ITrack)2 GenericFlexiConfiguration (de.mossgrabers.controller.generic.GenericFlexiConfiguration)1 MaschineConfiguration (de.mossgrabers.controller.ni.maschine.mk3.MaschineConfiguration)1 LaunchpadConfiguration (de.mossgrabers.controller.novation.launchpad.LaunchpadConfiguration)1 IllegalParameterException (de.mossgrabers.controller.osc.exception.IllegalParameterException)1 UnknownCommandException (de.mossgrabers.controller.osc.exception.UnknownCommandException)1 IHost (de.mossgrabers.framework.daw.IHost)1 ITransport (de.mossgrabers.framework.daw.ITransport)1 ArpeggiatorMode (de.mossgrabers.framework.daw.midi.ArpeggiatorMode)1