Search in sources :

Example 11 with ITrackBank

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

the class TrackView method onGridNote.

/**
 * {@inheritDoc}
 */
@Override
public void onGridNote(final int note, final int velocity) {
    if (velocity == 0)
        return;
    final IChannelBank tb = this.model.getCurrentTrackBank();
    int track;
    ITrack selectedTrack;
    ITrack sel;
    int index;
    int newSel;
    switch(note - 36) {
        // Toggle Activate
        case 0:
            selectedTrack = tb.getSelectedTrack();
            if (selectedTrack != null)
                selectedTrack.toggleIsActivated();
            break;
        // Track left
        case 1:
            sel = tb.getSelectedTrack();
            index = sel == null ? 0 : sel.getIndex() - 1;
            if (index == -1 || this.surface.isShiftPressed()) {
                if (!tb.canScrollTracksUp())
                    return;
                tb.scrollTracksPageUp();
                newSel = index == -1 || sel == null ? 7 : sel.getIndex();
                this.surface.scheduleTask(() -> this.selectTrack(newSel), 75);
                return;
            }
            this.selectTrack(index);
            break;
        // Track right
        case 2:
            sel = tb.getSelectedTrack();
            index = sel == null ? 0 : sel.getIndex() + 1;
            if (index == 8 || this.surface.isShiftPressed()) {
                if (!tb.canScrollTracksDown())
                    return;
                tb.scrollTracksPageDown();
                newSel = index == 8 || sel == null ? 0 : sel.getIndex();
                this.surface.scheduleTask(() -> this.selectTrack(newSel), 75);
                return;
            }
            this.selectTrack(index);
            break;
        // Move down
        case 3:
            if (tb instanceof ITrackBank)
                ((ITrackBank) tb).selectChildren();
            break;
        // Move up
        case 4:
            if (tb instanceof ITrackBank)
                ((ITrackBank) tb).selectParent();
            break;
        // Unused
        case 5:
            break;
        // Track Page down
        case 6:
            this.scrollTracksLeft();
            break;
        // Track Page up
        case 7:
            this.scrollTracksRight();
            break;
        default:
            track = note - 36 - 8;
            this.selectTrack(track);
            break;
    }
}
Also used : ITrack(de.mossgrabers.framework.daw.data.ITrack) ITrackBank(de.mossgrabers.framework.daw.ITrackBank) IChannelBank(de.mossgrabers.framework.daw.IChannelBank)

Example 12 with ITrackBank

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

the class SessionView method onSession.

/**
 * The session button was pressed.
 *
 * @param event The button event
 */
public void onSession(final ButtonEvent event) {
    switch(event) {
        case LONG:
            this.isTemporary = true;
            break;
        case UP:
            if (!this.isTemporary)
                return;
            this.isTemporary = false;
            final ViewManager viewManager = this.surface.getViewManager();
            final ITrackBank tb = this.model.getTrackBank();
            final ITrack selectedTrack = tb.getSelectedTrack();
            if (selectedTrack == null)
                return;
            final Integer viewId = viewManager.getPreferredView(selectedTrack.getPosition());
            viewManager.setActiveView(viewId == null ? Views.VIEW_PLAY : viewId);
            break;
        default:
            // Intentionally empty
            return;
    }
}
Also used : ITrack(de.mossgrabers.framework.daw.data.ITrack) ITrackBank(de.mossgrabers.framework.daw.ITrackBank) ViewManager(de.mossgrabers.framework.view.ViewManager)

Example 13 with ITrackBank

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

the class MCUControllerSetup method createModel.

/**
 * {@inheritDoc}
 */
@Override
protected void createModel() {
    this.model = this.factory.createModel(this.colorManager, this.valueChanger, this.scales, 8 * this.numMCUDevices, 8, 8, 8, 8, true, 8 * this.numMCUDevices, -1, -1, -1);
    final ITrackBank trackBank = this.model.getTrackBank();
    trackBank.setIndication(true);
    trackBank.addTrackSelectionObserver(this::handleTrackChange);
    this.model.getMasterTrack().addTrackSelectionObserver((index, isSelected) -> {
        final ModeManager modeManager = this.getSurface().getModeManager();
        if (isSelected)
            modeManager.setActiveMode(Modes.MODE_MASTER);
        else
            modeManager.restoreMode();
    });
}
Also used : ITrackBank(de.mossgrabers.framework.daw.ITrackBank) ModeManager(de.mossgrabers.framework.mode.ModeManager)

