Search in sources :

Example 1 with IClip

use of de.mossgrabers.framework.daw.IClip in project DrivenByMoss by git-moss.

the class ColorView method onGridNote.

/**
 * {@inheritDoc}
 */
@Override
public void onGridNote(final int note, final int velocity) {
    if (velocity > 0)
        return;
    final int offset = this.page * this.pageSize;
    final int color = offset + note - 36;
    final DAWColor[] dawColors = DAWColor.values();
    if (color < dawColors.length) {
        final ColorEx entry = dawColors[color].getColor();
        switch(this.mode) {
            case MODE_TRACK:
                final ITrack cursorTrack = this.model.getCursorTrack();
                if (cursorTrack.doesExist())
                    cursorTrack.setColor(entry);
                else {
                    final IMasterTrack master = this.model.getMasterTrack();
                    if (master.isSelected())
                        master.setColor(entry);
                }
                break;
            case MODE_LAYER:
                final IBank<? extends ILayer> layerBank = this.getLayerBank();
                final Optional<?> selectedItem = layerBank.getSelectedItem();
                if (selectedItem.isPresent())
                    ((ILayer) selectedItem.get()).setColor(entry);
                break;
            case MODE_CLIP:
                final IClip clip = this.model.getCursorClip();
                if (clip.doesExist())
                    clip.setColor(entry);
                break;
        }
    }
    this.surface.getViewManager().restore();
}
Also used : ITrack(de.mossgrabers.framework.daw.data.ITrack) DAWColor(de.mossgrabers.framework.daw.DAWColor) ColorEx(de.mossgrabers.framework.controller.color.ColorEx) IClip(de.mossgrabers.framework.daw.IClip) IMasterTrack(de.mossgrabers.framework.daw.data.IMasterTrack)

Example 2 with IClip

use of de.mossgrabers.framework.daw.IClip in project DrivenByMoss by git-moss.

the class ShiftView method onGridNote.

/**
 * {@inheritDoc}
 */
@Override
public void onGridNote(final int note, final int velocity) {
    if (velocity != 0)
        return;
    final ICursorDevice cursorDevice = this.model.getCursorDevice();
    final int n = this.surface.getPadGrid().translateToController(note)[1];
    switch(n) {
        // Flip views
        case 56:
            this.switchToView(Views.SESSION);
            break;
        case 57:
            this.switchToView(Views.PLAY);
            break;
        case 58:
            this.switchToView(Views.DRUM);
            break;
        case 59:
            this.switchToView(Views.SEQUENCER);
            break;
        case 60:
            this.switchToView(Views.RAINDROPS);
            break;
        // Last row transport
        case 63:
            this.playCommand.executeNormal(ButtonEvent.UP);
            this.surface.getDisplay().notify("Start/Stop");
            break;
        case 55:
            this.model.getTransport().startRecording();
            this.surface.getDisplay().notify("Record");
            break;
        case 47:
            this.model.getTransport().toggleLoop();
            this.surface.getDisplay().notify("Toggle Loop");
            break;
        case 39:
            this.model.getTransport().toggleMetronome();
            this.surface.getDisplay().notify("Toggle Click");
            break;
        // Navigation
        case 62:
            this.newCommand.execute();
            this.surface.getDisplay().notify("New clip");
            break;
        case 54:
            this.model.getTransport().toggleLauncherOverdub();
            this.surface.getDisplay().notify("Toggle Launcher Overdub");
            break;
        case 46:
            final IClip clip = this.model.getCursorClip();
            if (clip.doesExist())
                clip.quantize(this.surface.getConfiguration().getQuantizeAmount() / 100.0);
            this.surface.getDisplay().notify("Quantize");
            break;
        case 38:
            this.model.getApplication().undo();
            this.surface.getDisplay().notify("Undo");
            break;
        // Device Parameters up/down
        case 24:
            this.scrollParameterBank(true, cursorDevice);
            break;
        case 25:
            this.scrollParameterBank(false, cursorDevice);
            break;
        // Device up/down
        case 32:
            if (cursorDevice.canSelectPreviousFX()) {
                cursorDevice.selectPrevious();
                this.surface.getDisplay().notify("Device: " + cursorDevice.getName());
            }
            break;
        case 33:
            if (cursorDevice.canSelectNextFX()) {
                cursorDevice.selectNext();
                this.surface.getDisplay().notify("Device: " + cursorDevice.getName());
            }
            break;
        // Change the scale
        case 35:
            this.scales.prevScale();
            final String name = this.scales.getScale().getName();
            this.surface.getConfiguration().setScale(name);
            this.surface.getDisplay().notify(name);
            break;
        case 36:
            this.scales.nextScale();
            final String name2 = this.scales.getScale().getName();
            this.surface.getConfiguration().setScale(name2);
            this.surface.getDisplay().notify(name2);
            break;
        case 27:
            this.scales.toggleChromatic();
            this.surface.getDisplay().notify(this.scales.isChromatic() ? "Chromatic" : "In Key");
            break;
        // Scale Base note selection
        default:
            if (n > 15)
                return;
            final int pos = TRANSLATE[n];
            if (pos == -1)
                return;
            this.scales.setScaleOffset(pos);
            this.surface.getConfiguration().setScaleBase(Scales.BASES.get(pos));
            this.surface.getDisplay().notify(Scales.BASES.get(pos));
            this.surface.getViewManager().getActive().updateNoteMapping();
            break;
    }
}
Also used : IClip(de.mossgrabers.framework.daw.IClip) ICursorDevice(de.mossgrabers.framework.daw.data.ICursorDevice)

Example 3 with IClip

use of de.mossgrabers.framework.daw.IClip in project DrivenByMoss by git-moss.

the class TransportModule method execute.

/**
 * {@inheritDoc}
 */
