Search in sources :

Example 11 with ColorEx

use of de.mossgrabers.framework.controller.color.ColorEx in project DrivenByMoss by git-moss.

the class NoteMode method updateDisplay2.

/**
 * {@inheritDoc}
 */
@Override
public void updateDisplay2(final IGraphicDisplay display) {
    if (this.notes.isEmpty()) {
        for (int i = 0; i < 8; i++) display.addOptionElement(i == 2 ? "Please select a note to edit..." : "", "", false, "", "", false, true);
        return;
    }
    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);
    final IValueChanger valueChanger = this.model.getValueChanger();
    if (this.page != Page.RECCURRENCE_PATTERN) {
        final int size = this.notes.size();
        final boolean isOneNote = size == 1;
        final String stepBottomMenu = isOneNote ? "Step: " + (step + 1) : "Notes: " + size;
        display.addParameterElementWithPlainMenu(MENU[0], this.page == Page.NOTE, stepBottomMenu, null, false, "Length", -1, this.formatLength(stepInfo.getDuration()), this.isKnobTouched[0], -1);
        final boolean hasExpressions = this.host.supports(Capability.NOTE_EDIT_EXPRESSIONS);
        final String topMenu = hasExpressions ? MENU[1] : " ";
        final boolean isTopMenuOn = hasExpressions && this.page == Page.EXPRESSIONS;
        final String bottomMenu = isOneNote ? Scales.formatNoteAndOctave(note, -3) : "*";
        if (this.host.supports(Capability.NOTE_EDIT_MUTE)) {
            final int value = stepInfo.isMuted() ? valueChanger.getUpperBound() : 0;
            display.addParameterElementWithPlainMenu(topMenu, isTopMenuOn, bottomMenu, null, false, "Is Muted?", value, stepInfo.isMuted() ? "Yes" : "No", this.isKnobTouched[1], value);
        } else
            display.addParameterElementWithPlainMenu(topMenu, isTopMenuOn, bottomMenu, null, false, null, -1, null, false, -1);
    }
    switch(this.page) {
        case NOTE:
            final double noteVelocity = stepInfo.getVelocity();
            final int parameterValue = valueChanger.fromNormalizedValue(noteVelocity);
            display.addParameterElementWithPlainMenu(this.host.supports(Capability.NOTE_EDIT_REPEAT) ? MENU[2] : " ", false, null, null, false, "Velocity", parameterValue, StringUtils.formatPercentage(noteVelocity), this.isKnobTouched[2], parameterValue);
            if (this.host.supports(Capability.NOTE_EDIT_VELOCITY_SPREAD)) {
                final double noteVelocitySpread = stepInfo.getVelocitySpread();
                final int parameterSpreadValue = valueChanger.fromNormalizedValue(noteVelocitySpread);
                display.addParameterElementWithPlainMenu(MENU[3], false, null, null, false, "Vel-Spread", parameterSpreadValue, StringUtils.formatPercentage(noteVelocitySpread), this.isKnobTouched[3], parameterSpreadValue);
            } else
                display.addEmptyElement(true);
            if (this.host.supports(Capability.NOTE_EDIT_RELEASE_VELOCITY)) {
                final double noteReleaseVelocity = stepInfo.getReleaseVelocity();
                final int parameterReleaseValue = valueChanger.fromNormalizedValue(noteReleaseVelocity);
                display.addParameterElementWithPlainMenu(MENU[4], false, null, null, false, "R-Velocity", parameterReleaseValue, StringUtils.formatPercentage(noteReleaseVelocity), this.isKnobTouched[4], parameterReleaseValue);
            } else
                display.addEmptyElement(true);
            if (this.host.supports(Capability.NOTE_EDIT_CHANCE)) {
                final double chance = stepInfo.getChance();
                final int chanceValue = valueChanger.fromNormalizedValue(chance);
                display.addParameterElementWithPlainMenu(MENU[5], false, stepInfo.isChanceEnabled() ? "On" : "Off", null, false, "Chance", chanceValue, StringUtils.formatPercentage(chance), this.isKnobTouched[5], chanceValue);
            } else
                display.addEmptyElement(true);
            if (this.host.supports(Capability.NOTE_EDIT_OCCURRENCE)) {
                final NoteOccurrenceType occurrence = stepInfo.getOccurrence();
                display.addParameterElementWithPlainMenu(MENU[6], false, stepInfo.isOccurrenceEnabled() ? "On" : "Off", null, false, "Occurrence", -1, StringUtils.optimizeName(occurrence.getName(), 9), this.isKnobTouched[6], -1);
            } else
                display.addEmptyElement(true);
            if (this.host.supports(Capability.NOTE_EDIT_RECCURRENCE)) {
                final int recurrence = stepInfo.getRecurrenceLength();
                final String recurrenceStr = recurrence < 2 ? "Off" : Integer.toString(recurrence);
                final int recurrenceVal = (recurrence - 1) * (this.model.getValueChanger().getUpperBound() - 1) / 7;
                display.addParameterElementWithPlainMenu(MENU[7], false, stepInfo.isRecurrenceEnabled() ? "On" : "Off", null, false, "Recurrence", recurrenceVal, recurrenceStr, this.isKnobTouched[7], recurrenceVal);
            } else
                display.addEmptyElement(true);
            break;
        case EXPRESSIONS:
            display.addParameterElementWithPlainMenu(MENU[2], false, null, null, false, null, -1, null, false, -1);
            final double noteGain = stepInfo.getGain();
            final int parameterGainValue = Math.min(1023, valueChanger.fromNormalizedValue(noteGain));
            display.addParameterElementWithPlainMenu(MENU[3], false, null, null, false, "Gain", parameterGainValue, StringUtils.formatPercentage(noteGain), this.isKnobTouched[3], parameterGainValue);
            final double notePan = stepInfo.getPan();
            final int parameterPanValue = valueChanger.fromNormalizedValue((notePan + 1.0) / 2.0);
            display.addParameterElementWithPlainMenu(MENU[4], false, null, null, false, "Pan", parameterPanValue, StringUtils.formatPercentage(notePan), this.isKnobTouched[4], parameterPanValue);
            final double noteTranspose = stepInfo.getTranspose();
            final int parameterTransposeValue = valueChanger.fromNormalizedValue((noteTranspose + 24.0) / 48.0);
            display.addParameterElementWithPlainMenu(MENU[5], false, null, null, false, "Pitch", parameterTransposeValue, String.format("%.1f", Double.valueOf(noteTranspose)), this.isKnobTouched[5], parameterTransposeValue);
            final double noteTimbre = stepInfo.getTimbre();
            final int parameterTimbreValue = valueChanger.fromNormalizedValue((noteTimbre + 1.0) / 2.0);
            display.addParameterElementWithPlainMenu(MENU[6], false, null, null, false, "Timbre", parameterTimbreValue, StringUtils.formatPercentage(noteTimbre), this.isKnobTouched[6], parameterTimbreValue);
            final double notePressure = stepInfo.getPressure();
            final int parameterPressureValue = valueChanger.fromNormalizedValue(notePressure);
            display.addParameterElementWithPlainMenu(MENU[7], this.page == Page.RECCURRENCE_PATTERN, null, null, false, "Pressure", parameterPressureValue, StringUtils.formatPercentage(notePressure), this.isKnobTouched[7], parameterPressureValue);
            break;
        case REPEAT:
            display.addParameterElementWithPlainMenu(MENU[2], true, null, null, false, null, -1, null, false, -1);
            final int repeatCount = stepInfo.getRepeatCount();
            final String repeatCountValue = stepInfo.getFormattedRepeatCount();
            final int rc = (repeatCount + 127) * (this.model.getValueChanger().getUpperBound() - 1) / 254;
            display.addParameterElementWithPlainMenu(MENU[3], false, stepInfo.isRepeatEnabled() ? "On" : "Off", null, false, "Count", rc, repeatCountValue, this.isKnobTouched[3], rc);
            final double repeatCurve = stepInfo.getRepeatCurve();
            final int repeatCurveValue = valueChanger.fromNormalizedValue((repeatCurve + 1.0) / 2.0);
            display.addParameterElementWithPlainMenu(MENU[4], false, null, null, false, "Curve", repeatCurveValue, StringUtils.formatPercentage(repeatCurve), this.isKnobTouched[4], repeatCurveValue);
            final double repeatVelocityCurve = stepInfo.getRepeatVelocityCurve();
            final int repeatVelocityCurveValue = valueChanger.fromNormalizedValue((repeatVelocityCurve + 1.0) / 2.0);
            display.addParameterElementWithPlainMenu(MENU[5], false, null, null, false, "Vel. Curve", repeatVelocityCurveValue, StringUtils.formatPercentage(repeatVelocityCurve), this.isKnobTouched[5], repeatVelocityCurveValue);
            final double repeatVelocityEnd = stepInfo.getRepeatVelocityEnd();
            final int repeatVelocityEndValue = valueChanger.fromNormalizedValue((repeatVelocityEnd + 1.0) / 2.0);
            display.addParameterElementWithPlainMenu(MENU[6], false, null, null, false, "Vel. End", repeatVelocityEndValue, StringUtils.formatPercentage(repeatVelocityEnd), this.isKnobTouched[6], repeatVelocityEndValue);
            display.addParameterElementWithPlainMenu(MENU[7], false, null, null, false, null, -1, null, false, -1);
            break;
        case RECCURRENCE_PATTERN:
            final int recurrenceLength = stepInfo.getRecurrenceLength();
            final int mask = stepInfo.getRecurrenceMask();
            for (int i = 0; i < 8; i++) {
                final boolean isOn = (mask & 1 << i) > 0;
                ColorEx color = ColorEx.BLACK;
                String label = "-";
                if (i < recurrenceLength) {
                    color = isOn ? ColorEx.ORANGE : null;
                    label = isOn ? "On" : "Off";
                }
                if (i == 7) {
                    final int recurrence = stepInfo.getRecurrenceLength();
                    final String recurrenceStr = recurrence < 2 ? "Off" : Integer.toString(recurrence);
                    final int recurrenceVal = (recurrence - 1) * (this.model.getValueChanger().getUpperBound() - 1) / 7;
                    display.addParameterElementWithPlainMenu(MENU[i], i == 7, label, color, false, "Recurrence", recurrenceVal, recurrenceStr, this.isKnobTouched[7], recurrenceVal);
                } else
                    display.addParameterElementWithPlainMenu(MENU[i], i == 7, label, color, false, null, -1, null, false, -1);
            }
            break;
    }
}
Also used : IValueChanger(de.mossgrabers.framework.controller.valuechanger.IValueChanger) ColorEx(de.mossgrabers.framework.controller.color.ColorEx) GridStep(de.mossgrabers.framework.daw.data.GridStep) IStepInfo(de.mossgrabers.framework.daw.IStepInfo) NoteOccurrenceType(de.mossgrabers.framework.daw.NoteOccurrenceType)