Example 14 with ITrackBank

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

the class OSCParser method parseTrackCommands.

private void parseTrackCommands(final LinkedList<String> oscParts, final Object value, final int numValue) {
    if (oscParts.isEmpty()) {
        this.host.errorln("Missing Track command.");
        return;
    }
    final IChannelBank tb = this.model.getCurrentTrackBank();
    final String command = oscParts.removeFirst();
    switch(command) {
        case PART_INDICATE:
            {
                if (oscParts.isEmpty()) {
                    this.host.errorln("Missing Indicate subcommand.");
                    return;
                }
                final boolean isTrue = numValue > 0;
                final String subCommand = oscParts.removeFirst();
                switch(subCommand) {
                    case PART_VOLUME:
                        for (int i = 0; i < tb.getNumTracks(); i++) tb.getTrack(i).setVolumeIndication(isTrue);
                        break;
                    case "pan":
                        for (int i = 0; i < tb.getNumTracks(); i++) tb.getTrack(i).setPanIndication(isTrue);
                        break;
                    case "send":
                        if (tb instanceof ITrackBank) {
                            final int sendIndex = Integer.parseInt(oscParts.get(0));
                            for (int i = 0; i < tb.getNumTracks(); i++) tb.getTrack(i).getSend(sendIndex - 1).setIndication(isTrue);
                        }
                        break;
                    default:
                        this.host.errorln("Unknown Indicate subcommand: " + subCommand);
                        break;
                }
                break;
            }
        case "bank":
            if (oscParts.isEmpty()) {
                this.host.errorln("Missing Track Bank subcommand.");
                return;
            }
            final String subCommand = oscParts.removeFirst();
            switch(subCommand) {
                case "page":
                    if (oscParts.isEmpty()) {
                        this.host.errorln("Missing Track Bank Page subcommand.");
                        return;
                    }
                    if ("+".equals(oscParts.removeFirst())) {
                        if (!tb.canScrollTracksDown())
                            return;
                        tb.scrollTracksPageDown();
                        this.host.scheduleTask(() -> tb.getTrack(0).selectAndMakeVisible(), 75);
                    } else // "-"
                    {
                        if (!tb.canScrollTracksUp())
                            return;
                        tb.scrollTracksPageUp();
                        this.host.scheduleTask(() -> tb.getTrack(7).selectAndMakeVisible(), 75);
                    }
                    break;
                case "+":
                    tb.scrollTracksDown();
                    break;
                case "-":
                    tb.scrollTracksUp();
                    break;
                default:
                    this.host.errorln("Unknown Track Bank subcommand: " + subCommand);
                    break;
            }
            break;
        case "+":
            {
                final ITrack sel = tb.getSelectedTrack();
                final int index = sel == null ? 0 : sel.getIndex() + 1;
                if (index == tb.getNumTracks()) {
                    if (!tb.canScrollTracksDown())
                        return;
                    tb.scrollTracksPageDown();
                    this.host.scheduleTask(() -> tb.getTrack(0).selectAndMakeVisible(), 75);
                    return;
                }
                tb.getTrack(index).selectAndMakeVisible();
                break;
            }
        case "-":
            {
                final ITrack sel = tb.getSelectedTrack();
                final int index = sel == null ? 0 : sel.getIndex() - 1;
                if (index == -1) {
                    if (!tb.canScrollTracksUp())
                        return;
                    tb.scrollTracksPageUp();
                    this.host.scheduleTask(() -> tb.getTrack(7).selectAndMakeVisible(), 75);
                    return;
                }
                tb.getTrack(index).selectAndMakeVisible();
                break;
            }
        case "add":
            if (oscParts.isEmpty()) {
                this.host.errorln("Missing Add subcommand.");
                return;
            }
            final String subCommand2 = oscParts.removeFirst();
            final IApplication application = this.model.getApplication();
            switch(subCommand2) {
                case "audio":
                    application.addAudioTrack();
                    break;
                case "effect":
                    application.addEffectTrack();
                    break;
                case "instrument":
                    application.addInstrumentTrack();
                    break;
                default:
                    this.host.errorln("Unknown Add subcommand: " + subCommand2);
                    break;
            }
            break;
        case "stop":
            this.model.getCurrentTrackBank().stop();
            break;
        case "vu":
            this.configuration.setVUMetersEnabled(numValue > 0);
            break;
        case "toggleBank":
            {
                this.model.toggleCurrentTrackBank();
                final IChannelBank tbNew = this.model.getCurrentTrackBank();
                // Make sure a track is selected
                final IChannelBank tbOther = this.model.isEffectTrackBankActive() ? this.model.getTrackBank() : this.model.getEffectTrackBank();
                final ITrack selectedTrack = tbNew.getSelectedTrack();
                if (selectedTrack == null)
                    tbNew.getTrack(0).selectAndMakeVisible();
                // Move the indication to the other bank
                for (int i = 0; i < tbNew.getNumTracks(); i++) {
                    final ITrack otherTrack = tbOther.getTrack(i);
                    otherTrack.setVolumeIndication(false);
                    otherTrack.setPanIndication(false);
                    final ITrack track = tbNew.getTrack(i);
                    track.setVolumeIndication(true);
                    track.setPanIndication(true);
                }
                break;
            }
        case "parent":
            {
                if (tb instanceof ITrackBank)
                    ((ITrackBank) tb).selectParent();
                break;
            }
        case "selected":
            final ITrack selectedTrack = tb.getSelectedTrack();
            if (selectedTrack != null)
                this.parseTrackValue(selectedTrack, oscParts, value);
            break;
        default:
            this.host.println("Unknown Track Command: " + command);
            break;
    }
}
Also used : IApplication(de.mossgrabers.framework.daw.IApplication) ITrack(de.mossgrabers.framework.daw.data.ITrack) ITrackBank(de.mossgrabers.framework.daw.ITrackBank) IChannelBank(de.mossgrabers.framework.daw.IChannelBank)

