Search in sources :

Example 11 with UnknownCommandException

use of de.mossgrabers.controller.osc.exception.UnknownCommandException 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 12 with UnknownCommandException

use of de.mossgrabers.controller.osc.exception.UnknownCommandException in project DrivenByMoss by git-moss.

the class MarkerModule method execute.

/**
 * {@inheritDoc}
 */
@Override
public void execute(final String command, final LinkedList<String> path, final Object value) throws IllegalParameterException, UnknownCommandException, MissingCommandException {
    if (!"marker".equals(command))
        throw new UnknownCommandException(command);
    final String subCommand = getSubCommand(path);
    try {
        final int markerNo = Integer.parseInt(subCommand) - 1;
        final String subCommand2 = getSubCommand(path);
        if ("launch".equals(subCommand2))
            this.model.getMarkerBank().getItem(markerNo).launch(true);
        else
            throw new UnknownCommandException(subCommand2);
    } catch (final NumberFormatException ex) {
        final IMarkerBank markerBank = this.model.getMarkerBank();
        if ("bank".equals(subCommand)) {
            final String subCommand2 = getSubCommand(path);
            switch(subCommand2) {
                case "+":
                    markerBank.selectNextPage();
                    break;
                case "-":
                    markerBank.selectPreviousPage();
                    break;
                default:
                    throw new UnknownCommandException(subCommand2);
            }
        } else
            throw new UnknownCommandException(subCommand);
    }
}
Also used : IMarkerBank(de.mossgrabers.framework.daw.data.bank.IMarkerBank) UnknownCommandException(de.mossgrabers.controller.osc.exception.UnknownCommandException)

Aggregations

UnknownCommandException (de.mossgrabers.controller.osc.exception.UnknownCommandException)12 IllegalParameterException (de.mossgrabers.controller.osc.exception.IllegalParameterException)2 OSCConfiguration (de.mossgrabers.controller.osc.OSCConfiguration)1 MissingCommandException (de.mossgrabers.controller.osc.exception.MissingCommandException)1 IModule (de.mossgrabers.controller.osc.module.IModule)1 IApplication (de.mossgrabers.framework.daw.IApplication)1 IArranger (de.mossgrabers.framework.daw.IArranger)1 IBrowser (de.mossgrabers.framework.daw.IBrowser)1 IClip (de.mossgrabers.framework.daw.IClip)1 IMixer (de.mossgrabers.framework.daw.IMixer)1 INoteClip (de.mossgrabers.framework.daw.INoteClip)1 IProject (de.mossgrabers.framework.daw.IProject)1 Resolution (de.mossgrabers.framework.daw.constants.Resolution)1 ICursorTrack (de.mossgrabers.framework.daw.data.ICursorTrack)1 IScene (de.mossgrabers.framework.daw.data.IScene)1 ISlot (de.mossgrabers.framework.daw.data.ISlot)1 IMarkerBank (de.mossgrabers.framework.daw.data.bank.IMarkerBank)1 IParameterBank (de.mossgrabers.framework.daw.data.bank.IParameterBank)1 ISceneBank (de.mossgrabers.framework.daw.data.bank.ISceneBank)1 ISlotBank (de.mossgrabers.framework.daw.data.bank.ISlotBank)1