use of de.mossgrabers.framework.daw.data.ISlot in project DrivenByMoss by git-moss.
the class SlotBankImpl method getEmptySlot.
/**
* {@inheritDoc}
*/
@Override
public Optional<ISlot> getEmptySlot(final int startFrom) {
final int start = startFrom >= 0 ? startFrom : 0;
final int size = this.items.size();
for (int i = 0; i < size; i++) {
final ISlot item = this.items.get((start + i) % size);
if (!item.hasContent())
return Optional.of(item);
}
return Optional.empty();
}
use of de.mossgrabers.framework.daw.data.ISlot in project DrivenByMoss by git-moss.
the class ClipModule method execute.
/**
* {@inheritDoc}
*/
@Override
public void execute(final String command, final LinkedList<String> path, final Object value) throws IllegalParameterException, UnknownCommandException, MissingCommandException {
if (!"clip".equals(command))
throw new UnknownCommandException(command);
final String subCommand = getSubCommand(path);
if ("stopall".equals(subCommand)) {
this.model.getTrackBank().stop();
return;
}
// Cursor clip related commands
final INoteClip cursorClip = this.model.getCursorClip();
switch(subCommand) {
case "pinned":
if (value == null)
cursorClip.togglePinned();
else
cursorClip.setPinned(isTrigger(value));
return;
case "quantize":
if (cursorClip.doesExist())
cursorClip.quantize(1);
return;
default:
// Fall through
break;
}
// Slot bank related commands
final ICursorTrack cursorTrack = this.model.getCursorTrack();
if (!cursorTrack.doesExist())
return;
if ("stop".equals(subCommand)) {
cursorTrack.stop();
return;
}
final ISlotBank slotBank = cursorTrack.getSlotBank();
switch(subCommand) {
case "+":
slotBank.selectNextItem();
return;
case "-":
slotBank.selectPreviousItem();
return;
default:
// Fall through
break;
}
final Optional<ISlot> selectedSlotOptional = slotBank.getSelectedItem();
if (selectedSlotOptional.isEmpty())
return;
final ISlot selectedSlot = selectedSlotOptional.get();
switch(subCommand) {
case "launch":
selectedSlot.launch();
return;
case "record":
this.model.recordNoteClip(cursorTrack, selectedSlot);
return;
case "create":
this.model.createNoteClip(cursorTrack, selectedSlot, toInteger(value), true);
return;
default:
throw new UnknownCommandException(command);
}
}
use of de.mossgrabers.framework.daw.data.ISlot in project DrivenByMoss by git-moss.
the class DuplicateCommand method executeNormal.
/**
* {@inheritDoc}
*/
@Override
public void executeNormal(final ButtonEvent event) {
if (event != ButtonEvent.UP)
return;
// Is there a selected track?
final ITrack cursorTrack = this.model.getCursorTrack();
if (!cursorTrack.doesExist())
return;
// Is there a selected slot?
final ISlotBank slotBank = cursorTrack.getSlotBank();
final Optional<ISlot> slot = slotBank.getSelectedItem();
if (slot.isEmpty())
return;
final boolean isPlaying = slot.get().isPlaying();
// Duplicate the clip in the selected slot
slot.get().duplicate();
if (!isPlaying)
return;
// Need to wait a bit with starting the duplicated clip until it is selected
this.model.getHost().scheduleTask(() -> {
final Optional<ISlot> slotNew = slotBank.getSelectedItem();
if (slotNew.isPresent()) {
slotNew.get().launch();
return;
}
// Try to find the clip in the next page...
slotBank.selectNextPage();
this.model.getHost().scheduleTask(() -> {
final Optional<ISlot> slotNew2 = slotBank.getSelectedItem();
if (slotNew2.isPresent())
slotNew2.get().launch();
}, 200);
}, 200);
}
use of de.mossgrabers.framework.daw.data.ISlot in project DrivenByMoss by git-moss.
the class NewCommand method handleExecute.
/**
* Execute the new command.
*
* @param enableOverdub True to enable overdub for the new clip
*/
public void handleExecute(final boolean enableOverdub) {
final ITrack cursorTrack = this.model.getCursorTrack();
if (!cursorTrack.doesExist()) {
this.surface.getDisplay().notify("Please select an Instrument track first.");
return;
}
final ISlotBank slotBank = cursorTrack.getSlotBank();
final Optional<ISlot> selectedSlot = slotBank.getSelectedItem();
final int slotIndex = selectedSlot.isEmpty() ? 0 : selectedSlot.get().getIndex();
final Optional<ISlot> slot = slotBank.getEmptySlot(slotIndex);
if (slot.isEmpty()) {
this.surface.getDisplay().notify("No empty slot in the current page. Please scroll down.");
return;
}
this.model.createNoteClip(cursorTrack, slot.get(), this.getClipLength(), enableOverdub);
}
use of de.mossgrabers.framework.daw.data.ISlot in project DrivenByMoss by git-moss.
the class AbstractSessionView method onGridNoteLongPress.
/**
* {@inheritDoc}
*/
@Override
public void onGridNoteLongPress(final int note) {
final Pair<Integer, Integer> padPos = this.getPad(note);
final ITrack track = this.model.getCurrentTrackBank().getItem(padPos.getKey().intValue());
final ISlot slot = track.getSlotBank().getItem(padPos.getValue().intValue());
slot.select();
final int index = note - 36;
this.surface.getButton(ButtonID.get(ButtonID.PAD1, index)).setConsumed();
}
Aggregations