Search in sources :

Example 11 with IStepInfo

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

the class NoteMode method onButton.

/**
 * {@inheritDoc}
 */
@Override
public void onButton(final int row, final int index, final ButtonEvent event) {
    if (event != ButtonEvent.UP)
        return;
    for (final GridStep noteInfo : this.notes) {
        final int channel = noteInfo.channel();
        final int step = noteInfo.step();
        final int note = noteInfo.note();
        final IStepInfo stepInfo = this.clip.getStep(channel, step, note);
        switch(this.page) {
            case NOTE:
                switch(index) {
                    case 1:
                        if (this.host.supports(Capability.NOTE_EDIT_EXPRESSIONS))
                            this.page = Page.EXPRESSIONS;
                        break;
                    case 2:
                        if (this.host.supports(Capability.NOTE_EDIT_REPEAT))
                            this.page = Page.REPEAT;
                        break;
                    case 3:
                        if (this.host.supports(Capability.NOTE_EDIT_RECCURRENCE))
                            this.page = Page.RECCURRENCE_PATTERN;
                        break;
                    case 5:
                        if (this.host.supports(Capability.NOTE_EDIT_CHANCE))
                            this.clip.updateIsChanceEnabled(channel, step, note, !stepInfo.isChanceEnabled());
                        break;
                    case 6:
                        if (this.host.supports(Capability.NOTE_EDIT_OCCURRENCE))
                            this.clip.updateIsOccurrenceEnabled(channel, step, note, !stepInfo.isOccurrenceEnabled());
                        break;
                    case 7:
                        if (this.host.supports(Capability.NOTE_EDIT_RECCURRENCE))
                            this.clip.updateIsRecurrenceEnabled(channel, step, note, !stepInfo.isRecurrenceEnabled());
                        break;
                    default:
                        return;
                }
                break;
            case EXPRESSIONS:
                switch(index) {
                    case 0:
                        this.page = Page.NOTE;
                        break;
                    case 2:
                        this.page = Page.REPEAT;
                        break;
                    case 3:
                        this.page = Page.RECCURRENCE_PATTERN;
                        break;
                    default:
                        return;
                }
                break;
            case REPEAT:
                switch(index) {
                    case 0:
                        this.page = Page.NOTE;
                        break;
                    case 1:
                        this.page = Page.EXPRESSIONS;
                        break;
                    case 3:
                        this.page = Page.RECCURRENCE_PATTERN;
                        break;
                    case 4:
                        if (this.host.supports(Capability.NOTE_EDIT_REPEAT))
                            this.clip.updateIsRepeatEnabled(channel, step, note, !stepInfo.isRepeatEnabled());
                        break;
                    default:
                        return;
                }
                break;
            case RECCURRENCE_PATTERN:
                switch(index) {
                    case 0:
                        this.page = Page.NOTE;
                        break;
                    case 1:
                        this.page = Page.EXPRESSIONS;
                        break;
                    case 2:
                        this.page = Page.REPEAT;
                        break;
                    case 3:
                        this.page = Page.RECCURRENCE_PATTERN;
                        break;
                    default:
                        return;
                }
                break;
        }
    }
}
Also used : GridStep(de.mossgrabers.framework.daw.data.GridStep) IStepInfo(de.mossgrabers.framework.daw.IStepInfo)

Example 12 with IStepInfo

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

the class NoteMode method getKnobValue.

/**
 * {@inheritDoc}
 */
