use of de.mossgrabers.framework.daw.data.IDrumDevice in project DrivenByMoss by git-moss.
the class AbstractDrum64View method onOctaveDown.
/**
* {@inheritDoc}
*/
@Override
public void onOctaveDown(final ButtonEvent event) {
if (event != ButtonEvent.DOWN)
return;
this.clearPressedKeys();
final int oldDrumOctave = this.drumOctave;
this.drumOctave = Math.max(-2, this.drumOctave - 1);
this.offsetY = DRUM_START_KEY + this.drumOctave * BLOCK_SIZE;
this.updateNoteMapping();
this.surface.getDisplay().notify(this.getDrumRangeText());
if (oldDrumOctave != this.drumOctave) {
final IDrumDevice drumDevice64 = this.model.getDrumDevice64();
final IDrumPadBank drumPadBank = drumDevice64.getDrumPadBank();
for (int i = 0; i < BLOCK_SIZE; i++) drumPadBank.scrollBackwards();
}
}
use of de.mossgrabers.framework.daw.data.IDrumDevice in project DrivenByMoss by git-moss.
the class Kontrol1ControllerSetup method handleTrackChange.
/**
* Handle a track selection change.
*
* @param isSelected Has the track been selected?
*/
private void handleTrackChange(final boolean isSelected) {
if (!isSelected)
return;
this.host.scheduleTask(() -> {
final Kontrol1ControlSurface surface = this.getSurface();
final IView activeView = surface.getViewManager().getActive();
if (activeView != null) {
activeView.updateNoteMapping();
activeView.drawGrid();
}
if (this.model.canSelectedTrackHoldNotes()) {
final IDrumDevice primary = this.model.getDrumDevice();
if (primary.hasDrumPads())
primary.getDrumPadBank().scrollTo(0);
}
}, 100);
}
use of de.mossgrabers.framework.daw.data.IDrumDevice in project DrivenByMoss by git-moss.
the class ControlView method drawGrid.
/**
* {@inheritDoc}
*/
@Override
public void drawGrid() {
final ILightGuide lightGuide = this.surface.getLightGuide();
if (this.model.getHost().supports(Capability.HAS_DRUM_DEVICE) && this.model.canSelectedTrackHoldNotes()) {
final IDrumDevice primary = this.model.getDrumDevice();
if (primary.hasDrumPads()) {
final boolean isRecording = this.model.hasRecordingState();
for (int i = this.scales.getStartNote(); i < this.scales.getEndNote(); i++) lightGuide.light(i, this.getDrumPadColor(i, primary, isRecording));
return;
}
}
this.drawLightGuide(lightGuide);
}
use of de.mossgrabers.framework.daw.data.IDrumDevice 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.IDrumDevice in project DrivenByMoss by git-moss.
the class DrumView method handleSelectButton.
/**
* {@inheritDoc}
*/
@Override
public synchronized void handleSelectButton(final int playedPad) {
// Do we have drum pads?
final IDrumDevice primary = this.model.getDrumDevice();
if (!primary.hasDrumPads())
return;
final ICursorDevice cd = this.model.getCursorDevice();
final boolean isNested = cd.isNested();
if (isNested) {
// We have to move up to compare the main drum devices
cd.selectParent();
}
// Can only scroll to the channel if the cursor device is the primary device
if (primary.getPosition() != cd.getPosition())
return;
// Align the primary and cursor device drum bank view
final IDrumPadBank drumPadBank = primary.getDrumPadBank();
final int scrollPos = drumPadBank.getScrollPosition();
final IDrumPadBank cdDrumPadBank = cd.getDrumPadBank();
final int pageSize = cdDrumPadBank.getPageSize();
final int adjustedPage = playedPad / pageSize * pageSize;
cdDrumPadBank.scrollTo(scrollPos + adjustedPage, false);
// Do not reselect
final IDrumPad drumPad = drumPadBank.getItem(playedPad);
if (drumPad.isSelected()) {
// If the instrument of the pad was selected for editing, try to select it again
if (isNested) {
final IDrumPad selectedItem = cdDrumPadBank.getItem(playedPad % pageSize);
if (selectedItem != null)
selectedItem.enter();
}
return;
}
// Only activate layer mode if not one of the layer modes is already active
final ModeManager modeManager = this.surface.getModeManager();
if (!Modes.isLayerMode(modeManager.getActiveID()))
modeManager.setActive(Modes.DEVICE_LAYER);
drumPad.select();
this.updateNoteMapping();
}
Aggregations