Example 12 with ColorEx

use of de.mossgrabers.framework.controller.color.ColorEx in project DrivenByMoss by git-moss.

the class DeviceChainsMode method updateDisplay2.

/**
 * {@inheritDoc}
 */
@Override
public void updateDisplay2(final IGraphicDisplay display) {
    final ICursorDevice cd = this.model.getCursorDevice();
    if (!this.checkExists2(display, cd))
        return;
    final String color = this.model.getCurrentTrackBank().getSelectedChannelColorEntry();
    final ColorEx bottomMenuColor = DAWColor.getColorEntry(color);
    final boolean hasPinning = this.model.getHost().supports(Capability.HAS_PINNING);
    final String[] slotChains = cd.getSlotChains();
    for (int i = 0; i < 8; i++) {
        final boolean isTopMenuOn = this.getTopMenuEnablement(cd, hasPinning, i);
        final String bottomMenu = i < slotChains.length ? slotChains[i] : "";
        final String bottomMenuIcon = "";
        final boolean isBottomMenuOn = i < slotChains.length;
        display.addParameterElement(this.hostMenu[i], isTopMenuOn, bottomMenu, bottomMenuIcon, bottomMenuColor, isBottomMenuOn, "", 0, "", false, -1);
    }
}
Also used : ColorEx(de.mossgrabers.framework.controller.color.ColorEx) ICursorDevice(de.mossgrabers.framework.daw.data.ICursorDevice)

