use of de.mossgrabers.framework.configuration.IIntegerSetting 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);
}
use of de.mossgrabers.framework.configuration.IIntegerSetting in project DrivenByMoss by git-moss.
the class OSCConfiguration method init.
/**
* {@inheritDoc}
*/
@Override
public void init(final ISettingsUI settingsUI) {
// /////////////////////////
// Network
final IIntegerSetting receivePortSetting = settingsUI.getRangeSetting("Port", "Receive from (Script restart required)", 0, 65535, 1, "", 8000);
receivePortSetting.addValueObserver(value -> {
this.receivePort = value.intValue();
this.notifyObservers(OSCConfiguration.RECEIVE_PORT);
});
final IStringSetting sendHostSetting = settingsUI.getStringSetting("Host", "Send to", 15, DEFAULT_SERVER);
sendHostSetting.addValueObserver(value -> {
this.sendHost = value;
this.notifyObservers(OSCConfiguration.SEND_HOST);
});
final IIntegerSetting sendPortSetting = settingsUI.getRangeSetting("Port", "Send to", 0, 65535, 1, "", 9000);
sendPortSetting.addValueObserver(value -> {
this.sendPort = value.intValue();
this.notifyObservers(SEND_PORT);
});
// /////////////////////////
// Accent
this.activateAccentActiveSetting(settingsUI);
this.activateAccentValueSetting(settingsUI);
// /////////////////////////
// Workflow
this.activateEnableVUMetersSetting(settingsUI);
// /////////////////////////
// Debug
final IEnumSetting debugCommandsSetting = settingsUI.getEnumSetting("Debug commands", "Debug", ON_OFF_OPTIONS, ON_OFF_OPTIONS[0]);
debugCommandsSetting.addValueObserver(value -> {
this.debugCommands = "On".equals(value);
this.notifyObservers(DEBUG_COMMANDS);
});
}
use of de.mossgrabers.framework.configuration.IIntegerSetting in project DrivenByMoss by git-moss.
the class PushConfiguration method activatePush2HardwareSettings.
/**
* Activate the Push 2 hardware settings.
*
* @param settingsUI The settings
*/
private void activatePush2HardwareSettings(final ISettingsUI settingsUI) {
if (!this.isPush2)
return;
final IIntegerSetting sendPortSetting = settingsUI.getRangeSetting("Display Port", CATEGORY_HARDWARE_SETUP, 1, 65535, 1, "", 7000);
sendPortSetting.addValueObserver(value -> {
this.sendPort = value.intValue() + 1;
this.notifyObservers(SEND_PORT);
});
this.displayBrightnessSetting = settingsUI.getRangeSetting("Display Brightness", CATEGORY_HARDWARE_SETUP, 0, 100, 1, "%", 100);
this.displayBrightnessSetting.addValueObserver(value -> {
this.displayBrightness = value.intValue();
this.notifyObservers(DISPLAY_BRIGHTNESS);
});
this.ledBrightnessSetting = settingsUI.getRangeSetting("LED Brightness", CATEGORY_HARDWARE_SETUP, 0, 100, 1, "%", 100);
this.ledBrightnessSetting.addValueObserver(value -> {
this.ledBrightness = value.intValue();
this.notifyObservers(LED_BRIGHTNESS);
});
}
use of de.mossgrabers.framework.configuration.IIntegerSetting in project DrivenByMoss by git-moss.
the class FireConfiguration method init.
/**
* {@inheritDoc}
*/
@Override
public void init(final ISettingsUI globalSettings, final ISettingsUI documentSettings) {
// /////////////////////////
// Scale
this.activateScaleSetting(documentSettings);
this.activateScaleBaseSetting(documentSettings);
this.activateScaleInScaleSetting(documentSettings);
this.activateScaleLayoutSetting(documentSettings);
// /////////////////////////
// Note Repeat
this.activateNoteRepeatSetting(documentSettings);
// /////////////////////////
// Session
this.activateSelectClipOnLaunchSetting(globalSettings);
this.activateDrawRecordStripeSetting(globalSettings);
this.activateActionForRecArmedPad(globalSettings);
// /////////////////////////
// Transport
this.activateBehaviourOnStopSetting(globalSettings);
// Corrected label (removed automation)
final IEnumSetting flipRecordSetting = globalSettings.getEnumSetting("Flip arranger and clip record", CATEGORY_TRANSPORT, ON_OFF_OPTIONS, ON_OFF_OPTIONS[0]);
flipRecordSetting.addValueObserver(value -> {
this.flipRecord = "On".equals(value);
this.notifyObservers(FLIP_RECORD);
});
this.isSettingActive.add(FLIP_RECORD);
// /////////////////////////
// Play and Sequence
this.activateAccentActiveSetting(globalSettings);
this.activateAccentValueSetting(globalSettings);
this.activateQuantizeAmountSetting(globalSettings);
this.activateMidiEditChannelSetting(documentSettings);
if (this.host.supports(Capability.HAS_DRUM_DEVICE))
this.activateTurnOffEmptyDrumPadsSetting(globalSettings);
// /////////////////////////
// Workflow
this.activateExcludeDeactivatedItemsSetting(globalSettings);
this.activateNewClipLengthSetting(globalSettings);
this.activateKnobSpeedSetting(globalSettings);
// /////////////////////////
// Hardware
final IIntegerSetting padBrightnessSetting = globalSettings.getRangeSetting("Pad Brightness", CATEGORY_HARDWARE_SETUP, 0, 100, 1, "%", 100);
padBrightnessSetting.addValueObserver(value -> {
this.padBrightness = value.intValue();
this.notifyObservers(PAD_BRIGHTNESS);
});
this.isSettingActive.add(PAD_BRIGHTNESS);
final IIntegerSetting padSaturationSetting = globalSettings.getRangeSetting("Pad Saturation", CATEGORY_HARDWARE_SETUP, 0, 100, 1, "%", 100);
padSaturationSetting.addValueObserver(value -> {
this.padSaturation = value.intValue();
this.notifyObservers(PAD_SATURATION);
});
this.isSettingActive.add(PAD_SATURATION);
}
use of de.mossgrabers.framework.configuration.IIntegerSetting 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);
}
Aggregations