Example 15 with ITrackBank

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

the class OSCParser method parseTrackValue.

private void parseTrackValue(final ITrack track, final LinkedList<String> parts, final Object value) {
    final double numValue = value instanceof Number ? ((Number) value).doubleValue() : -1;
    final int intValue = value instanceof Number ? ((Number) value).intValue() : -1;
    if (parts.isEmpty()) {
        this.host.errorln("Missing Track command.");
        return;
    }
    final String command = parts.removeFirst();
    switch(command) {
        case "activated":
            track.setIsActivated(intValue > 0);
            break;
        case "crossfadeMode":
            if (numValue == 1)
                track.setCrossfadeMode(parts.removeFirst());
            break;
        case "selected":
            if (intValue > 0)
                track.selectAndMakeVisible();
            break;
        case PART_VOLUME:
            if (parts.isEmpty())
                track.setVolume(numValue);
            else if (PART_INDICATE.equals(parts.get(0)))
                track.setVolumeIndication(numValue > 0);
            else if (PART_RESET.equals(parts.get(0)))
                track.resetVolume();
            else if (PART_TOUCH.equals(parts.get(0)))
                track.touchVolume(numValue > 0);
            break;
        case "pan":
            if (parts.isEmpty())
                track.setPan(numValue);
            else if (PART_INDICATE.equals(parts.get(0)))
                track.setPanIndication(numValue > 0);
            else if (PART_RESET.equals(parts.get(0)))
                track.resetPan();
            else if (PART_TOUCH.equals(parts.get(0)))
                track.touchPan(numValue > 0);
            break;
        case "mute":
            if (numValue < 0)
                track.toggleMute();
            else
                track.setMute(numValue > 0);
            break;
        case "solo":
            if (numValue < 0)
                track.toggleSolo();
            else
                track.setSolo(numValue > 0);
            break;
        case "recarm":
            if (numValue < 0)
                track.toggleRecArm();
            else
                track.setRecArm(numValue > 0);
            break;
        case "monitor":
            if (numValue < 0)
                track.toggleMonitor();
            else
                track.setMonitor(numValue > 0);
            break;
        case "autoMonitor":
            if (numValue < 0)
                track.toggleAutoMonitor();
            else
                track.setAutoMonitor(numValue > 0);
            break;
        case "send":
            final int sendNo = Integer.parseInt(parts.removeFirst());
            this.parseSendValue(track, sendNo - 1, parts, value);
            break;
        case "clip":
            if (parts.isEmpty()) {
                this.host.errorln("Missing Clip subcommand.");
                return;
            }
            final String cmd = parts.removeFirst();
            try {
                final int clipNo = Integer.parseInt(cmd);
                if (parts.isEmpty()) {
                    this.host.errorln("Missing Clip subcommand.");
                    return;
                }
                final String clipCommand = parts.removeFirst();
                final ISlot slot = track.getSlot(clipNo - 1);
                switch(clipCommand) {
                    case "select":
                        slot.select();
                        break;
                    case "launch":
                        slot.launch();
                        break;
                    case "record":
                        slot.record();
                        break;
                    case "color":
                        final Matcher matcher = RGB_COLOR_PATTERN.matcher(value.toString());
                        if (!matcher.matches())
                            return;
                        final int count = matcher.groupCount();
                        if (count != 7)
                            return;
                        slot.setColor(Double.parseDouble(matcher.group(2)) / 255.0, Double.parseDouble(matcher.group(4)) / 255.0, Double.parseDouble(matcher.group(6)) / 255.0);
                        break;
                    default:
                        this.host.println("Unknown Clip subcommand: " + clipCommand);
                        break;
                }
            } catch (final NumberFormatException ex) {
                switch(cmd) {
                    case "stop":
                        track.stop();
                        break;
                    case "returntoarrangement":
                        track.returnToArrangement();
                        break;
                    default:
                        this.host.println("Unknown Clip command: " + cmd);
                        break;
                }
            }
            break;
        case "enter":
            final IChannelBank tb = this.model.getCurrentTrackBank();
            if (tb instanceof ITrackBank) {
                track.select();
                ((ITrackBank) tb).selectChildren();
            }
            break;
        case "color":
            final Matcher matcher = RGB_COLOR_PATTERN.matcher(value.toString());
            if (!matcher.matches())
                return;
            final int count = matcher.groupCount();
            if (count == 7)
                track.setColor(Double.parseDouble(matcher.group(2)) / 255.0, Double.parseDouble(matcher.group(4)) / 255.0, Double.parseDouble(matcher.group(6)) / 255.0);
            break;
        default:
            this.host.println("Unknown Track Parameter: " + command);
            break;
    }
}
Also used : Matcher(java.util.regex.Matcher) ITrackBank(de.mossgrabers.framework.daw.ITrackBank) IChannelBank(de.mossgrabers.framework.daw.IChannelBank) ISlot(de.mossgrabers.framework.daw.data.ISlot)