@Override
public int getKnobValue(final int index) {
    if (this.notes.isEmpty())
        return 0;
    final IValueChanger valueChanger = this.model.getValueChanger();
    final GridStep noteInfo = this.notes.get(0);
    final int channel = noteInfo.channel();
    final int step = noteInfo.step();
    final int note = noteInfo.note();
    final IStepInfo stepInfo = this.clip.getStep(channel, step, note);
    switch(this.page) {
        case NOTE:
            switch(index) {
                case 2:
                    return valueChanger.fromNormalizedValue(stepInfo.getVelocity());
                case 3:
                    if (this.host.supports(Capability.NOTE_EDIT_VELOCITY_SPREAD))
                        return valueChanger.fromNormalizedValue(stepInfo.getVelocitySpread());
                    break;
                case 4:
                    if (this.host.supports(Capability.NOTE_EDIT_RELEASE_VELOCITY))
                        return valueChanger.fromNormalizedValue(stepInfo.getReleaseVelocity());
                    break;
                case 5:
                    if (this.host.supports(Capability.NOTE_EDIT_CHANCE))
                        return valueChanger.fromNormalizedValue(stepInfo.getChance());
                    break;
                case 6:
                    if (this.host.supports(Capability.NOTE_EDIT_OCCURRENCE))
                        return 0;
                    break;
                case 7:
                    if (this.host.supports(Capability.NOTE_EDIT_RECCURRENCE))
                        return (stepInfo.getRecurrenceLength() - 1) * (this.model.getValueChanger().getUpperBound() - 1) / 7;
                    break;
                default:
                    return 0;
            }
            break;
        case EXPRESSIONS:
            switch(index) {
                case 3:
                    if (this.host.supports(Capability.NOTE_EDIT_EXPRESSIONS))
                        return Math.min(valueChanger.getUpperBound() - 1, valueChanger.fromNormalizedValue(stepInfo.getGain()));
                    break;
                case 4:
                    if (this.host.supports(Capability.NOTE_EDIT_EXPRESSIONS))
                        return valueChanger.fromNormalizedValue((stepInfo.getPan() + 1.0) / 2.0);
                    break;
                case 5:
                    if (this.host.supports(Capability.NOTE_EDIT_EXPRESSIONS))
                        return valueChanger.fromNormalizedValue((stepInfo.getTranspose() + 24.0) / 48.0);
                    break;
                case 6:
                    if (this.host.supports(Capability.NOTE_EDIT_EXPRESSIONS))
                        return valueChanger.fromNormalizedValue((stepInfo.getTimbre() + 1.0) / 2.0);
                    break;
                case 7:
                    if (this.host.supports(Capability.NOTE_EDIT_EXPRESSIONS))
                        return valueChanger.fromNormalizedValue(stepInfo.getPressure());
                    break;
                default:
                    break;
            }
            break;
        case REPEAT:
            switch(index) {
                case 4:
                    if (this.host.supports(Capability.NOTE_EDIT_REPEAT))
                        return (stepInfo.getRepeatCount() + 127) * (this.model.getValueChanger().getUpperBound() - 1) / 254;
                    break;
                case 5:
                    if (this.host.supports(Capability.NOTE_EDIT_REPEAT))
                        return valueChanger.fromNormalizedValue((stepInfo.getRepeatCurve() + 1.0) / 2.0);
                    break;
                case 6:
                    if (this.host.supports(Capability.NOTE_EDIT_REPEAT))
                        return valueChanger.fromNormalizedValue((stepInfo.getRepeatVelocityCurve() + 1.0) / 2.0);
                    break;
                case 7:
                    if (this.host.supports(Capability.NOTE_EDIT_REPEAT))
                        return valueChanger.fromNormalizedValue((stepInfo.getRepeatVelocityEnd() + 1.0) / 2.0);
                    break;
                default:
                    break;
            }
            break;
        case RECCURRENCE_PATTERN:
            // None
            break;
    }
    return 0;
}
Also used : IValueChanger(de.mossgrabers.framework.controller.valuechanger.IValueChanger) GridStep(de.mossgrabers.framework.daw.data.GridStep) IStepInfo(de.mossgrabers.framework.daw.IStepInfo)

Example 13 with IStepInfo

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

the class AbstractNoteSequencerView method drawGrid.

/**
 * {@inheritDoc}
 */
@Override
public void drawGrid() {
    final IPadGrid gridPad = this.surface.getPadGrid();
    if (!this.isActive()) {
        gridPad.turnOff();
        return;
    }
    // Steps with notes
    final INoteClip clip = this.getClip();
    final int step = clip.getCurrentStep();
    final int hiStep = this.isInXRange(step) ? step % this.numDisplayCols : -1;
    final int editMidiChannel = this.configuration.getMidiEditChannel();
    final List<GridStep> editNotes = this.getEditNotes();
    for (int x = 0; x < this.numDisplayCols; x++) {
        for (int y = 0; y < this.numSequencerRows; y++) {
            final int map = this.keyManager.map(y);
            final IStepInfo stepInfo = map < 0 ? null : clip.getStep(editMidiChannel, x, map);
            gridPad.lightEx(x, this.numDisplayRows - 1 - y, this.getStepColor(stepInfo, x == hiStep, editMidiChannel, x, y, map, editNotes));
        }
    }
    if (this.numDisplayRows - this.numSequencerRows <= 0)
        return;
    // CLip Pages on the top
    final int lengthOfOnePad = this.getLengthOfOnePage(this.numDisplayCols);
    final double loopStart = clip.getLoopStart();
    final int loopStartPad = (int) Math.ceil(loopStart / lengthOfOnePad);
    final int loopEndPad = (int) Math.ceil((loopStart + clip.getLoopLength()) / lengthOfOnePad);
    final int currentPage = step / this.numDisplayCols;
    for (int pad = 0; pad < this.numDisplayCols; pad++) gridPad.lightEx(pad, 0, this.getPageColor(loopStartPad, loopEndPad, currentPage, clip.getEditPage(), pad));
}
Also used : IPadGrid(de.mossgrabers.framework.controller.grid.IPadGrid) GridStep(de.mossgrabers.framework.daw.data.GridStep) IStepInfo(de.mossgrabers.framework.daw.IStepInfo) INoteClip(de.mossgrabers.framework.daw.INoteClip)

