Search in sources :

Example 1 with FlexiCommand

use of de.mossgrabers.controller.generic.controller.FlexiCommand in project DrivenByMoss by git-moss.

the class GenericFlexiConfiguration method fixKnobMode.

/**
 * Always set the knob mode to absolute for trigger commands.
 */
private void fixKnobMode() {
    final CommandSlot slot = this.getSelectedSlot();
    final FlexiCommand command = slot.getCommand();
    if (!command.isTrigger())
        return;
    if (!AbstractHandler.isAbsolute(slot.getKnobMode()) || slot.getType() == CommandSlot.TYPE_MMC)
        this.knobModeSetting.set(KnobMode.ABSOLUTE.getLabel());
}
Also used : CommandSlot(de.mossgrabers.controller.generic.flexihandler.utils.CommandSlot) FlexiCommand(de.mossgrabers.controller.generic.controller.FlexiCommand)

Example 2 with FlexiCommand

use of de.mossgrabers.controller.generic.controller.FlexiCommand in project DrivenByMoss by git-moss.

the class GenericFlexiConfiguration method importFrom.

/**
 * Import the configuration from the given file.
 *
 * @param importFile Where to import from
 * @throws IOException Could not save the file
 */
public void importFrom(final File importFile) throws IOException {
    this.slotSelectionSetting.set("1");
    this.host.scheduleTask(() -> {
        try {
            final Properties props = new Properties();
            try (final Reader reader = new FileReader(importFile)) {
                props.load(reader);
            }
            for (int i = 0; i < this.commandSlots.length; i++) {
                final String slotName = "SLOT" + i + "_";
                final CommandSlot slot = this.commandSlots[i];
                final String typeProperty = props.getProperty(slotName + TAG_TYPE);
                if (typeProperty == null)
                    continue;
                int type = Integer.parseInt(typeProperty);
                final FlexiCommand command = FlexiCommand.lookupByName(props.getProperty(slotName + TAG_COMMAND));
                // For backwards compatibility
                if (command == FlexiCommand.OFF)
                    type = CommandSlot.TYPE_OFF;
                final String numberProperty = props.getProperty(slotName + TAG_NUMBER);
                final String midiChannelProperty = props.getProperty(slotName + TAG_MIDI_CHANNEL);
                final String knobModeProperty = props.getProperty(slotName + TAG_KNOB_MODE);
                slot.setType(type);
                slot.setNumber(numberProperty == null ? 0 : Integer.parseInt(numberProperty));
                slot.setMidiChannel(midiChannelProperty == null ? 0 : Integer.parseInt(midiChannelProperty));
                slot.setResolution(Boolean.parseBoolean(props.getProperty(slotName + TAG_RESOLUTION)));
                slot.setKnobMode(readKnobMode(knobModeProperty));
                slot.setCommand(command);
                slot.setSendValue(Boolean.parseBoolean(props.getProperty(slotName + TAG_SEND_VALUE)));
                slot.setSendValueWhenReceived(Boolean.parseBoolean(props.getProperty(slotName + TAG_SEND_VALUE_WHEN_RECEIVED)));
            }
        } catch (final IOException | NumberFormatException ex) {
            this.host.error("Could not import from file.", ex);
            this.host.showNotification("Could not import from file. Check Script Console for detailed error.");
            return;
        }
        this.clearNoteMap();
        this.selectSlot("1");
    }, 1000);
}
Also used : Reader(java.io.Reader) FileReader(java.io.FileReader) CommandSlot(de.mossgrabers.controller.generic.flexihandler.utils.CommandSlot) FileReader(java.io.FileReader) IOException(java.io.IOException) Properties(java.util.Properties) FlexiCommand(de.mossgrabers.controller.generic.controller.FlexiCommand)

Example 3 with FlexiCommand

use of de.mossgrabers.controller.generic.controller.FlexiCommand in project DrivenByMoss by git-moss.

the class GenericFlexiControllerSetup method updateIndication.

