Search in sources :

Example 16 with ISlot

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();
}
Also used : ISlot(de.mossgrabers.framework.daw.data.ISlot)

Example 17 with ISlot

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);
    }
}
Also used : ISlotBank(de.mossgrabers.framework.daw.data.bank.ISlotBank) ICursorTrack(de.mossgrabers.framework.daw.data.ICursorTrack) UnknownCommandException(de.mossgrabers.controller.osc.exception.UnknownCommandException) ISlot(de.mossgrabers.framework.daw.data.ISlot) INoteClip(de.mossgrabers.framework.daw.INoteClip)

Example 18 with ISlot

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);
}
Also used : ISlotBank(de.mossgrabers.framework.daw.data.bank.ISlotBank) ITrack(de.mossgrabers.framework.daw.data.ITrack) ISlot(de.mossgrabers.framework.daw.data.ISlot)

Example 19 with ISlot

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);
}
Also used : ISlotBank(de.mossgrabers.framework.daw.data.bank.ISlotBank) ITrack(de.mossgrabers.framework.daw.data.ITrack) ISlot(de.mossgrabers.framework.daw.data.ISlot)

Example 20 with ISlot

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();
}
Also used : ITrack(de.mossgrabers.framework.daw.data.ITrack) ISlot(de.mossgrabers.framework.daw.data.ISlot)

Aggregations

ISlot (de.mossgrabers.framework.daw.data.ISlot)25 ITrack (de.mossgrabers.framework.daw.data.ITrack)19 IChannelBank (de.mossgrabers.framework.daw.IChannelBank)7 ISlotBank (de.mossgrabers.framework.daw.data.bank.ISlotBank)5 AbstractConfiguration (de.mossgrabers.framework.configuration.AbstractConfiguration)2 ColorEx (de.mossgrabers.framework.controller.color.ColorEx)2 MaschineConfiguration (de.mossgrabers.controller.ni.maschine.mk3.MaschineConfiguration)1 UnknownCommandException (de.mossgrabers.controller.osc.exception.UnknownCommandException)1 IPadGrid (de.mossgrabers.framework.controller.grid.IPadGrid)1 INoteClip (de.mossgrabers.framework.daw.INoteClip)1 ITrackBank (de.mossgrabers.framework.daw.ITrackBank)1 ICursorTrack (de.mossgrabers.framework.daw.data.ICursorTrack)1 ITrackBank (de.mossgrabers.framework.daw.data.bank.ITrackBank)1 ChannelType (de.mossgrabers.framework.daw.resource.ChannelType)1 IGraphicsConfiguration (de.mossgrabers.framework.graphics.IGraphicsConfiguration)1 IGraphicsContext (de.mossgrabers.framework.graphics.IGraphicsContext)1 IGraphicsDimensions (de.mossgrabers.framework.graphics.IGraphicsDimensions)1 ModeManager (de.mossgrabers.framework.mode.ModeManager)1 Matcher (java.util.regex.Matcher)1