Example 13 with ColorEx

use of de.mossgrabers.framework.controller.color.ColorEx in project DrivenByMoss by git-moss.

the class MarkerModule method flush.

/**
 * {@inheritDoc}
 */
@Override
public void flush(final boolean dump) {
    final IMarkerBank markerBank = this.model.getMarkerBank();
    for (int i = 0; i < markerBank.getPageSize(); i++) {
        final String markerAddress = "/marker/" + (i + 1) + "/";
        final IMarker marker = markerBank.getItem(i);
        this.writer.sendOSC(markerAddress + "exists", marker.doesExist(), dump);
        this.writer.sendOSC(markerAddress + TAG_NAME, marker.getName(), dump);
        final ColorEx color = marker.getColor();
        this.writer.sendOSCColor(markerAddress + "color", color.getRed(), color.getGreen(), color.getBlue(), dump);
    }
}
Also used : IMarkerBank(de.mossgrabers.framework.daw.data.bank.IMarkerBank) ColorEx(de.mossgrabers.framework.controller.color.ColorEx) IMarker(de.mossgrabers.framework.daw.data.IMarker)

Example 14 with ColorEx

use of de.mossgrabers.framework.controller.color.ColorEx in project DrivenByMoss by git-moss.

the class ColorView method onGridNote.

