Search in sources :

Example 1 with IActionSetting

use of de.mossgrabers.framework.configuration.IActionSetting in project DrivenByMoss by git-moss.

the class GenericFlexiConfiguration method init.

/**
 * {@inheritDoc}
 */
@Override
public void init(final ISettingsUI globalSettings, final ISettingsUI documentSettings) {
    String category = "Slot";
    final String[] slotEntries = new String[NUM_SLOTS];
    for (int i = 0; i < NUM_SLOTS; i++) {
        this.commandSlots[i] = new CommandSlot();
        slotEntries[i] = Integer.toString(i + 1);
    }
    this.slotSelectionSetting = globalSettings.getEnumSetting("Selected:", category, slotEntries, slotEntries[0]);
    // /////////////////////////////////////////////
    // The MIDI learn section
    category = "Use a knob/fader/button then click Set...";
    this.learnTypeSetting = globalSettings.getEnumSetting("Type:", category, OPTIONS_TYPE, OPTIONS_TYPE.get(0));
    this.learnNumberSetting = globalSettings.getEnumSetting("Number:", category, NUMBER_NAMES, NUMBER_NAMES.get(0));
    this.learnMidiChannelSetting = globalSettings.getEnumSetting("Midi Channel:", category, OPTIONS_MIDI_CHANNEL, OPTIONS_MIDI_CHANNEL[0]);
    this.learnResolutionSetting = globalSettings.getEnumSetting("Resolution:", category, OPTIONS_RESOLUTION, OPTIONS_RESOLUTION.get(0));
    this.learnTypeSetting.setEnabled(false);
    this.learnNumberSetting.setEnabled(false);
    this.learnMidiChannelSetting.setEnabled(false);
    this.learnResolutionSetting.setEnabled(false);
    globalSettings.getSignalSetting(" ", category, "Set").addSignalObserver(value -> {
        if (this.learnTypeValue == null)
            return;
        this.typeSetting.set(this.learnTypeValue);
        this.midiChannelSetting.set(this.learnMidiChannelValue);
        // CC? For 14-bit values only set CCs below 32
        if (OPTIONS_TYPE.get(1).equals(this.learnTypeValue) && this.learnResolution) {
            final int number = AbstractConfiguration.lookupIndex(NUMBER_NAMES, this.learnNumberValue);
            if (number >= 32 && number < 64)
                this.learnNumberValue = NUMBER_NAMES.get(number - 32);
            else if (number >= 64)
                this.learnResolution = false;
        }
        this.resolutionSetting.set(OPTIONS_RESOLUTION.get(this.learnResolution ? 1 : 0));
        this.numberSetting.set(this.learnNumberValue);
    });
    // /////////////////////////////////////////////
    // Selected Slot - MIDI trigger
    category = "Selected Slot - MIDI trigger";
    this.typeSetting = globalSettings.getEnumSetting("Type:", category, OPTIONS_TYPE, OPTIONS_TYPE.get(0));
    this.numberSetting = globalSettings.getEnumSetting("Number:", category, NUMBER_NAMES, NUMBER_NAMES.get(0));
    this.midiChannelSetting = globalSettings.getEnumSetting("Midi Channel:", category, CONTROLLER_CHANNELS, CONTROLLER_CHANNELS.get(0));
    this.resolutionSetting = globalSettings.getEnumSetting("Resolution:", category, OPTIONS_RESOLUTION, OPTIONS_RESOLUTION.get(0));
    final String[] knobModeLabels = KnobMode.getLabels();
    this.knobModeSetting = globalSettings.getEnumSetting("Knob Mode:", category, knobModeLabels, knobModeLabels[0]);
    // /////////////////////////////////////////////
    // Selected Slot - MIDI device update
    category = "Selected Slot - MIDI device update";
    this.sendValueSetting = globalSettings.getEnumSetting("Send value to device:", category, AbstractConfiguration.ON_OFF_OPTIONS, AbstractConfiguration.ON_OFF_OPTIONS[1]);
    this.sendValueWhenReceivedSetting = globalSettings.getEnumSetting("Send value to device when received (only buttons):", category, AbstractConfiguration.ON_OFF_OPTIONS, AbstractConfiguration.ON_OFF_OPTIONS[1]);
    // /////////////////////////////////////////////
    // Selected Slot - Function
    category = "Selected Slot - Function";
    final CommandCategory[] values = CommandCategory.values();
    for (final CommandCategory value : values) {
        final IEnumSetting fs = createFunctionSetting(value.getName(), category, globalSettings);
        this.functionSettings.add(fs);
        this.functionSettingsMap.put(value, fs);
        fs.addValueObserver(this::handleFunctionChange);
    }
    // /////////////////////////////////////////////
    // Export/Import section
    category = "Load / Save";
    // The Setlist file to auto-load
    this.fileSetting = globalSettings.getStringSetting("Filename", category, -1, "");
    this.filename = this.fileSetting.get();
    this.fileSetting.addValueObserver(value -> this.filename = value);
    // The different blank labels are necessary to distinguish the widgets!
    globalSettings.getSignalSetting("  ", category, "Save").addSignalObserver(value -> this.notifyObservers(BUTTON_SAVE));
    globalSettings.getSignalSetting("   ", category, "Load").addSignalObserver(value -> this.notifyObservers(BUTTON_LOAD));
    this.learnTypeSetting.set(OPTIONS_TYPE.get(0));
    this.typeSetting.addValueObserver(value -> {
        final int type = AbstractConfiguration.lookupIndex(OPTIONS_TYPE, value) - 1;
        this.getSelectedSlot().setType(type);
        // High resolution is only true for pitchbend as the default
        final int number = AbstractConfiguration.lookupIndex(NUMBER_NAMES, this.numberSetting.get());
        if (type != CommandSlot.TYPE_PITCH_BEND && (type != CommandSlot.TYPE_CC || number >= 32))
            this.resolutionSetting.set(OPTIONS_RESOLUTION.get(0));
        this.clearNoteMap();
        this.updateVisibility(!OPTIONS_TYPE.get(0).equals(value));
    });
    this.numberSetting.addValueObserver(value -> {
        final int numberIndex = AbstractConfiguration.lookupIndex(NUMBER_NAMES, value);
        this.getSelectedSlot().setNumber(numberIndex);
        // Switch resolution setting to low for CC >= 32
        final int type = AbstractConfiguration.lookupIndex(OPTIONS_TYPE, this.typeSetting.get()) - 1;
        if (type == CommandSlot.TYPE_CC && numberIndex >= 32)
            this.resolutionSetting.set(OPTIONS_RESOLUTION.get(0));
        this.clearNoteMap();
    });
    this.midiChannelSetting.addValueObserver(value -> {
        this.getSelectedSlot().setMidiChannel(AbstractConfiguration.lookupIndex(CONTROLLER_CHANNELS, value));
        this.clearNoteMap();
    });
    this.resolutionSetting.addValueObserver(value -> {
        final boolean isHighRes = OPTIONS_RESOLUTION.get(1).equals(value);
        this.getSelectedSlot().setResolution(OPTIONS_RESOLUTION.get(1).equals(value));
        // High resolution can only be set for CC < 32 and pitchbend (fixed to high res)
        final int type = AbstractConfiguration.lookupIndex(OPTIONS_TYPE, this.typeSetting.get()) - 1;
        if (isHighRes) {
            final int number = AbstractConfiguration.lookupIndex(NUMBER_NAMES, this.numberSetting.get());
            if ((type != CommandSlot.TYPE_CC || number >= 32) && type != CommandSlot.TYPE_PITCH_BEND)
                this.resolutionSetting.set(OPTIONS_RESOLUTION.get(0));
        } else {
            if (type == CommandSlot.TYPE_PITCH_BEND)
                this.resolutionSetting.set(OPTIONS_RESOLUTION.get(1));
        }
    });
    this.knobModeSetting.addValueObserver(value -> {
        this.getSelectedSlot().setKnobMode(KnobMode.lookupByLabel(value));
        this.fixKnobMode();
    });
    this.sendValueSetting.addValueObserver(value -> this.getSelectedSlot().setSendValue(AbstractConfiguration.lookupIndex(AbstractConfiguration.ON_OFF_OPTIONS, value) > 0));
    this.sendValueWhenReceivedSetting.addValueObserver(value -> this.getSelectedSlot().setSendValueWhenReceived(AbstractConfiguration.lookupIndex(AbstractConfiguration.ON_OFF_OPTIONS, value) > 0));
    // /////////////////////////////////////////////
    // Keyboard / Pads
    final IEnumSetting enableMPESetting = globalSettings.getEnumSetting("MIDI Polyphonic Expression (MPE)", CATEGORY_KEYBOARD, ON_OFF_OPTIONS, ON_OFF_OPTIONS[0]);
    this.isMPEEnabled = ON_OFF_OPTIONS[1].equals(enableMPESetting.get());
    final IIntegerSetting pitchBendRangeSetting = globalSettings.getRangeSetting("MPE Pitch Bend Sensitivity", CATEGORY_KEYBOARD, 1, 96, 1, "", 48);
    this.mpePitchBendRange = pitchBendRangeSetting.get().intValue();
    final IEnumSetting keyboardMidiChannelSetting = globalSettings.getEnumSetting("Midi Channel", CATEGORY_KEYBOARD, KEYBOARD_CHANNELS, KEYBOARD_CHANNELS.get(1));
    this.keyboardChannel = AbstractConfiguration.lookupIndex(KEYBOARD_CHANNELS, keyboardMidiChannelSetting.get()) - 1;
    final IEnumSetting routeTimbreSetting = globalSettings.getEnumSetting("Route Timbre (CC74)", CATEGORY_KEYBOARD, AbstractConfiguration.ON_OFF_OPTIONS, AbstractConfiguration.ON_OFF_OPTIONS[0]);
    this.keyboardRouteTimbre = "On".equals(routeTimbreSetting.get());
    final IEnumSetting routeModulationSetting = globalSettings.getEnumSetting("Route Modulation (CC01)", CATEGORY_KEYBOARD, AbstractConfiguration.ON_OFF_OPTIONS, AbstractConfiguration.ON_OFF_OPTIONS[1]);
    this.keyboardRouteModulation = "On".equals(routeModulationSetting.get());
    final IEnumSetting routeSustainSetting = globalSettings.getEnumSetting("Route Sustain (CC64)", CATEGORY_KEYBOARD, AbstractConfiguration.ON_OFF_OPTIONS, AbstractConfiguration.ON_OFF_OPTIONS[1]);
    this.keyboardRouteSustain = "On".equals(routeSustainSetting.get());
    final IEnumSetting routePitchbendSetting = globalSettings.getEnumSetting("Route Pitchbend", CATEGORY_KEYBOARD, AbstractConfiguration.ON_OFF_OPTIONS, AbstractConfiguration.ON_OFF_OPTIONS[1]);
    this.keyboardRoutePitchbend = "On".equals(routePitchbendSetting.get());
    enableMPESetting.addValueObserver(value -> {
        this.isMPEEnabled = ON_OFF_OPTIONS[1].equals(value);
        this.notifyObservers(ENABLED_MPE_ZONES);
        pitchBendRangeSetting.setEnabled(this.isMPEEnabled);
        keyboardMidiChannelSetting.setEnabled(!this.isMPEEnabled);
        routePitchbendSetting.setEnabled(!this.isMPEEnabled);
    });
    pitchBendRangeSetting.addValueObserver(value -> {
        this.mpePitchBendRange = value.intValue();
        this.notifyObservers(MPE_PITCHBEND_RANGE);
    });
    // /////////////////////////////////////////////
    // Options
    this.selectedModeSetting = globalSettings.getEnumSetting("Selected Mode", CATEGORY_OPTIONS, MODES, MODES.get(0));
    this.selectedModeSetting.addValueObserver(value -> {
        this.selectedMode = value;
        this.notifyObservers(SELECTED_MODE);
    });
    for (int i = 0; i < this.assignableFunctionActions.length; i++) {
        final int pos = i;
        final IActionSetting actionSetting = globalSettings.getActionSetting("Action " + (i + 1), CATEGORY_OPTIONS);
        actionSetting.addValueObserver(value -> this.assignableFunctionActions[pos] = actionSetting.get());
    }
    // /////////////////////////////////////////////
    // Workflow
    this.activateKnobSpeedSetting(globalSettings);
    this.activateExcludeDeactivatedItemsSetting(globalSettings);
    this.activateNoteRepeatSetting(documentSettings);
    this.slotSelectionSetting.addValueObserver(this::selectSlot);
}
Also used : IIntegerSetting(de.mossgrabers.framework.configuration.IIntegerSetting) CommandSlot(de.mossgrabers.controller.generic.flexihandler.utils.CommandSlot) CommandCategory(de.mossgrabers.controller.generic.controller.CommandCategory) IActionSetting(de.mossgrabers.framework.configuration.IActionSetting) IEnumSetting(de.mossgrabers.framework.configuration.IEnumSetting)

