Search in sources :

Example 21 with ISlot

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

the class SessionMode method updateDisplay1Clips.

private void updateDisplay1Clips(final ITextDisplay display) {
    final ITrackBank tb = this.model.getCurrentTrackBank();
    final int numTracks = tb.getPageSize();
    final int numScenes = tb.getSceneBank().getPageSize();
    final boolean flipSession = this.surface.getConfiguration().isFlipSession();
    final int maxCols = flipSession ? numScenes : numTracks;
    int maxRows = flipSession ? numTracks : numScenes;
    if (this.rowDisplayMode != RowDisplayMode.ALL)
        maxRows = maxRows / 2;
    for (int col = 0; col < maxCols; col++) {
        for (int row = 0; row < maxRows; row++) {
            int x = flipSession ? row : col;
            int y = flipSession ? col : row;
            if (this.rowDisplayMode == RowDisplayMode.LOWER) {
                if (flipSession)
                    x += maxRows;
                else
                    y += maxRows;
            }
            final ITrack track = tb.getItem(x);
            final ISlot slot = track.getSlotBank().getItem(y);
            if (!slot.doesExist())
                continue;
            String name = slot.getName(8);
            if (track.isGroup()) {
                if (name.isEmpty())
                    name = "Scene " + (slot.getPosition() + 1);
            } else {
                // https://github.com/teotigraphix/Framework4Bitwig/issues/193
                if (name.isEmpty()) {
                    final ColorEx color = slot.getColor();
                    if (color.getRed() != 0 || color.getGreen() != 0 || color.getBlue() != 0)
                        name = "--------";
                }
            }
            if (slot.isSelected())
                name = Push1Display.SELECT_ARROW + name;
            else if (slot.isPlaying())
                name = ">" + name;
            else if (slot.isPlayingQueued() || slot.isRecordingQueued())
                name = ")" + name;
            else if (track.isRecArm() || slot.isRecording())
                name = "*" + name;
            else if (slot.hasContent())
                name = Push1Display.RIGHT_ARROW + name;
            else
                name = Push1Display.DEGREE + name;
            display.setCell(row, col, StringUtils.shortenAndFixASCII(name, 8));
        }
    }
}
Also used : ITrack(de.mossgrabers.framework.daw.data.ITrack) ITrackBank(de.mossgrabers.framework.daw.data.bank.ITrackBank) ColorEx(de.mossgrabers.framework.controller.color.ColorEx) ISlot(de.mossgrabers.framework.daw.data.ISlot)

Example 22 with ISlot

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

the class SessionView method onGridNoteLongPress.

/**
 * {@inheritDoc}
 */
@Override
public void onGridNoteLongPress(final int note) {
    final int modeIndex = this.getControlModeIndex(note);
    if (modeIndex >= 0)
        return;
    // Cannot call the super method here since the setConsumed would store the wrong button
    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)

Example 23 with ISlot

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

the class ClipView method executeFunction.

/**
 * {@inheritDoc}
 */
@Override
protected void executeFunction(final int padIndex) {
    final Optional<ITrack> track = this.model.getCurrentTrackBank().getSelectedItem();
    if (track.isEmpty())
        return;
    final ISlot slot = track.get().getSlotBank().getItem(padIndex);
    final MaschineConfiguration configuration = this.surface.getConfiguration();
    if (this.isButtonCombination(ButtonID.DUPLICATE)) {
        if (track.get().doesExist())
            slot.duplicate();
        return;
    }
    // Stop clip
    if (this.isButtonCombination(ButtonID.CLIP)) {
        track.get().stop();
        return;
    }
    // Browse for clips
    if (this.isButtonCombination(ButtonID.BROWSE)) {
        if (track.get().doesExist())
            this.model.getBrowser().replace(slot);
        return;
    }
    // Delete selected clip
    if (this.isButtonCombination(ButtonID.DELETE)) {
        slot.remove();
        return;
    }
    // Select clip
    if (this.isButtonCombination(ButtonID.SELECT)) {
        slot.select();
        return;
    }
    if (configuration.isSelectClipOnLaunch())
        slot.select();
    if (!track.get().isRecArm() || slot.hasContent()) {
        slot.launch();
        return;
    }
    switch(configuration.getActionForRecArmedPad()) {
        case 0:
            this.model.recordNoteClip(track.get(), slot);
            break;
        case 1:
            final int lengthInBeats = configuration.getNewClipLenghthInBeats(this.model.getTransport().getQuartersPerMeasure());
            this.model.createNoteClip(track.get(), slot, lengthInBeats, true);
            break;
        case 2:
        default:
            // Do nothing
            break;
    }
}
Also used : MaschineConfiguration(de.mossgrabers.controller.ni.maschine.mk3.MaschineConfiguration) ITrack(de.mossgrabers.framework.daw.data.ITrack) ISlot(de.mossgrabers.framework.daw.data.ISlot)

Example 24 with ISlot

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

the class ConfiguredRecordCommand method execute.

/**
 * {@inheritDoc}
 */
