use of de.mossgrabers.framework.daw.data.GridStep 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));
}
}
use of de.mossgrabers.framework.daw.data.GridStep in project DrivenByMoss by git-moss.
the class EditNoteMode method addNote.
/**
* {@inheritDoc}
*/
@Override
public void addNote(final INoteClip clip, final int channel, final int step, final int note) {
if (this.clip != clip) {
this.notes.clear();
this.clip = clip;
}
// Is the note already edited? Remove it.
for (final GridStep gridStep : this.notes) {
if (gridStep.channel() == channel && gridStep.step() == step && gridStep.note() == note) {
this.notes.remove(gridStep);
return;
}
}
this.notes.add(new GridStep(channel, step, note));
}
use of de.mossgrabers.framework.daw.data.GridStep in project DrivenByMoss by git-moss.
the class EditNoteMode method onKnobValue.
/**
* {@inheritDoc}
*/
@Override
public void onKnobValue(final int index, final int value) {
for (final GridStep noteInfo : this.notes) {
final int channel = noteInfo.channel();
final int step = noteInfo.step();
final int note = noteInfo.note();
final int idx = index < 0 ? this.selectedParam : index;
final boolean hasMCUDisplay = this.surface.getMaschine().hasMCUDisplay();
final IStepInfo stepInfo = this.clip.getStep(channel, step, note);
switch(idx + 10 * this.selectedPage) {
case DURATION:
case DURATION2:
case DURATION3:
case DURATION4:
case DURATION5:
case DURATION6:
this.clip.changeStepDuration(channel, step, note, value);
if (!hasMCUDisplay)
this.mvHelper.delayDisplay(() -> "Duration: " + StringUtils.formatMeasures(this.model.getTransport().getQuartersPerMeasure(), stepInfo.getDuration(), 0, true));
break;
case VELOCITY:
case VELOCITY2:
this.clip.changeStepVelocity(channel, step, note, value);
if (!hasMCUDisplay)
this.mvHelper.delayDisplay(() -> "Velocity: " + StringUtils.formatPercentage(stepInfo.getVelocity()));
break;
case GAIN:
if (this.host.supports(Capability.NOTE_EDIT_EXPRESSIONS)) {
this.clip.changeStepGain(channel, step, note, value);
if (!hasMCUDisplay)
this.mvHelper.delayDisplay(() -> "Gain: " + StringUtils.formatPercentage(stepInfo.getGain()));
}
break;
case PANORAMA:
if (this.host.supports(Capability.NOTE_EDIT_EXPRESSIONS)) {
this.clip.changeStepPan(channel, step, note, value);
if (!hasMCUDisplay)
this.mvHelper.delayDisplay(() -> "Panorama: " + StringUtils.formatPercentage(stepInfo.getPan() * 2.0 - 1.0));
}
break;
case PITCH:
if (this.host.supports(Capability.NOTE_EDIT_EXPRESSIONS)) {
this.clip.changeStepTranspose(channel, step, note, value);
if (!hasMCUDisplay)
this.mvHelper.delayDisplay(() -> "Pitch: " + String.format("%.1f", Double.valueOf(stepInfo.getTranspose() * 48.0 - 24.0)));
}
break;
case PRESSURE:
if (this.host.supports(Capability.NOTE_EDIT_EXPRESSIONS)) {
this.clip.changeStepPressure(channel, step, note, value);
if (!hasMCUDisplay)
this.mvHelper.delayDisplay(() -> "Pressure: " + StringUtils.formatPercentage(stepInfo.getPressure()));
}
break;
case TIMBRE:
if (this.host.supports(Capability.NOTE_EDIT_EXPRESSIONS)) {
this.clip.changeStepTimbre(channel, step, note, value);
if (!hasMCUDisplay)
this.mvHelper.delayDisplay(() -> "Timbre: " + StringUtils.formatPercentage(stepInfo.getTimbre()));
}
break;
case VELOCITY_SPREAD:
if (this.host.supports(Capability.NOTE_EDIT_VELOCITY_SPREAD)) {
this.clip.changeVelocitySpread(channel, step, note, value);
if (!hasMCUDisplay)
this.mvHelper.delayDisplay(() -> "Velocity Spread: " + StringUtils.formatPercentage(stepInfo.getVelocitySpread()));
}
break;
case RELEASE_VELOCITY:
if (this.host.supports(Capability.NOTE_EDIT_RELEASE_VELOCITY)) {
this.clip.changeStepReleaseVelocity(channel, step, note, value);
if (!hasMCUDisplay)
this.mvHelper.delayDisplay(() -> "Release Velocity: " + StringUtils.formatPercentage(stepInfo.getReleaseVelocity()));
}
break;
case CHANCE:
if (this.host.supports(Capability.NOTE_EDIT_CHANCE)) {
this.clip.changeChance(channel, step, note, value);
if (!hasMCUDisplay)
this.mvHelper.delayDisplay(() -> "Chance: " + StringUtils.formatPercentage(stepInfo.getChance()));
}
break;
case OCCURRENCE:
if (this.host.supports(Capability.NOTE_EDIT_OCCURRENCE)) {
final boolean increase = this.model.getValueChanger().isIncrease(value);
this.clip.setPrevNextOccurrence(channel, step, note, increase);
if (!hasMCUDisplay)
this.mvHelper.delayDisplay(() -> "Occurrence: " + StringUtils.optimizeName(stepInfo.getOccurrence().getName(), 8));
}
break;
case VELOCITY_END:
if (this.host.supports(Capability.NOTE_EDIT_REPEAT)) {
this.clip.changeRepeatVelocityEnd(channel, step, note, value);
if (!hasMCUDisplay)
this.mvHelper.delayDisplay(() -> "Velocity End: " + StringUtils.formatPercentage(stepInfo.getRepeatVelocityEnd()));
}
break;
case VELOCITY_CURVE:
if (this.host.supports(Capability.NOTE_EDIT_REPEAT)) {
this.clip.changeRepeatVelocityCurve(channel, step, note, value);
if (!hasMCUDisplay)
this.mvHelper.delayDisplay(() -> "Velocity Curve: " + StringUtils.formatPercentage(stepInfo.getRepeatVelocityCurve()));
}
break;
case COUNT:
if (this.host.supports(Capability.NOTE_EDIT_REPEAT)) {
this.clip.changeRepeatCount(channel, step, note, value);
if (!hasMCUDisplay)
this.mvHelper.delayDisplay(() -> "Repeat Count: " + stepInfo.getFormattedRepeatCount());
}
break;
case CURVE:
if (this.host.supports(Capability.NOTE_EDIT_REPEAT)) {
this.clip.changeRepeatCurve(channel, step, note, value);
if (!hasMCUDisplay)
this.mvHelper.delayDisplay(() -> "Repeat Curve: " + StringUtils.formatPercentage(stepInfo.getRepeatCurve()));
}
break;
default:
return;
}
}
}
use of de.mossgrabers.framework.daw.data.GridStep in project DrivenByMoss by git-moss.
the class CursorClipImpl method handleStepData.
/**
* Update the step info with the incoming data from Bitwig if the note is not currently edited.
*
* @param noteStep The new data
*/
private void handleStepData(final NoteStep noteStep) {
final int channel = noteStep.channel();
final int step = noteStep.x();
final int note = noteStep.y();
for (final GridStep editStep : this.editSteps) {
// Is the note among the currently edited ones?
if (editStep.channel() == channel && editStep.step() == step && editStep.note() == note)
return;
}
this.getUpdateableStep(channel, step, note).updateData(noteStep);
}
use of de.mossgrabers.framework.daw.data.GridStep in project DrivenByMoss by git-moss.
the class AbstractDrumView method drawSequencerSteps.
/**
* Draw the sequencer steps.
*
* @param clip The clip
* @param isActive Is there an active clip?
* @param noteRow The note for which to draw the row
* @param rowColor The color to use the notes of the row
* @param yModifier Flips the Y order if true
*/
protected void drawSequencerSteps(final INoteClip clip, final boolean isActive, final int noteRow, final Optional<ColorEx> rowColor, final IntUnaryOperator yModifier) {
final int step = clip.getCurrentStep();
final int hiStep = this.isInXRange(step) ? step % this.sequencerSteps : -1;
final int editMidiChannel = this.configuration.getMidiEditChannel();
final IPadGrid padGrid = this.surface.getPadGrid();
final List<GridStep> editNotes = this.getEditNotes();
for (int col = 0; col < this.sequencerSteps; col++) {
final IStepInfo stepInfo = clip.getStep(editMidiChannel, col, noteRow);
final boolean hilite = col == hiStep;
final int x = col % this.numColumns;
int y = col / this.numColumns;
if (yModifier != null)
y = yModifier.applyAsInt(y);
padGrid.lightEx(x, y, isActive ? this.getStepColor(stepInfo, hilite, rowColor, editMidiChannel, col, noteRow, editNotes) : AbstractSequencerView.COLOR_NO_CONTENT);
}
}
Aggregations