Example 14 with IStepInfo

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

the class AbstractDrumView method handleSequencerAreaButtonCombinations.

/**
 * Handle button combinations in the sequencer area.
 *
 * @param clip The sequenced MIDI clip
 * @param channel The MIDI channel of the note
 * @param step The step in the current page in the clip
 * @param note The note in the current page of the pad in the clip
 * @param velocity The velocity
 * @return True if handled
 */
protected boolean handleSequencerAreaButtonCombinations(final INoteClip clip, final int channel, final int step, final int note, final int velocity) {
    // Handle note duplicate function
    if (this.isButtonCombination(ButtonID.DUPLICATE)) {
        final IStepInfo noteStep = clip.getStep(channel, step, note);
        if (noteStep.getState() == StepState.START)
            this.copyNote = noteStep;
        else if (this.copyNote != null)
            clip.setStep(channel, step, note, this.copyNote);
        return true;
    }
    if (this.isButtonCombination(ButtonID.MUTE)) {
        final IStepInfo stepInfo = clip.getStep(channel, step, note);
        final StepState isSet = stepInfo.getState();
        if (isSet == StepState.START)
            this.getClip().updateMuteState(channel, step, note, !stepInfo.isMuted());
        return true;
    }
    // Change length of a note or create a new one with a length
    for (int s = 0; s < step; s++) {
        final int pad = this.getPadIndex(s);
        final IHwButton button = this.surface.getButton(ButtonID.get(this.firstPad, pad));
        if (button.isLongPressed()) {
            button.setConsumed();
            final int length = step - s + 1;
            final double duration = length * Resolution.getValueAt(this.getResolutionIndex());
            final StepState state = note < 0 ? StepState.OFF : clip.getStep(channel, s, note).getState();
            if (state == StepState.START)
                clip.updateStepDuration(channel, s, note, duration);
            else
                clip.setStep(channel, s, note, velocity, duration);
            return true;
        }
    }
    return false;
}
Also used : StepState(de.mossgrabers.framework.daw.StepState) IStepInfo(de.mossgrabers.framework.daw.IStepInfo) IHwButton(de.mossgrabers.framework.controller.hardware.IHwButton)

Example 15 with IStepInfo

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

the class NoteMode method getButtonColor.

/**
 * {@inheritDoc}
 */