@Override
public void execute(final ButtonEvent event, final int velocity) {
    if (event != ButtonEvent.UP)
        return;
    final C configuration = this.surface.getConfiguration();
    final AbstractConfiguration.RecordFunction recordMode = this.isShifted() ? configuration.getShiftedRecordButtonFunction() : configuration.getRecordButtonFunction();
    switch(recordMode) {
        case RECORD_ARRANGER:
            this.model.getTransport().startRecording();
            break;
        case RECORD_CLIP:
            final Optional<ISlot> slot = this.model.getSelectedSlot();
            if (slot.isEmpty())
                return;
            final ISlot s = slot.get();
            if (!s.isRecording())
                s.startRecording();
            s.launch();
            break;
        case NEW_CLIP:
            new NewCommand<>(this.model, this.surface).execute();
            break;
        case TOGGLE_ARRANGER_OVERDUB:
            this.model.getTransport().toggleOverdub();
            break;
        case TOGGLE_CLIP_OVERDUB:
            this.model.getTransport().toggleLauncherOverdub();
            break;
        case TOGGLE_REC_ARM:
            final Optional<ITrack> selectedTrack = this.model.getCurrentTrackBank().getSelectedItem();
            if (selectedTrack.isPresent())
                selectedTrack.get().toggleRecArm();
            break;
        default:
            // Intentionally empty
            break;
    }
}
Also used : AbstractConfiguration(de.mossgrabers.framework.configuration.AbstractConfiguration) ITrack(de.mossgrabers.framework.daw.data.ITrack) ISlot(de.mossgrabers.framework.daw.data.ISlot)

Example 25 with ISlot

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

the class ClipListComponent method draw.

/**
 * {@inheritDoc}
 */
@Override
public void draw(final IGraphicsInfo info) {
    final IGraphicsContext gc = info.getContext();
    final IGraphicsDimensions dimensions = info.getDimensions();
    final IGraphicsConfiguration configuration = info.getConfiguration();
    final double left = info.getBounds().left();
    final double width = info.getBounds().width();
    final double height = info.getBounds().height();
    final double separatorSize = dimensions.getSeparatorSize();
    final double inset = dimensions.getInset();
    final int size = this.items.size();
    final double itemLeft = left + separatorSize;
    final double itemWidth = width - separatorSize;
    final double itemHeight = height / size;
    final double fontHeight = itemHeight > 30 ? itemHeight / 2 : itemHeight * 2 / 3;
    final double boxLeft = itemLeft + inset;
    final double boxWidth = fontHeight - 2 * separatorSize;
    final double radius = boxWidth / 2;
    final ColorEx textColor = configuration.getColorText();
    final ColorEx borderColor = configuration.getColorBackgroundLighter();
    for (int i = 0; i < size; i++) {
        final Pair<ITrack, ISlot> pair = this.items.get(i);
        final ISlot slot = pair.getValue();
        final ITrack track = pair.getKey();
        final double itemTop = i * itemHeight;
        String name = slot.getName();
        final double boxTop = itemTop + (itemHeight - fontHeight) / 2;
        // Draw the background
        final ColorEx clipBackgroundColor = slot.getColor();
        if (track.isGroup()) {
            if (name.isEmpty())
                name = "Scene " + (slot.getPosition() + 1);
            gc.fillRectangle(itemLeft, itemTop + separatorSize, itemWidth, itemHeight - 2 * separatorSize, ColorEx.darker(ColorEx.DARK_GRAY));
            gc.fillRectangle(itemLeft + itemWidth - 2 * inset, itemTop + separatorSize, 2 * inset, itemHeight - 2 * separatorSize, clipBackgroundColor);
        } else
            gc.fillRectangle(itemLeft, itemTop + separatorSize, itemWidth, itemHeight - 2 * separatorSize, clipBackgroundColor);
        if (slot.doesExist()) {
            // Draw the play/record state indicator box
            final boolean isPlaying = slot.isPlaying();
            if (isPlaying || slot.isRecording() || slot.isPlayingQueued() || slot.isRecordingQueued())
                gc.fillRectangle(boxLeft, boxTop, fontHeight, fontHeight, ColorEx.BLACK);
            // Draw the play, record or stop symbol depending on the slots state
            if (slot.hasContent()) {
                if (slot.isRecording())
                    gc.fillCircle(boxLeft + separatorSize + radius, boxTop + separatorSize + radius, radius, ColorEx.RED);
                else {
                    ColorEx fillColor = ColorEx.darker(clipBackgroundColor);
                    if (isPlaying)
                        fillColor = ColorEx.GREEN;
                    else if (slot.isPlayingQueued() || slot.isRecordingQueued())
                        fillColor = ColorEx.WHITE;
                    gc.fillTriangle(boxLeft + separatorSize, boxTop + separatorSize, boxLeft + separatorSize, boxTop + fontHeight - separatorSize, boxLeft + fontHeight - separatorSize, boxTop + fontHeight / 2, fillColor);
                }
            } else {
                if (track.isRecArm())
                    gc.fillCircle(boxLeft + separatorSize + radius, boxTop + separatorSize + radius, radius, ColorEx.DARK_GRAY);
                else
                    gc.fillRectangle(boxLeft + separatorSize, boxTop + separatorSize, boxWidth, boxWidth, ColorEx.DARK_GRAY);
            }
            // Draw the text
            gc.drawTextInBounds(name, itemLeft + 2 * inset + fontHeight, itemTop - 1, itemWidth - 2 * inset, itemHeight, Align.LEFT, ColorEx.BLACK, fontHeight);
        }
        // Draw the border
        ColorEx color = borderColor;
        if (slot.isSelected())
            color = textColor;
        else if (track.isSelected())
            color = ColorEx.darker(ColorEx.YELLOW);
        gc.strokeRectangle(itemLeft, itemTop + separatorSize, itemWidth, itemHeight - 2 * separatorSize, color, slot.isSelected() ? 2 : 1);
    }
}
Also used : IGraphicsContext(de.mossgrabers.framework.graphics.IGraphicsContext) IGraphicsConfiguration(de.mossgrabers.framework.graphics.IGraphicsConfiguration) ITrack(de.mossgrabers.framework.daw.data.ITrack) ColorEx(de.mossgrabers.framework.controller.color.ColorEx) ISlot(de.mossgrabers.framework.daw.data.ISlot) IGraphicsDimensions(de.mossgrabers.framework.graphics.IGraphicsDimensions)

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