use of de.mossgrabers.framework.daw.INoteClip in project DrivenByMoss by git-moss.
the class AbstractNoteSequencerView method drawGrid.
/**
* {@inheritDoc}
*/
@Override
public void drawGrid() {
final IPadGrid gridPad = this.surface.getPadGrid();
if (!this.isActive()) {
gridPad.turnOff();
return;
}
// Steps with notes
final INoteClip clip = this.getClip();
final int step = clip.getCurrentStep();
final int hiStep = this.isInXRange(step) ? step % this.numDisplayCols : -1;
final int editMidiChannel = this.configuration.getMidiEditChannel();
final List<GridStep> editNotes = this.getEditNotes();
for (int x = 0; x < this.numDisplayCols; x++) {
for (int y = 0; y < this.numSequencerRows; y++) {
final int map = this.keyManager.map(y);
final IStepInfo stepInfo = map < 0 ? null : clip.getStep(editMidiChannel, x, map);
gridPad.lightEx(x, this.numDisplayRows - 1 - y, this.getStepColor(stepInfo, x == hiStep, editMidiChannel, x, y, map, editNotes));
}
}
if (this.numDisplayRows - this.numSequencerRows <= 0)
return;
// CLip Pages on the top
final int lengthOfOnePad = this.getLengthOfOnePage(this.numDisplayCols);
final double loopStart = clip.getLoopStart();
final int loopStartPad = (int) Math.ceil(loopStart / lengthOfOnePad);
final int loopEndPad = (int) Math.ceil((loopStart + clip.getLoopLength()) / lengthOfOnePad);
final int currentPage = step / this.numDisplayCols;
for (int pad = 0; pad < this.numDisplayCols; pad++) gridPad.lightEx(pad, 0, this.getPageColor(loopStartPad, loopEndPad, currentPage, clip.getEditPage(), pad));
}
use of de.mossgrabers.framework.daw.INoteClip in project DrivenByMoss by git-moss.
the class AbstractRaindropsView method getNoteDistanceToTheLeft.
protected int getNoteDistanceToTheLeft(final int row, final int start, final int length) {
if (row < 0 || start < 0 || start >= length)
return -1;
final int s = start == 0 ? length - 1 : start - 1;
int step = s;
int counter = 0;
final INoteClip clip = this.getClip();
final int editMidiChannel = this.configuration.getMidiEditChannel();
do {
if (clip.getStep(editMidiChannel, step, row).getState() != StepState.OFF)
return counter;
step--;
counter++;
if (step < 0)
step = length - 1;
} while (step != s);
return -1;
}
use of de.mossgrabers.framework.daw.INoteClip in project DrivenByMoss by git-moss.
the class AbstractRaindropsView method drawGrid.
/**
* {@inheritDoc}
*/
@Override
public void drawGrid() {
final IPadGrid padGrid = this.surface.getPadGrid();
if (!this.isActive()) {
padGrid.turnOff();
return;
}
if (this.ongoingResolutionChange)
return;
final ITrack cursorTrack = this.useDawColors ? this.model.getCursorTrack() : null;
final INoteClip clip = this.getClip();
final int length = (int) Math.floor(clip.getLoopLength() / Resolution.getValueAt(this.selectedResolutionIndex));
final int step = clip.getCurrentStep();
for (int x = 0; x < AbstractRaindropsView.NUM_DISPLAY_COLS; x++) {
final int mappedKey = this.keyManager.map(x);
if (mappedKey == -1)
continue;
final int left = this.getNoteDistanceToTheLeft(mappedKey, step, length);
final int right = this.getNoteDistanceToTheRight(mappedKey, step, length);
final boolean isOn = left >= 0 && right >= 0;
final int sum = left + right;
final int distance = sum == 0 ? 0 : (sum + 1) / 2;
for (int y = 0; y < this.numDisplayRows; y++) {
String colorID = y == 0 ? this.getPadColor(x, cursorTrack) : AbstractSequencerView.COLOR_NO_CONTENT;
if (isOn) {
if (y == distance)
colorID = AbstractSequencerView.COLOR_CONTENT;
if (left <= distance && y == left || left > distance && y == sum - left)
colorID = AbstractSequencerView.COLOR_STEP_HILITE_NO_CONTENT;
}
padGrid.lightEx(x, this.numDisplayRows - 1 - y, colorID);
}
}
}
use of de.mossgrabers.framework.daw.INoteClip in project DrivenByMoss by git-moss.
the class AbstractRaindropsView method getNoteDistance.
protected int getNoteDistance(final int row, final int length) {
if (row < 0)
return -1;
int step;
final INoteClip clip = this.getClip();
final int editMidiChannel = this.configuration.getMidiEditChannel();
for (step = 0; step < length; step++) {
if (clip.getStep(editMidiChannel, step, row).getState() != StepState.OFF)
break;
}
if (step >= length)
return -1;
for (int step2 = step + 1; step2 < length; step2++) {
if (clip.getStep(editMidiChannel, step2, row).getState() != StepState.OFF)
return step2 - step;
}
return -1;
}
use of de.mossgrabers.framework.daw.INoteClip in project DrivenByMoss by git-moss.
the class AbstractRaindropsView method onGridNote.
/**
* {@inheritDoc}
*/
@Override
public void onGridNote(final int note, final int velocity) {
if (!this.isActive() || velocity == 0)
return;
final int index = note - 36;
final int x = index % 8;
final int y = index / 8;
final int stepSize = y == 0 ? 1 : 2 * y;
final INoteClip clip = this.getClip();
final int length = (int) Math.floor(clip.getLoopLength() / Resolution.getValueAt(this.selectedResolutionIndex));
final int distance = this.getNoteDistance(this.keyManager.map(x), length);
final int editMidiChannel = this.configuration.getMidiEditChannel();
clip.clearRow(editMidiChannel, this.keyManager.map(x));
if (distance == -1 || distance != (y == 0 ? 1 : y * 2)) {
final int offset = clip.getCurrentStep() % stepSize;
if (offset < 0)
return;
for (int i = offset; i < length; i += stepSize) {
// Only support 32 measures at 1/32t
if (i < MAX_STEPS)
clip.setStep(editMidiChannel, i, this.keyManager.map(x), this.configuration.isAccentActive() ? this.configuration.getFixedAccentValue() : velocity, Resolution.getValueAt(this.selectedResolutionIndex));
}
}
}
Aggregations