Example 2 with IActionSetting

use of de.mossgrabers.framework.configuration.IActionSetting in project DrivenByMoss by git-moss.

the class MCUConfiguration method activateAssignableSettings.

private void activateAssignableSettings(final ISettingsUI settingsUI) {
    for (int i = 0; i < this.assignableFunctions.length; i++) {
        final int pos = i;
        final IEnumSetting assignableSetting = settingsUI.getEnumSetting(ASSIGNABLE_BUTTON_NAMES[i], CATEGORY_ASSIGNABLE_BUTTONS, ASSIGNABLE_VALUES, ASSIGNABLE_VALUES[6]);
        assignableSetting.addValueObserver(value -> this.assignableFunctions[pos] = lookupIndex(ASSIGNABLE_VALUES, value));
        final IActionSetting actionSetting = settingsUI.getActionSetting(ASSIGNABLE_BUTTON_NAMES[i] + " - Action", CATEGORY_ASSIGNABLE_BUTTONS);
        actionSetting.addValueObserver(value -> this.assignableFunctionActions[pos] = actionSetting.get());
    }
}
Also used : IActionSetting(de.mossgrabers.framework.configuration.IActionSetting) IEnumSetting(de.mossgrabers.framework.configuration.IEnumSetting)

Example 3 with IActionSetting