protected void updateIndication() {
    final Set<FlexiCommand> commands = this.configuration.getMappedCommands();
    final FlexiCommand[] allCommands = FlexiCommand.values();
    final ITrackBank trackBank = this.model.getTrackBank();
    final Optional<ITrack> selectedTrack = trackBank.getSelectedItem();
    for (int i = 0; i < trackBank.getPageSize(); i++) {
        final boolean hasTrackSel = selectedTrack.isPresent() && selectedTrack.get().getIndex() == i;
        final ITrack track = trackBank.getItem(i);
        track.setVolumeIndication(this.testVolumeIndication(commands, allCommands, i, hasTrackSel));
        track.setPanIndication(this.testPanIndication(commands, allCommands, i, hasTrackSel));
        final ISendBank sendBank = track.getSendBank();
        final int sendPageSize = sendBank.getPageSize();
        for (int j = 0; j < sendPageSize; j++) sendBank.getItem(j).setIndication(this.testSendIndication(commands, allCommands, i, hasTrackSel, sendPageSize, j));
    }
    final IMasterTrack masterTrack = this.model.getMasterTrack();
    masterTrack.setVolumeIndication(commands.contains(FlexiCommand.MASTER_SET_VOLUME));
    masterTrack.setPanIndication(commands.contains(FlexiCommand.MASTER_SET_PANORAMA));
    final IParameterBank parameterBank = this.model.getCursorDevice().getParameterBank();
    for (int i = 0; i < parameterBank.getPageSize(); i++) parameterBank.getItem(i).setIndication(this.testParameterIndication(commands, allCommands, i));
}
Also used : ITrack(de.mossgrabers.framework.daw.data.ITrack) ITrackBank(de.mossgrabers.framework.daw.data.bank.ITrackBank) IParameterBank(de.mossgrabers.framework.daw.data.bank.IParameterBank) FlexiCommand(de.mossgrabers.controller.generic.controller.FlexiCommand) ISendBank(de.mossgrabers.framework.daw.data.bank.ISendBank) IMasterTrack(de.mossgrabers.framework.daw.data.IMasterTrack)

Example 4 with FlexiCommand

use of de.mossgrabers.controller.generic.controller.FlexiCommand in project DrivenByMoss by git-moss.

the class GenericFlexiConfiguration method handleFunctionChange.

/**
 * Handles changing the function selection by the user.
 *
 * @param value The new value
 */
private void handleFunctionChange(final String value) {
    if (this.commandIsUpdating.get())
        return;
    if (this.doNotFire.get()) {
        this.doNotFire.set(false);
        return;
    }
    final CommandSlot slot = this.getSelectedSlot();
    final FlexiCommand oldCommand = slot.getCommand();
    final FlexiCommand newCommand = FlexiCommand.lookupByName(value);
    slot.setCommand(newCommand);
    this.fixKnobMode();
    this.notifyCommandObserver();
    final CommandCategory oldCategory = oldCommand.getCategory();
    if (oldCategory != null && oldCategory != newCommand.getCategory()) {
        this.doNotFire.set(true);
        this.functionSettingsMap.get(oldCategory).set(FlexiCommand.OFF.getName());
    }
}
Also used : CommandSlot(de.mossgrabers.controller.generic.flexihandler.utils.CommandSlot) CommandCategory(de.mossgrabers.controller.generic.controller.CommandCategory) FlexiCommand(de.mossgrabers.controller.generic.controller.FlexiCommand)

Aggregations

FlexiCommand (de.mossgrabers.controller.generic.controller.FlexiCommand)4 CommandSlot (de.mossgrabers.controller.generic.flexihandler.utils.CommandSlot)3 CommandCategory (de.mossgrabers.controller.generic.controller.CommandCategory)1 IMasterTrack (de.mossgrabers.framework.daw.data.IMasterTrack)1 ITrack (de.mossgrabers.framework.daw.data.ITrack)1 IParameterBank (de.mossgrabers.framework.daw.data.bank.IParameterBank)1 ISendBank (de.mossgrabers.framework.daw.data.bank.ISendBank)1 ITrackBank (de.mossgrabers.framework.daw.data.bank.ITrackBank)1 FileReader (java.io.FileReader)1 IOException (java.io.IOException)1 Reader (java.io.Reader)1 Properties (java.util.Properties)1