Search in sources :

Example 6 with StepState

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

the class SequencerView method drawGrid.

/**
 * {@inheritDoc}
 */
@Override
public void drawGrid() {
    final IPadGrid padGrid = this.surface.getPadGrid();
    if (!this.model.canSelectedTrackHoldNotes()) {
        padGrid.turnOff();
        return;
    }
    if (this.isPlayMode) {
        for (int i = 36; i < 52; i++) {
            padGrid.light(i, this.keyManager.isKeyPressed(i) || this.selectedPad == i - 36 ? BeatstepColorManager.BEATSTEP_BUTTON_STATE_PINK : this.colorManager.getColorIndex(this.keyManager.getColor(i)));
        }
    } else {
        final INoteClip clip = this.getClip();
        // Paint the sequencer steps
        final int step = clip.getCurrentStep();
        final int hiStep = this.isInXRange(step) ? step % SequencerView.NUM_DISPLAY_COLS : -1;
        final int editMidiChannel = this.configuration.getMidiEditChannel();
        for (int col = 0; col < SequencerView.NUM_DISPLAY_COLS; col++) {
            final int y = this.offsetY + this.selectedPad;
            final int map = this.scales.getNoteMatrix()[y];
            final StepState stepState = clip.getStep(editMidiChannel, col, map).getState();
            padGrid.lightEx(col % 8, 1 - col / 8, getSequencerColor(stepState, col == hiStep));
        }
    }
}
Also used : IPadGrid(de.mossgrabers.framework.controller.grid.IPadGrid) StepState(de.mossgrabers.framework.daw.StepState) INoteClip(de.mossgrabers.framework.daw.INoteClip)

Example 7 with StepState

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

the class AbstractPolySequencerView 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
 * @return True if handled
 */