Aggregations

ITrackBank (de.mossgrabers.framework.daw.ITrackBank)25 IChannelBank (de.mossgrabers.framework.daw.IChannelBank)20 ITrack (de.mossgrabers.framework.daw.data.ITrack)18 ICursorDevice (de.mossgrabers.framework.daw.ICursorDevice)7 PushConfiguration (de.mossgrabers.push.PushConfiguration)5 ModeManager (de.mossgrabers.framework.mode.ModeManager)4 ViewManager (de.mossgrabers.framework.view.ViewManager)4 IValueChanger (de.mossgrabers.framework.controller.IValueChanger)3 DisplayMessage (de.mossgrabers.push.controller.DisplayMessage)3 PushDisplay (de.mossgrabers.push.controller.PushDisplay)3 IMasterTrack (de.mossgrabers.framework.daw.data.IMasterTrack)2 ISend (de.mossgrabers.framework.daw.data.ISend)2 PushControlSurface (de.mossgrabers.push.controller.PushControlSurface)2 APCControlSurface (de.mossgrabers.apc.controller.APCControlSurface)1 APCminiControlSurface (de.mossgrabers.apcmini.controller.APCminiControlSurface)1 BeatstepControlSurface (de.mossgrabers.beatstep.controller.BeatstepControlSurface)1 IApplication (de.mossgrabers.framework.daw.IApplication)1 ISlot (de.mossgrabers.framework.daw.data.ISlot)1 SceneView (de.mossgrabers.framework.view.SceneView)1 View (de.mossgrabers.framework.view.View)1