@Override
public int getButtonColor(final ButtonID buttonID) {
    if (this.notes.isEmpty())
        return this.colorManager.getColorIndex(PushColorManager.PUSH_BLACK);
    for (final GridStep noteInfo : this.notes) {
        final int channel = noteInfo.channel();
        final int step = noteInfo.step();
        final int note = noteInfo.note();
        final IStepInfo stepInfo = this.clip.getStep(channel, step, note);
        int index = this.isButtonRow(0, buttonID);
        if (index >= 0) {
            switch(this.page) {
                case NOTE:
                    if (index == 5 && this.host.supports(Capability.NOTE_EDIT_CHANCE))
                        return this.colorManager.getColorIndex(stepInfo.isChanceEnabled() ? PushColorManager.PUSH_ORANGE_HI : PushColorManager.PUSH_ORANGE_LO);
                    if (index == 6 && this.host.supports(Capability.NOTE_EDIT_OCCURRENCE))
                        return this.colorManager.getColorIndex(stepInfo.isOccurrenceEnabled() ? PushColorManager.PUSH_ORANGE_HI : PushColorManager.PUSH_ORANGE_LO);
                    if (index == 7 && this.host.supports(Capability.NOTE_EDIT_RECCURRENCE))
                        return this.colorManager.getColorIndex(stepInfo.isRecurrenceEnabled() ? PushColorManager.PUSH_ORANGE_HI : PushColorManager.PUSH_ORANGE_LO);
                    break;
                case EXPRESSIONS:
                    break;
                case REPEAT:
                    if (index == 3)
                        return this.colorManager.getColorIndex(stepInfo.isRepeatEnabled() ? PushColorManager.PUSH_ORANGE_HI : PushColorManager.PUSH_ORANGE_LO);
                    break;
                case RECCURRENCE_PATTERN:
                    final int recurrenceLength = stepInfo.getRecurrenceLength();
                    final int mask = stepInfo.getRecurrenceMask();
                    final boolean isOn = (mask & 1 << index) > 0;
                    String color = PushColorManager.PUSH_BLACK;
                    if (index < recurrenceLength)
                        color = isOn ? PushColorManager.PUSH_ORANGE_HI : PushColorManager.PUSH_ORANGE_LO;
                    return this.colorManager.getColorIndex(color);
            }
            return this.colorManager.getColorIndex(PushColorManager.PUSH_BLACK);
        }
        index = this.isButtonRow(1, buttonID);
        if (index >= 0) {
            switch(this.page) {
                case NOTE:
                    if (index == 0)
                        return this.colorManager.getColorIndex(PushColorManager.PUSH_GREEN_2);
                    break;
                case EXPRESSIONS:
                    if (index == 1)
                        return this.colorManager.getColorIndex(PushColorManager.PUSH_GREEN_2);
                    break;
                case REPEAT:
                    if (index == 2)
                        return this.colorManager.getColorIndex(PushColorManager.PUSH_GREEN_2);
                    break;
                case RECCURRENCE_PATTERN:
                    if (index == 7)
                        return this.colorManager.getColorIndex(PushColorManager.PUSH_GREEN_2);
                    break;
            }
            if (index == 0 || index == 1 && this.host.supports(Capability.NOTE_EDIT_EXPRESSIONS))
                return this.colorManager.getColorIndex(PushColorManager.PUSH_GREY_LO_2);
            if (index == 2 && this.host.supports(Capability.NOTE_EDIT_REPEAT) || index == 7 && this.host.supports(Capability.NOTE_EDIT_RECCURRENCE))
                return this.colorManager.getColorIndex(PushColorManager.PUSH_GREY_LO_2);
            return this.colorManager.getColorIndex(PushColorManager.PUSH_BLACK_2);
        }
    }
    return this.colorManager.getColorIndex(PushColorManager.PUSH_BLACK);
}
Also used : GridStep(de.mossgrabers.framework.daw.data.GridStep) IStepInfo(de.mossgrabers.framework.daw.IStepInfo)

Aggregations

IStepInfo (de.mossgrabers.framework.daw.IStepInfo)41 GridStep (de.mossgrabers.framework.daw.data.GridStep)18 IPadGrid (de.mossgrabers.framework.controller.grid.IPadGrid)7 StepState (de.mossgrabers.framework.daw.StepState)7 ColorEx (de.mossgrabers.framework.controller.color.ColorEx)6 INoteClip (de.mossgrabers.framework.daw.INoteClip)6 IHwButton (de.mossgrabers.framework.controller.hardware.IHwButton)4 IValueChanger (de.mossgrabers.framework.controller.valuechanger.IValueChanger)3 IDrumDevice (de.mossgrabers.framework.daw.data.IDrumDevice)3 NoteOccurrenceType (de.mossgrabers.framework.daw.NoteOccurrenceType)2 NoteStep (com.bitwig.extension.controller.api.NoteStep)1 SLMkIIIDisplay (de.mossgrabers.controller.novation.slmkiii.controller.SLMkIIIDisplay)1 ITextDisplay (de.mossgrabers.framework.controller.display.ITextDisplay)1 DefaultStepInfo (de.mossgrabers.framework.daw.DefaultStepInfo)1 ITrack (de.mossgrabers.framework.daw.data.ITrack)1 ModeManager (de.mossgrabers.framework.featuregroup.ModeManager)1 IGraphicsConfiguration (de.mossgrabers.framework.graphics.IGraphicsConfiguration)1 IGraphicsContext (de.mossgrabers.framework.graphics.IGraphicsContext)1