use of de.mossgrabers.framework.configuration.IActionSetting in project DrivenByMoss by git-moss.

the class OSCConfiguration method init.

/**
 * {@inheritDoc}
 */
@Override
public void init(final ISettingsUI globalSettings, final ISettingsUI documentSettings) {
    // /////////////////////////
    // Network
    final IIntegerSetting receivePortSetting = globalSettings.getRangeSetting("Port to receive on", CATEGORY_SETUP, 1024, 65535, 1, "", 8000);
    receivePortSetting.addValueObserver(value -> {
        this.receivePort = value.intValue();
        this.notifyObservers(RECEIVE_PORT);
    });
    this.isSettingActive.add(RECEIVE_PORT);
    final IStringSetting sendHostSetting = globalSettings.getStringSetting("Host to send to (requires restart)", CATEGORY_SETUP, 15, DEFAULT_SERVER);
    this.sendHost = sendHostSetting.get();
    final IIntegerSetting sendPortSetting = globalSettings.getRangeSetting("Port to send to (requires restart)", CATEGORY_SETUP, 1024, 65535, 1, "", 9000);
    this.sendPort = sendPortSetting.get().intValue();
    // /////////////////////////
    // Protocol
    final IEnumSetting valueResolutionSetting = globalSettings.getEnumSetting("Value resolution", CATEGORY_PROTOCOL, VALUE_RESOLUTION_OPTIONS, VALUE_RESOLUTION_OPTIONS[0]);
    valueResolutionSetting.addValueObserver(value -> {
        if (VALUE_RESOLUTION_OPTIONS[0].equals(value))
            this.valueResolution = ValueResolution.LOW;
        else if (VALUE_RESOLUTION_OPTIONS[1].equals(value))
            this.valueResolution = ValueResolution.MEDIUM;
        else if (VALUE_RESOLUTION_OPTIONS[2].equals(value))
            this.valueResolution = ValueResolution.HIGH;
        this.notifyObservers(VALUE_RESOLUTION);
    });
    this.isSettingActive.add(VALUE_RESOLUTION);
    final String[] pageSize = new String[200];
    for (int i = 0; i < pageSize.length; i++) pageSize[i] = Integer.toString(i + 1);
    final IEnumSetting bankPageSizeSetting = globalSettings.getEnumSetting("Bank Page Size (requires restart)", CATEGORY_PROTOCOL, pageSize, pageSize[7]);
    this.bankPageSize = Integer.parseInt(bankPageSizeSetting.get());
    // /////////////////////////
    // Transport
    this.activateBehaviourOnStopSetting(globalSettings);
    // /////////////////////////
    // Play and Sequence
    this.activateAccentActiveSetting(globalSettings);
    this.activateAccentValueSetting(globalSettings);
    // /////////////////////////
    // Workflow
    this.activateExcludeDeactivatedItemsSetting(globalSettings);
    this.activateEnableVUMetersSetting(globalSettings);
    for (int i = 0; i < this.assignableFunctionActions.length; i++) {
        final int pos = i;
        final IActionSetting actionSetting = globalSettings.getActionSetting("Action " + (i + 1), "Actions");
        actionSetting.addValueObserver(value -> this.assignableFunctionActions[pos] = actionSetting.get());
    }
    // /////////////////////////
    // Debug
    this.activateOSCLogging(globalSettings);
}
Also used : IStringSetting(de.mossgrabers.framework.configuration.IStringSetting) IIntegerSetting(de.mossgrabers.framework.configuration.IIntegerSetting) IActionSetting(de.mossgrabers.framework.configuration.IActionSetting) IEnumSetting(de.mossgrabers.framework.configuration.IEnumSetting)

Aggregations

IActionSetting (de.mossgrabers.framework.configuration.IActionSetting)3 IEnumSetting (de.mossgrabers.framework.configuration.IEnumSetting)3 IIntegerSetting (de.mossgrabers.framework.configuration.IIntegerSetting)2 CommandCategory (de.mossgrabers.controller.generic.controller.CommandCategory)1 CommandSlot (de.mossgrabers.controller.generic.flexihandler.utils.CommandSlot)1 IStringSetting (de.mossgrabers.framework.configuration.IStringSetting)1