use of de.mossgrabers.framework.daw.StepState in project DrivenByMoss by git-moss.
the class SequencerView method handleSequencerArea.
/**
* {@inheritDoc}
*/
@Override
protected void handleSequencerArea(final int index, final int x, final int y, final int velocity) {
if (!this.isActive())
return;
final ModeManager modeManager = this.surface.getModeManager();
if (velocity > 0) {
// Turn on Note mode if an existing note is pressed
final INoteClip cursorClip = this.getClip();
final int mappedNote = this.keyManager.map(y);
final int editMidiChannel = this.configuration.getMidiEditChannel();
final StepState state = cursorClip.getStep(editMidiChannel, x, mappedNote).getState();
if (state == StepState.START) {
final NoteMode noteMode = (NoteMode) modeManager.get(Modes.NOTE);
noteMode.setValues(cursorClip, editMidiChannel, x, mappedNote);
modeManager.setActive(Modes.NOTE);
}
} else {
// Turn off Note mode
if (modeManager.isActive(Modes.NOTE))
modeManager.restore();
if (this.isNoteEdited) {
this.isNoteEdited = false;
return;
}
}
super.handleSequencerArea(index, x, y, velocity);
}
use of de.mossgrabers.framework.daw.StepState in project DrivenByMoss by git-moss.
the class DrumView method handleSequencerArea.
/**
* {@inheritDoc}
*/
@Override
protected void handleSequencerArea(final int index, final int x, final int y, final int offsetY, final int velocity) {
if (!this.isActive())
return;
final ModeManager modeManager = this.surface.getModeManager();
if (velocity > 0) {
// Turn on Note mode if an existing note is pressed
final INoteClip cursorClip = this.getClip();
final int channel = this.configuration.getMidiEditChannel();
final int step = this.numColumns * (this.allRows - 1 - y) + x;
final int note = offsetY + this.selectedPad;
final StepState state = cursorClip.getStep(channel, step, note).getState();
if (state == StepState.START) {
final NoteMode noteMode = (NoteMode) modeManager.get(Modes.NOTE);
noteMode.setValues(cursorClip, channel, step, note);
modeManager.setActive(Modes.NOTE);
}
} else {
// Turn off Note mode
if (modeManager.isActive(Modes.NOTE))
modeManager.restore();
if (this.isNoteEdited) {
this.isNoteEdited = false;
return;
}
}
super.handleSequencerArea(index, x, y, offsetY, velocity);
}
use of de.mossgrabers.framework.daw.StepState in project DrivenByMoss by git-moss.
the class AbstractDrumView method handleSequencerAreaButtonCombinations.
/**
* Handle button combinations in the sequencer area.
*
* @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 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 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
for (int s = 0; s < step; s++) {
final int pad = this.getPadIndex(s);
final IHwButton button = this.surface.getButton(ButtonID.get(this.firstPad, pad));
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;
}
use of de.mossgrabers.framework.daw.StepState in project DrivenByMoss by git-moss.
the class MidiClipComponent method draw.
/**
* {@inheritDoc}
*/
@Override
public void draw(final IGraphicsInfo info) {
final IGraphicsConfiguration configuration = info.getConfiguration();
final ColorEx gridBackground = configuration.getColorBackgroundLighter();
final ColorEx measureTextColor = ColorEx.WHITE;
final ColorEx dividersColor = configuration.getColorBackgroundDarker();
final ColorEx noteColor = this.clip.getColor();
final ColorEx noteMutedColor = ColorEx.DARK_GRAY;
final ColorEx noteGridLoopColor = configuration.getColorBackground();
final ColorEx noteBorderColor = ColorEx.BLACK;
final IGraphicsContext gc = info.getContext();
final double left = info.getBounds().left();
final double width = info.getBounds().width();
final double height = info.getBounds().height();
final int top = 14;
final double noteAreaHeight = height - top;
// Draw the background
gc.fillRectangle(left, top, width, noteAreaHeight, gridBackground);
// Draw the loop, if any and ...
final int numSteps = this.clip.getNumSteps();
final double stepLength = this.clip.getStepLength();
final double pageLength = numSteps * stepLength;
final int editPage = this.clip.getEditPage();
final double startPos = editPage * pageLength;
final double endPos = (editPage + 1) * pageLength;
final int len = top - 1;
if (this.clip.isLoopEnabled()) {
final double loopStart = this.clip.getLoopStart();
final double loopLength = this.clip.getLoopLength();
// ... the loop is visible in the current page
if (loopStart < endPos && loopStart + loopLength > startPos) {
final double start = Math.max(0, loopStart - startPos);
final double end = Math.min(endPos, loopStart + loopLength) - startPos;
final double x = width * start / pageLength;
final double w = width * end / pageLength - x;
// The header loop
gc.fillRectangle(x + 1, 0, w, len, noteColor);
// Background in note area
gc.fillRectangle(x + 1, top, w, noteAreaHeight, noteGridLoopColor);
}
}
// Draw play start in header
final double playStart = this.clip.getPlayStart();
if (playStart >= startPos && playStart <= endPos) {
final double start = playStart - startPos;
final double x = width * start / pageLength;
gc.fillTriangle(x + 1, 0, x + 1 + len, len / 2.0, x + 1, len, noteColor);
gc.strokeTriangle(x + 1, 0, x + 1 + len, len / 2.0, x + 1, len, ColorEx.evenDarker(noteColor));
}
// Draw play end in header
final double playEnd = this.clip.getPlayEnd();
if (playEnd >= startPos && playEnd <= endPos) {
final double end = playEnd - startPos;
final double x = width * end / pageLength;
gc.fillTriangle(x + 1, 0, x + 1, len, x + 1 - top, len / 2.0, noteColor);
gc.strokeTriangle(x + 1, 0, x + 1, len, x + 1 - top, len / 2.0, ColorEx.evenDarker(noteColor));
}
// Draw dividers
final double stepWidth = width / numSteps;
for (int step = 0; step <= numSteps; step++) {
final double x = left + step * stepWidth;
gc.fillRectangle(x, top, 1, noteAreaHeight, dividersColor);
// Draw measure texts
if (step % 4 == 0) {
final double time = startPos + step * stepLength;
final String measureText = StringUtils.formatMeasures(this.quartersPerMeasure, time, 1, false);
gc.drawTextInHeight(measureText, x, 0, top - 1.0, measureTextColor, top);
}
}
// Draw the notes
final int lowerRowWithData = this.clip.getLowerRowWithData();
if (lowerRowWithData == -1)
return;
final int upperRowWithData = this.clip.getUpperRowWithData();
// Display at least 4 rows
final int range = Math.max(4, 1 + upperRowWithData - lowerRowWithData);
final double stepHeight = noteAreaHeight / range;
final double fontSize = gc.calculateFontSize("G#5", stepHeight, stepWidth, 12.0);
for (int row = 0; row < range; row++) {
gc.fillRectangle(left, top + (range - row - 1) * stepHeight, width, 1, dividersColor);
for (int step = 0; step < numSteps; step++) {
final int note = lowerRowWithData + row;
// Get step, check for length
for (int channel = 0; channel < 16; channel++) {
final IStepInfo stepInfo = this.clip.getStep(channel, step, note);
final StepState stepState = stepInfo.getState();
if (stepState == StepState.OFF)
continue;
double x = left + step * stepWidth - 1;
double w = stepWidth + 2;
final boolean isStart = stepState == StepState.START;
if (isStart) {
x += 2;
w -= 2;
}
gc.strokeRectangle(x, top + (range - row - 1) * stepHeight + 2, w, stepHeight - 2, noteBorderColor);
gc.fillRectangle(x + (isStart ? 0 : -2), top + (range - row - 1) * stepHeight + 2, w - 1 + (isStart ? 0 : 2), stepHeight - 3, stepInfo.isMuted() ? noteMutedColor : noteColor);
if (isStart && fontSize > 0) {
final String text = channel + 1 + ": " + Scales.formatDrumNote(note);
final ColorEx textColor = ColorEx.calcContrastColor(noteColor);
gc.drawTextInBounds(text, x, top + (range - row - 1) * stepHeight + 2, w - 1, stepHeight - 3, Align.CENTER, textColor, fontSize);
}
}
}
}
// Draw the play cursor
final int playStep = this.clip.getCurrentStep();
if (playStep >= 0)
gc.fillRectangle(left + playStep * stepWidth - 1, 0, 3, height, measureTextColor);
}
use of de.mossgrabers.framework.daw.StepState in project DrivenByMoss by git-moss.
the class DrumView method handleSequencerAreaButtonCombinations.
/**
* {@inheritDoc}
*/
@Override
protected boolean handleSequencerAreaButtonCombinations(final INoteClip clip, final int channel, final int step, final int note, final int velocity) {
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;
}
final ModeManager modeManager = this.surface.getModeManager();
if (modeManager.isActive(Modes.NOTE)) {
this.model.getHost().showNotification("Note " + Scales.formatNoteAndOctave(note, -3) + " - Step " + Integer.toString(step + 1));
this.editNote(clip, channel, step, note, true);
return true;
}
final boolean isSelectPressed = this.surface.isSelectPressed();
if (isSelectPressed) {
if (velocity > 0)
this.handleSequencerAreaRepeatOperator(clip, channel, step, note, velocity, isSelectPressed);
return true;
}
return super.handleSequencerAreaButtonCombinations(clip, channel, step, note, velocity);
}
Aggregations