Search in sources :

Example 31 with IStepInfo

use of de.mossgrabers.framework.daw.IStepInfo 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)

Example 32 with IStepInfo

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

the class NoteMode method updateDisplay1.

/**
 * {@inheritDoc}
 */
@Override
public void updateDisplay1(final ITextDisplay display) {
    if (this.notes.isEmpty()) {
        display.setRow(1, "                     Please selecta note...                         ");
        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);
    if (this.page != Page.RECCURRENCE_PATTERN) {
        display.setCell(0, 0, "Length").setCell(1, 0, this.formatLength(stepInfo.getDuration()));
        if (stepInfo.isMuted())
            display.setCell(2, 1, " MUTED");
        final int size = this.notes.size();
        final boolean isOneNote = size == 1;
        display.setCell(3, 0, isOneNote ? "Step: " + (step + 1) : "Notes: " + size);
        display.setCell(3, 1, isOneNote ? Scales.formatNoteAndOctave(note, -3) : "*");
    }
    final IValueChanger valueChanger = this.model.getValueChanger();
    switch(this.page) {
        case NOTE:
            display.setCell(0, 1, " COMMON:");
            final double noteVelocity = stepInfo.getVelocity();
            final int parameterValue = valueChanger.fromNormalizedValue(noteVelocity);
            display.setCell(0, 2, "Velocity");
            display.setCell(1, 2, StringUtils.formatPercentage(noteVelocity));
            display.setCell(2, 2, parameterValue, Format.FORMAT_VALUE);
            if (this.host.supports(Capability.NOTE_EDIT_VELOCITY_SPREAD)) {
                final double noteVelocitySpread = stepInfo.getVelocitySpread();
                final int parameterSpreadValue = valueChanger.fromNormalizedValue(noteVelocitySpread);
                display.setCell(0, 3, "V-Spread");
                display.setCell(1, 3, StringUtils.formatPercentage(noteVelocitySpread));
                display.setCell(2, 3, parameterSpreadValue, Format.FORMAT_VALUE);
            }
            if (this.host.supports(Capability.NOTE_EDIT_RELEASE_VELOCITY)) {
                final double noteReleaseVelocity = stepInfo.getReleaseVelocity();
                final int parameterReleaseValue = valueChanger.fromNormalizedValue(noteReleaseVelocity);
                display.setCell(0, 4, "R-Velcty");
                display.setCell(1, 4, StringUtils.formatPercentage(noteReleaseVelocity));
                display.setCell(2, 4, parameterReleaseValue, Format.FORMAT_VALUE);
            }
            if (this.host.supports(Capability.NOTE_EDIT_CHANCE)) {
                final double chance = stepInfo.getChance();
                final int chanceValue = valueChanger.fromNormalizedValue(chance);
                display.setCell(0, 5, "Chance");
                display.setCell(1, 5, StringUtils.formatPercentage(chance));
                display.setCell(2, 5, chanceValue, Format.FORMAT_VALUE);
                display.setCell(3, 5, stepInfo.isChanceEnabled() ? ON : OFF);
            }
            if (this.host.supports(Capability.NOTE_EDIT_OCCURRENCE)) {
                final NoteOccurrenceType occurrence = stepInfo.getOccurrence();
                display.setCell(0, 6, "Occurnce");
                display.setCell(1, 6, StringUtils.optimizeName(occurrence.getName(), 8));
                display.setCell(3, 6, stepInfo.isOccurrenceEnabled() ? ON : OFF);
            }
            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.setCell(0, 7, "Recurnce");
                display.setCell(1, 7, recurrenceStr);
                display.setCell(2, 7, recurrenceVal, Format.FORMAT_VALUE);
                display.setCell(3, 7, stepInfo.isRecurrenceEnabled() ? ON : OFF);
            }
            break;
        case EXPRESSIONS:
            if (this.host.supports(Capability.NOTE_EDIT_EXPRESSIONS)) {
                display.setCell(0, 2, "EXPRESS:");
                final double noteGain = stepInfo.getGain();
                final int parameterGainValue = Math.min(1023, valueChanger.fromNormalizedValue(noteGain));
                display.setCell(0, 3, "Gain").setCell(1, 3, StringUtils.formatPercentage(noteGain)).setCell(2, 3, parameterGainValue, Format.FORMAT_VALUE);
                final double notePan = stepInfo.getPan();
                final int parameterPanValue = valueChanger.fromNormalizedValue((notePan + 1.0) / 2.0);
                display.setCell(0, 4, "Pan").setCell(1, 4, StringUtils.formatPercentage(notePan)).setCell(2, 4, parameterPanValue, Format.FORMAT_PAN);
                final double noteTranspose = stepInfo.getTranspose();
                final int parameterTransposeValue = valueChanger.fromNormalizedValue((noteTranspose + 24.0) / 48.0);
                display.setCell(0, 5, "Pitch").setCell(1, 5, String.format("%.1f", Double.valueOf(noteTranspose))).setCell(2, 5, parameterTransposeValue, Format.FORMAT_PAN);
                final double noteTimbre = stepInfo.getTimbre();
                final int parameterTimbreValue = valueChanger.fromNormalizedValue((noteTimbre + 1.0) / 2.0);
                display.setCell(0, 6, "Timbre").setCell(1, 6, StringUtils.formatPercentage(noteTimbre)).setCell(2, 6, parameterTimbreValue, Format.FORMAT_VALUE);
                final double notePressure = stepInfo.getPressure();
                final int parameterPressureValue = valueChanger.fromNormalizedValue(notePressure);
                display.setCell(0, 7, "Pressure").setCell(1, 7, StringUtils.formatPercentage(notePressure)).setCell(2, 7, parameterPressureValue, Format.FORMAT_VALUE);
            }
            break;
        case REPEAT:
            display.setCell(0, 2, "REPEAT:");
            final int repeatCount = stepInfo.getRepeatCount();
            final String repeatCountValue = stepInfo.getFormattedRepeatCount();
            final int rc = (repeatCount + 127) * (this.model.getValueChanger().getUpperBound() - 1) / 254;
            display.setCell(0, 3, "Count");
            display.setCell(1, 3, repeatCountValue);
            display.setCell(2, 3, rc, Format.FORMAT_VALUE);
            display.setCell(3, 3, stepInfo.isRepeatEnabled() ? ON : OFF);
            final double repeatCurve = stepInfo.getRepeatCurve();
            final int repeatCurveValue = valueChanger.fromNormalizedValue((repeatCurve + 1.0) / 2.0);
            display.setCell(0, 4, "Curve");
            display.setCell(1, 4, StringUtils.formatPercentage(repeatCurve));
            display.setCell(2, 4, repeatCurveValue, Format.FORMAT_VALUE);
            final double repeatVelocityCurve = stepInfo.getRepeatVelocityCurve();
            final int repeatVelocityCurveValue = valueChanger.fromNormalizedValue((repeatVelocityCurve + 1.0) / 2.0);
            display.setCell(0, 5, "Vel-Crve");
            display.setCell(1, 5, StringUtils.formatPercentage(repeatVelocityCurve));
            display.setCell(2, 5, repeatVelocityCurveValue, Format.FORMAT_VALUE);
            final double repeatVelocityEnd = stepInfo.getRepeatVelocityEnd();
            final int repeatVelocityEndValue = valueChanger.fromNormalizedValue((repeatVelocityEnd + 1.0) / 2.0);
            display.setCell(0, 6, "Vel. End");
            display.setCell(1, 6, StringUtils.formatPercentage(repeatVelocityEnd));
            display.setCell(2, 6, repeatVelocityEndValue, Format.FORMAT_VALUE);
            break;
        case RECCURRENCE_PATTERN:
            display.setBlock(0, 1, "       Recurrence");
            display.setBlock(0, 2, "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;
                String label = "   -";
                if (i < recurrenceLength) {
                    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.setCell(0, 7, "Recurnce");
                    display.setCell(1, 7, recurrenceStr);
                    display.setCell(2, 7, recurrenceVal, Format.FORMAT_VALUE);
                }
                display.setCell(3, i, label);
            }
            break;
    }
}
Also used : IValueChanger(de.mossgrabers.framework.controller.valuechanger.IValueChanger) GridStep(de.mossgrabers.framework.daw.data.GridStep) IStepInfo(de.mossgrabers.framework.daw.IStepInfo) NoteOccurrenceType(de.mossgrabers.framework.daw.NoteOccurrenceType)