/**
 * {@inheritDoc}
 */
@Override
public void onGridNote(final int note, final int velocity) {
    if (velocity > 0)
        return;
    final int offset = this.page * this.pageSize;
    final int color = offset + note - 36;
    final DAWColor[] dawColors = DAWColor.values();
    if (color < dawColors.length) {
        final ColorEx entry = dawColors[color].getColor();
        switch(this.mode) {
            case MODE_TRACK:
                final ITrack cursorTrack = this.model.getCursorTrack();
                if (cursorTrack.doesExist())
                    cursorTrack.setColor(entry);
                else {
                    final IMasterTrack master = this.model.getMasterTrack();
                    if (master.isSelected())
                        master.setColor(entry);
                }
                break;
            case MODE_LAYER:
                final IBank<? extends ILayer> layerBank = this.getLayerBank();
                final Optional<?> selectedItem = layerBank.getSelectedItem();
                if (selectedItem.isPresent())
                    ((ILayer) selectedItem.get()).setColor(entry);
                break;
            case MODE_CLIP:
                final IClip clip = this.model.getCursorClip();
                if (clip.doesExist())
                    clip.setColor(entry);
                break;
        }
    }
    this.surface.getViewManager().restore();
}
Also used : ITrack(de.mossgrabers.framework.daw.data.ITrack) DAWColor(de.mossgrabers.framework.daw.DAWColor) ColorEx(de.mossgrabers.framework.controller.color.ColorEx) IClip(de.mossgrabers.framework.daw.IClip) IMasterTrack(de.mossgrabers.framework.daw.data.IMasterTrack)

Example 15 with ColorEx

use of de.mossgrabers.framework.controller.color.ColorEx in project DrivenByMoss by git-moss.

