Search in sources :

Example 41 with INoteClip

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

the class PlayView method drawDrumGrid.

/**
 * 'Draw' the drum grid sequencer.
 *
 * @param buttonIDOrdinal The ordinal number of the button
 * @return The color for the step
 */
public int drawDrumGrid(final int buttonIDOrdinal) {
    final boolean isRow3 = buttonIDOrdinal >= ButtonID.ROW3_1.ordinal() && buttonIDOrdinal <= ButtonID.ROW3_8.ordinal();
    final int index = isRow3 ? buttonIDOrdinal - ButtonID.ROW3_1.ordinal() : buttonIDOrdinal - ButtonID.ROW4_1.ordinal();
    final int x = index;
    final int y;
    if (this.isPlayMode)
        y = isRow3 ? 1 : 0;
    else
        y = isRow3 ? 0 : 1;
    final int col = 8 * y + x;
    if (this.isPlayMode)
        return this.getDrumPadColor(col);
    if (!this.isActive())
        return SLControlSurface.MKII_BUTTON_STATE_OFF;
    final INoteClip clip = this.getClip();
    final boolean exists = clip.doesExist();
    // Paint the sequencer steps
    final int step = clip.getCurrentStep();
    final int hiStep = this.isInXRange(step) ? step % PlayView.NUM_DISPLAY_COLS : -1;
    final int offsetY = this.scales.getDrumOffset();
    final int editMidiChannel = this.configuration.getMidiEditChannel();
    if (col >= PlayView.NUM_DISPLAY_COLS)
        return SLControlSurface.MKII_BUTTON_STATE_OFF;
    final StepState isSet = clip.getStep(editMidiChannel, col, offsetY + this.selectedPad).getState();
    final boolean hilite = col == hiStep;
    return exists && (isSet != StepState.OFF || hilite) ? SLControlSurface.MKII_BUTTON_STATE_ON : SLControlSurface.MKII_BUTTON_STATE_OFF;
}
Also used : StepState(de.mossgrabers.framework.daw.StepState) INoteClip(de.mossgrabers.framework.daw.INoteClip)

Aggregations

INoteClip (de.mossgrabers.framework.daw.INoteClip)41 IPadGrid (de.mossgrabers.framework.controller.grid.IPadGrid)13 IStepInfo (de.mossgrabers.framework.daw.IStepInfo)6 StepState (de.mossgrabers.framework.daw.StepState)6 GridStep (de.mossgrabers.framework.daw.data.GridStep)6 IDrumDevice (de.mossgrabers.framework.daw.data.IDrumDevice)6 ColorEx (de.mossgrabers.framework.controller.color.ColorEx)5 ITrack (de.mossgrabers.framework.daw.data.ITrack)3 ModeManager (de.mossgrabers.framework.featuregroup.ModeManager)3 NoteMode (de.mossgrabers.controller.akai.apc.mode.NoteMode)2 UnknownCommandException (de.mossgrabers.controller.osc.exception.UnknownCommandException)1 ICursorTrack (de.mossgrabers.framework.daw.data.ICursorTrack)1 ISlot (de.mossgrabers.framework.daw.data.ISlot)1 ISlotBank (de.mossgrabers.framework.daw.data.bank.ISlotBank)1