protected boolean handleSequencerAreaButtonCombinations(final INoteClip clip, final int channel, final int step) {
    // Handle note duplicate function
    if (this.isButtonCombination(ButtonID.DUPLICATE)) {
        if (this.getStep(clip, step).getState() == StepState.START)
            this.copyStep = step;
        else if (this.copyStep >= 0) {
            for (int row = 0; row < 128; row++) {
                final IStepInfo stepInfo = clip.getStep(channel, this.copyStep, row);
                if (stepInfo != null && stepInfo.getVelocity() > 0)
                    clip.setStep(channel, step, row, stepInfo);
            }
        }
        return true;
    }
    if (this.isButtonCombination(ButtonID.MUTE)) {
        for (int note = 0; note < 128; note++) {
            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 = step - 1; s >= 0; s--) {
        final int x = s % this.numColumns;
        final int y = this.numRows - 1 - s / this.numColumns;
        final int pad = y * this.numColumns + x;
        final IHwButton button = this.surface.getButton(ButtonID.get(ButtonID.PAD1, pad));
        if (button.isLongPressed()) {
            button.setConsumed();
            final int length = step - s + 1;
            final double duration = length * Resolution.getValueAt(this.getResolutionIndex());
            // Create new note(s)
            if (this.getStep(clip, s).getState() != StepState.START) {
                for (int row = 0; row < 128; row++) {
                    final Integer k = Integer.valueOf(row);
                    if (this.noteMemory.containsKey(k)) {
                        final Integer vel = this.noteMemory.get(k);
                        clip.setStep(channel, s, row, this.configuration.isAccentActive() ? this.configuration.getFixedAccentValue() : vel.intValue(), duration);
                    }
                }
                return true;
            }
            // Change length of existing notes
            for (int row = 0; row < 128; row++) {
                final IStepInfo stepInfo = clip.getStep(channel, s, row);
                if (stepInfo != null && stepInfo.getState() == StepState.START)
                    clip.updateStepDuration(channel, s, row, 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 8 with StepState

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

the class AbstractPolySequencerView method getStep.

/**
 * Check if any note is set at the current step.
 *
 * @param clip The clip which contains the notes
 * @param col The column/step to check
 * @return The aggregated about the step aggregated from all notes at that step
 */
protected IStepInfo getStep(final INoteClip clip, final int col) {
    final DefaultStepInfo result = new DefaultStepInfo();
    boolean isMuted = true;
    final int editMidiChannel = this.configuration.getMidiEditChannel();
    for (int row = 0; row < 128; row++) {
        final IStepInfo stepInfo = clip.getStep(editMidiChannel, col, row);
        final StepState r = stepInfo.getState();
        if (r == StepState.START)
            result.setState(StepState.START);
        else if (r == StepState.CONTINUE && result.getState() != StepState.START)
            result.setState(StepState.CONTINUE);
        if ((r == StepState.START || r == StepState.CONTINUE) && !stepInfo.isMuted())
            isMuted = false;
    }
    result.setMuted(isMuted);
    return result;
}
Also used : DefaultStepInfo(de.mossgrabers.framework.daw.DefaultStepInfo) StepState(de.mossgrabers.framework.daw.StepState) IStepInfo(de.mossgrabers.framework.daw.IStepInfo)

Example 9 with StepState

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

the class AbstractDrumLaneView method handleNoteAreaButtonCombinations.

/**
 * Handle button combinations on the note area of the sequencer.
 *
 * @param clip The sequenced MIDI clip
 * @param channel The MIDI channel of the note
 * @param row The row in the current page in the clip
 * @param note The note in the current page of the pad in the clip
 * @param step The step in the current page in the clip
 * @param velocity The velocity
 * @param accentVelocity The velocity or accent value
 * @return True if handled
 */
protected boolean handleNoteAreaButtonCombinations(final INoteClip clip, final int channel, final int step, final int row, final int note, final int velocity, final int accentVelocity) {
    // Handle note duplicate function
    if (this.isButtonCombination(ButtonID.DUPLICATE)) {
        if (velocity == 0) {
            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)) {
        if (velocity == 0) {
            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
    final int laneOffset = (this.allRows - row - 1) / this.lanes * this.numColumns;
    final int offset = row * this.numColumns;
    for (int s = 0; s < step; s++) {
        final IHwButton button = this.surface.getButton(ButtonID.get(ButtonID.PAD1, offset + s));
        if (button.isLongPressed()) {
            final int start = s + laneOffset;
            button.setConsumed();
            final int length = step - start + 1;
            final double duration = length * Resolution.getValueAt(this.getResolutionIndex());
            final StepState state = note < 0 ? StepState.OFF : clip.getStep(channel, start, note).getState();
            if (state == StepState.START)
                clip.updateStepDuration(channel, start, note, duration);
            else
                clip.setStep(channel, start, note, accentVelocity, 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 10 with StepState

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

the class AbstractNoteSequencerView method handleSequencerAreaButtonCombinations.

/**
 * Handle button combinations on the note area of the sequencer.
 *
 * @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 row The row 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 row, 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
    final int offset = row * clip.getNumSteps();
    for (int s = 0; s < step; s++) {
        final IHwButton button = this.surface.getButton(ButtonID.get(ButtonID.PAD1, offset + s));
        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)

Aggregations

StepState (de.mossgrabers.framework.daw.StepState)13 IStepInfo (de.mossgrabers.framework.daw.IStepInfo)7 INoteClip (de.mossgrabers.framework.daw.INoteClip)6 IHwButton (de.mossgrabers.framework.controller.hardware.IHwButton)4 ModeManager (de.mossgrabers.framework.featuregroup.ModeManager)4 NoteMode (de.mossgrabers.controller.akai.apc.mode.NoteMode)2 IPadGrid (de.mossgrabers.framework.controller.grid.IPadGrid)2 ColorEx (de.mossgrabers.framework.controller.color.ColorEx)1 DefaultStepInfo (de.mossgrabers.framework.daw.DefaultStepInfo)1 IDrumDevice (de.mossgrabers.framework.daw.data.IDrumDevice)1 IGraphicsConfiguration (de.mossgrabers.framework.graphics.IGraphicsConfiguration)1 IGraphicsContext (de.mossgrabers.framework.graphics.IGraphicsContext)1