the class DrumView method drawGrid.

/**
 * {@inheritDoc}
 */
@Override
public void drawGrid() {
    final IPadGrid padGrid = this.surface.getPadGrid();
    final IDrumDevice primary = this.model.getDrumDevice();
    if (this.isPlayMode) {
        for (int y = 0; y < 2; y++) {
            for (int x = 0; x < 8; x++) {
                final int index = 8 * y + x;
                padGrid.lightEx(x, 1 - y, this.getDrumPadColor(index, primary, false));
            }
        }
        return;
    }
    if (!this.isActive()) {
        padGrid.turnOff();
        return;
    }
    // Paint the sequencer steps
    final INoteClip clip = this.getClip();
    final int step = clip.getCurrentStep();
    final int hiStep = this.isInXRange(step) ? step % this.sequencerSteps : -1;
    final int offsetY = this.scales.getDrumOffset();
    final int editMidiChannel = this.configuration.getMidiEditChannel();
    final int selPad = this.getSelectedPad();
    final List<GridStep> editNotes = this.getEditNotes();
    for (int col = 0; col < DrumView.NUM_DISPLAY_COLS; col++) {
        final int noteRow = offsetY + selPad;
        final IStepInfo stepInfo = clip.getStep(editMidiChannel, col, noteRow);
        final boolean hilite = col == hiStep;
        final int x = col % GRID_COLUMNS;
        final int y = col / GRID_COLUMNS;
        final Optional<ColorEx> rowColor = this.getPadColor(primary, this.selectedPad);
        padGrid.lightEx(x, y, this.getStepColor(stepInfo, hilite, rowColor, editMidiChannel, col, noteRow, editNotes));
    }
}
Also used : IPadGrid(de.mossgrabers.framework.controller.grid.IPadGrid) IDrumDevice(de.mossgrabers.framework.daw.data.IDrumDevice) ColorEx(de.mossgrabers.framework.controller.color.ColorEx) GridStep(de.mossgrabers.framework.daw.data.GridStep) IStepInfo(de.mossgrabers.framework.daw.IStepInfo) INoteClip(de.mossgrabers.framework.daw.INoteClip)

Aggregations

ColorEx (de.mossgrabers.framework.controller.color.ColorEx)35 IGraphicsConfiguration (de.mossgrabers.framework.graphics.IGraphicsConfiguration)12 IGraphicsContext (de.mossgrabers.framework.graphics.IGraphicsContext)12 IGraphicsDimensions (de.mossgrabers.framework.graphics.IGraphicsDimensions)9 IStepInfo (de.mossgrabers.framework.daw.IStepInfo)6 Color (com.bitwig.extension.api.Color)5 INoteClip (de.mossgrabers.framework.daw.INoteClip)5 GridStep (de.mossgrabers.framework.daw.data.GridStep)5 ITrack (de.mossgrabers.framework.daw.data.ITrack)5 IPadGrid (de.mossgrabers.framework.controller.grid.IPadGrid)4 IValueChanger (de.mossgrabers.framework.controller.valuechanger.IValueChanger)4 ITrackBank (de.mossgrabers.framework.daw.data.bank.ITrackBank)4 ButtonID (de.mossgrabers.framework.controller.ButtonID)3 IDrumDevice (de.mossgrabers.framework.daw.data.IDrumDevice)3 HardwareButton (com.bitwig.extension.controller.api.HardwareButton)2 HardwareLightVisualState (com.bitwig.extension.controller.api.HardwareLightVisualState)2 HardwareSurface (com.bitwig.extension.controller.api.HardwareSurface)2 InternalHardwareLightState (com.bitwig.extension.controller.api.InternalHardwareLightState)2 MultiStateHardwareLight (com.bitwig.extension.controller.api.MultiStateHardwareLight)2 HostImpl (de.mossgrabers.bitwig.framework.daw.HostImpl)2