use of de.mossgrabers.framework.daw.NoteOccurrenceType 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;
}
}
use of de.mossgrabers.framework.daw.NoteOccurrenceType in project DrivenByMoss by git-moss.
the class CursorClipImpl method setPrevNextOccurrence.
/**
* {@inheritDoc}
*/
@Override
public void setPrevNextOccurrence(final int channel, final int step, final int row, final boolean increase) {
final StepInfoImpl stepInfo = this.getUpdateableStep(channel, step, row);
final NoteOccurrenceType occurrenceType = stepInfo.getOccurrence();
final List<NoteOccurrenceType> types = Arrays.asList(NoteOccurrenceType.values());
final int typeIndex = Math.max(0, types.indexOf(occurrenceType));
final int newIndex = Math.max(0, Math.min(types.size() - 1, typeIndex + (increase ? 1 : -1)));
final NoteOccurrenceType newType = types.get(newIndex);
stepInfo.setOccurrence(newType);
if (this.editSteps.isEmpty()) {
final NoteOccurrence v = NoteOccurrence.valueOf(newType.name());
this.getClip().getStep(channel, step, row).setOccurrence(v);
}
}
use of de.mossgrabers.framework.daw.NoteOccurrenceType 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;
}
}
Aggregations