Example 33 with IStepInfo

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

the class NoteMode method onFirstRow.

/**
 * {@inheritDoc}
 */
@Override
public void onFirstRow(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 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:
                break;
            case REPEAT:
                if (index == 3 && this.host.supports(Capability.NOTE_EDIT_REPEAT))
                    this.clip.updateIsRepeatEnabled(channel, step, note, !stepInfo.isRepeatEnabled());
                break;
            case RECCURRENCE_PATTERN:
                if (this.host.supports(Capability.NOTE_EDIT_RECCURRENCE)) {
                    int mask = stepInfo.getRecurrenceMask();
                    final int bitVal = 1 << index;
                    if ((mask & bitVal) > 0)
                        mask &= ~bitVal;
                    else
                        mask |= bitVal;
                    this.clip.updateRecurrenceMask(channel, step, note, mask);
                }
                break;
        }
    }
}
Also used : GridStep(de.mossgrabers.framework.daw.data.GridStep) IStepInfo(de.mossgrabers.framework.daw.IStepInfo)

Example 34 with IStepInfo

use of de.mossgrabers.framework.daw.IStepInfo 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)

Example 35 with IStepInfo

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

the class NoteMode method onKnobValue.

/**
 * {@inheritDoc}
 */
@Override
public void onKnobValue(final int index, final int value) {
    if (this.notes.isEmpty())
        return;
    if (this.surface.isDeletePressed()) {
        this.handleDelete(index);
        return;
    }
    synchronized (this.startLock) {
        if (!this.started) {
            this.clip.startEdit(this.notes);
            this.started = true;
        }
    }
    for (final GridStep noteInfo : this.notes) {
        final int channel = noteInfo.channel();
        final int step = noteInfo.step();
        final int note = noteInfo.note();
        switch(this.page) {
            case NOTE:
                switch(index) {
                    case 0:
                        this.clip.changeStepDuration(channel, step, note, value);
                        break;
                    case 1:
                        if (this.host.supports(Capability.NOTE_EDIT_MUTE))
                            this.clip.changeMuteState(channel, step, note, value);
                        break;
                    case 2:
                        this.clip.changeStepVelocity(channel, step, note, value);
                        break;
                    case 3:
                        if (this.host.supports(Capability.NOTE_EDIT_VELOCITY_SPREAD))
                            this.clip.changeVelocitySpread(channel, step, note, value);
                        break;
                    case 4:
                        if (this.host.supports(Capability.NOTE_EDIT_RELEASE_VELOCITY))
                            this.clip.changeStepReleaseVelocity(channel, step, note, value);
                        break;
                    case 5:
                        if (this.host.supports(Capability.NOTE_EDIT_CHANCE))
                            this.clip.changeChance(channel, step, note, value);
                        break;
                    case 6:
                        if (this.host.supports(Capability.NOTE_EDIT_OCCURRENCE)) {
                            final boolean increase = this.model.getValueChanger().isIncrease(value);
                            this.clip.setPrevNextOccurrence(channel, step, note, increase);
                        }
                        break;
                    case 7:
                        if (this.host.supports(Capability.NOTE_EDIT_RECCURRENCE))
                            this.clip.changeRecurrenceLength(channel, step, note, value);
                        break;
                    default:
                        return;
                }
                break;
            case EXPRESSIONS:
                switch(index) {
                    case 0:
                        this.clip.changeStepDuration(channel, step, note, value);
                        break;
                    case 1:
                        if (this.host.supports(Capability.NOTE_EDIT_MUTE))
                            this.clip.changeMuteState(channel, step, note, value);
                        break;
                    case 3:
                        if (this.host.supports(Capability.NOTE_EDIT_EXPRESSIONS))
                            this.clip.changeStepGain(channel, step, note, value);
                        break;
                    case 4:
                        if (this.host.supports(Capability.NOTE_EDIT_EXPRESSIONS))
                            this.clip.changeStepPan(channel, step, note, value);
                        break;
                    case 5:
                        if (this.host.supports(Capability.NOTE_EDIT_EXPRESSIONS))
                            this.clip.changeStepTranspose(channel, step, note, value);
                        break;
                    case 6:
                        if (this.host.supports(Capability.NOTE_EDIT_EXPRESSIONS))
                            this.clip.changeStepTimbre(channel, step, note, value);
                        break;
                    case 7:
                        if (this.host.supports(Capability.NOTE_EDIT_EXPRESSIONS))
                            this.clip.changeStepPressure(channel, step, note, value);
                        break;
                    default:
                        return;
                }
                break;
            case REPEAT:
                switch(index) {
                    case 0:
                        this.clip.changeStepDuration(channel, step, note, value);
                        break;
                    case 1:
                        if (this.host.supports(Capability.NOTE_EDIT_MUTE))
                            this.clip.changeMuteState(channel, step, note, value);
                        break;
                    case 4:
                        if (this.host.supports(Capability.NOTE_EDIT_REPEAT))
                            this.clip.changeRepeatCount(channel, step, note, value);
                        break;
                    case 5:
                        if (this.host.supports(Capability.NOTE_EDIT_REPEAT))
                            this.clip.changeRepeatCurve(channel, step, note, value);
                        break;
                    case 6:
                        if (this.host.supports(Capability.NOTE_EDIT_REPEAT))
                            this.clip.changeRepeatVelocityCurve(channel, step, note, value);
                        break;
                    case 7:
                        if (this.host.supports(Capability.NOTE_EDIT_REPEAT))
                            this.clip.changeRepeatVelocityEnd(channel, step, note, value);
                        break;
                    default:
                        return;
                }
                break;
            case RECCURRENCE_PATTERN:
                if (this.host.supports(Capability.NOTE_EDIT_RECCURRENCE)) {
                    final IStepInfo stepInfo = this.clip.getStep(channel, step, note);
                    int mask = stepInfo.getRecurrenceMask();
                    final int bitVal = 1 << index;
                    if (this.model.getValueChanger().isIncrease(value))
                        mask |= bitVal;
                    else
                        mask &= ~bitVal;
                    this.clip.updateRecurrenceMask(channel, step, note, mask);
                }
                break;
        }
    }
    // Ugly workaround for knobs not having touch support...
    final long lastValueChange = System.currentTimeMillis();
    this.host.scheduleTask(() -> {
        if (System.currentTimeMillis() - lastValueChange > 400) {
            synchronized (this.startLock) {
                if (this.started) {
                    this.started = false;
                    this.clip.stopEdit();
                }
            }
        }
    }, 400);
}
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