use of de.mossgrabers.framework.daw.INoteClip in project DrivenByMoss by git-moss.
the class AbstractNoteSequencerView method handleLoopArea.
/**
* Handle button presses in the loop area of the note sequencer.
*
* @param pad The pressed pad
* @param velocity The velocity
*/
protected void handleLoopArea(final int pad, final int velocity) {
// Button pressed?
if (velocity > 0) {
// Not yet a button pressed, store it
if (this.loopPadPressed == -1)
this.loopPadPressed = pad;
return;
}
if (this.loopPadPressed == -1)
return;
final INoteClip clip = this.getClip();
if (pad == this.loopPadPressed && pad != clip.getEditPage()) {
// Only single pad pressed -> page selection
clip.scrollToPage(pad);
} else {
// Set a new loop between the 2 selected pads
final int start = this.loopPadPressed < pad ? this.loopPadPressed : pad;
final int end = (this.loopPadPressed < pad ? pad : this.loopPadPressed) + 1;
final int lengthOfOnePad = this.getLengthOfOnePage(this.numDisplayCols);
final double newStart = (double) start * lengthOfOnePad;
clip.setLoopStart(newStart);
clip.setLoopLength((end - start) * lengthOfOnePad);
clip.setPlayRange(newStart, (double) end * lengthOfOnePad);
}
this.loopPadPressed = -1;
}
use of de.mossgrabers.framework.daw.INoteClip in project DrivenByMoss by git-moss.
the class AbstractNoteSequencerView method handleSequencerArea.
/**
* Handle button presses in the sequencer area of the note sequencer.
*
* @param index The index of the pad
* @param x The x position of the pad in the sequencer grid
* @param y The y position of the pad in the sequencer grid
* @param velocity The velocity
*/
protected void handleSequencerArea(final int index, final int x, final int y, final int velocity) {
// Toggle the note on up, so we can intercept the long presses
if (velocity != 0)
return;
final INoteClip clip = this.getClip();
final int channel = this.configuration.getMidiEditChannel();
final int mappedY = this.keyManager.map(y);
final int vel = this.configuration.isAccentActive() ? this.configuration.getFixedAccentValue() : this.surface.getButton(ButtonID.get(ButtonID.PAD1, index)).getPressedVelocity();
if (this.handleSequencerAreaButtonCombinations(clip, channel, x, y, mappedY, vel))
return;
if (mappedY >= 0)
clip.toggleStep(channel, x, mappedY, vel);
}
use of de.mossgrabers.framework.daw.INoteClip in project DrivenByMoss by git-moss.
the class AbstractDrumView method drawGrid.
/**
* {@inheritDoc}
*/
@Override
public void drawGrid() {
final IPadGrid padGrid = this.surface.getPadGrid();
if (!this.model.canSelectedTrackHoldNotes()) {
padGrid.turnOff();
return;
}
// halfColumns x playLines Drum Pad Grid
final IDrumDevice primary = this.model.getDrumDevice();
final boolean isRecording = this.model.hasRecordingState();
for (int y = 0; y < this.playRows; y++) {
for (int x = 0; x < this.playColumns; x++) {
final int index = this.playColumns * y + x;
padGrid.lightEx(x, this.allRows - 1 - y, this.getDrumPadColor(index, primary, isRecording));
}
}
if (this.sequencerLines > 0) {
final INoteClip clip = this.getClip();
final boolean isActive = this.isActive();
this.drawPages(clip, isActive);
this.drawSequencerSteps(clip, isActive, this.scales.getDrumOffset() + this.selectedPad, this.getPadColor(primary, this.selectedPad));
}
}
use of de.mossgrabers.framework.daw.INoteClip 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.INoteClip in project DrivenByMoss by git-moss.
the class DrumConfigView method onGridNote.
/**
* {@inheritDoc}
*/
@Override
public void onGridNote(final int note, final int velocity) {
if (velocity == 0)
return;
final int index = note - 36;
final int col = index % 8;
final DrumView view = (DrumView) this.surface.getViewManager().get(Views.DRUM);
if (index / 8 == 1) {
view.setResolutionIndex(col);
return;
}
final INoteClip clip = view.getClip();
switch(col) {
case 0:
clip.scrollStepsPageBackwards();
this.mvHelper.notifyEditPage(clip);
break;
case 1:
clip.scrollStepsPageForward();
this.mvHelper.notifyEditPage(clip);
break;
case 3:
this.model.getTransport().toggleMetronome();
this.surface.scheduleTask(() -> this.surface.getDisplay().notify("Metronome: " + (this.model.getTransport().isMetronomeOn() ? "On" : "Off")), 100);
break;
case 6:
view.onOctaveDown(ButtonEvent.DOWN);
break;
case 7:
view.onOctaveUp(ButtonEvent.DOWN);
break;
default:
// Not used
break;
}
}
Aggregations