@Override
public void execute(final String command, final LinkedList<String> path, final Object value) throws IllegalParameterException, UnknownCommandException, MissingCommandException {
    final boolean isTrigger = isTrigger(value);
    switch(command) {
        case "play":
            final boolean isPlaying = this.transport.isPlaying();
            if (isTrigger && !isPlaying || !isTrigger && isPlaying)
                this.transport.play();
            break;
        case "playbutton":
            if (isTrigger)
                this.playCommand.execute(ButtonEvent.DOWN, 127);
            break;
        case "stop":
            if (this.transport.isPlaying())
                this.transport.stop();
            else
                this.transport.stopAndRewind();
            break;
        case "restart":
            if (isTrigger)
                this.transport.restart();
            break;
        case "record":
            this.transport.startRecording();
            break;
        case "overdub":
            if (!path.isEmpty() && TAG_LAUNCHER.equals(path.get(0)))
                this.transport.toggleLauncherOverdub();
            else
                this.transport.toggleOverdub();
            break;
        case "repeat":
            if (value == null)
                this.transport.toggleLoop();
            else
                this.transport.setLoop(isTrigger);
            break;
        case "punchIn":
            if (value == null)
                this.transport.togglePunchIn();
            else
                this.transport.setPunchIn(isTrigger);
            break;
        case "punchOut":
            if (value == null)
                this.transport.togglePunchOut();
            else
                this.transport.setPunchOut(isTrigger);
            break;
        case "click":
            if (path.isEmpty()) {
                if (value == null)
                    this.transport.toggleMetronome();
                else
                    this.transport.setMetronome(isTrigger);
                break;
            }
            final String subCommand = getSubCommand(path);
            switch(subCommand) {
                case "volume":
                    this.transport.setMetronomeVolume(toInteger(value));
                    break;
                case "ticks":
                    if (value == null)
                        this.transport.toggleMetronomeTicks();
                    else
                        this.transport.setMetronomeTicks(isTrigger);
                    break;
                case TAG_PREROLL:
                    if (isTrigger)
                        this.transport.togglePrerollMetronome();
                    break;
                default:
                    throw new UnknownCommandException(subCommand);
            }
            break;
        case "quantize":
            final IClip clip = this.getClip();
            if (clip.doesExist())
                clip.quantize(1);
            break;
        case "tempo":
            final String tempoCommand = getSubCommand(path);
            switch(tempoCommand) {
                case "raw":
                    this.transport.setTempo(toNumber(value));
                    break;
                case "tap":
                    if (isTrigger)
                        this.transport.tapTempo();
                    break;
                case "+":
                    this.transport.setTempo(this.transport.getTempo() + toNumber(value, 1.0));
                    break;
                case "-":
                    this.transport.setTempo(this.transport.getTempo() - toNumber(value, 1.0));
                    break;
                default:
                    throw new UnknownCommandException(tempoCommand);
            }
            break;
        case "time":
            this.transport.setPosition(toNumber(value));
            break;
        case "position":
            if (path.isEmpty()) {
                final double numValue = toNumber(value);
                this.transport.changePosition(numValue >= 0, Math.abs(numValue) <= 1);
                break;
            }
            final String positionCommand = path.get(0);
            switch(positionCommand) {
                case "+":
                    this.transport.changePosition(true, true);
                    break;
                case "-":
                    this.transport.changePosition(false, true);
                    break;
                case "++":
                    this.transport.changePosition(true, false);
                    break;
                case "--":
                    this.transport.changePosition(false, false);
                    break;
                case "start":
                    this.transport.setPosition(0);
                    break;
                default:
                    throw new UnknownCommandException(positionCommand);
            }
            break;
        case "crossfade":
            this.transport.setCrossfade(toInteger(value));
            break;
        case "autowrite":
            if (!path.isEmpty() && TAG_LAUNCHER.equals(path.get(0)))
                this.transport.toggleWriteClipLauncherAutomation();
            else
                this.transport.toggleWriteArrangerAutomation();
            break;
        case "automationWriteMode":
            if (value != null)
                this.transport.setAutomationWriteMode(AutomationMode.valueOf(value.toString().toUpperCase(Locale.US)));
            break;
        case TAG_PREROLL:
            this.transport.setPrerollAsBars(toInteger(value));
            break;
        case TAG_LAUNCHER:
            final String launcherCommand = path.get(0);
            switch(launcherCommand) {
                case "postRecordingAction":
                    this.transport.setClipLauncherPostRecordingAction(PostRecordingAction.lookup(value.toString()));
                    break;
                case "postRecordingTimeOffset":
                    final double beats = Math.min(4000, Math.max(0, toNumber(value)));
                    this.transport.setClipLauncherPostRecordingTimeOffset(beats);
                    break;
                case "defaultQuantization":
                    this.transport.setDefaultLaunchQuantization(LaunchQuantization.lookup(value.toString()));
                    break;
                default:
                    throw new UnknownCommandException(launcherCommand);
            }
            break;
        default:
            throw new UnknownCommandException(command);
    }
}
Also used : UnknownCommandException(de.mossgrabers.controller.osc.exception.UnknownCommandException) IClip(de.mossgrabers.framework.daw.IClip)

Aggregations

IClip (de.mossgrabers.framework.daw.IClip)3 UnknownCommandException (de.mossgrabers.controller.osc.exception.UnknownCommandException)1 ColorEx (de.mossgrabers.framework.controller.color.ColorEx)1 DAWColor (de.mossgrabers.framework.daw.DAWColor)1 ICursorDevice (de.mossgrabers.framework.daw.data.ICursorDevice)1 IMasterTrack (de.mossgrabers.framework.daw.data.IMasterTrack)1 ITrack (de.mossgrabers.framework.daw.data.ITrack)1