diff --git a/src/main/java/com/bitwig/extensions/controllers/mcu/StringUtil.java b/src/main/java/com/bitwig/extensions/controllers/mcu/StringUtil.java index bd0508d0..69421387 100644 --- a/src/main/java/com/bitwig/extensions/controllers/mcu/StringUtil.java +++ b/src/main/java/com/bitwig/extensions/controllers/mcu/StringUtil.java @@ -1,22 +1,26 @@ package com.bitwig.extensions.controllers.mcu; public class StringUtil { - + private static final int PAN_RANGE = 50; - private static final char[] SPECIALS = {'ä', 'ü', 'ö', 'Ä', 'Ü', 'Ö', 'ß', 'é', 'è', 'ê', 'â', 'á', 'à', // - 'û', 'ú', 'ù', 'ô', 'ó', 'ò'}; - private static final String[] REPLACE = {"a", "u", "o", "A", "U", "O", "ss", "e", "e", "e", "a", "a", "a", // - "u", "u", "u", "o", "o", "o"}; - + private static final char[] SPECIALS = { + 'ä', 'ü', 'ö', 'Ä', 'Ü', 'Ö', 'ß', 'é', 'è', 'ê', 'â', 'á', 'à', // + 'û', 'ú', 'ù', 'ô', 'ó', 'ò' + }; + private static final String[] REPLACE = { + "a", "u", "o", "A", "U", "O", "ss", "e", "e", "e", "a", "a", "a", // + "u", "u", "u", "o", "o", "o" + }; + private StringUtil() { } - + public static String toBarBeats(final double value) { final int bars = (int) Math.floor(value); final int beats = (int) Math.floor((value - bars) * 4); return String.format("%02d:%02d", bars, beats); } - + public static String panToString(final double v) { final int intv = (int) (v * PAN_RANGE * 2); if (intv == PAN_RANGE) { @@ -26,7 +30,7 @@ public static String panToString(final double v) { } return " " + (intv - PAN_RANGE) + "R"; } - + /** * Tailored to condense Volume value strings. Removes leading + and spaces. * @@ -45,27 +49,27 @@ public static String condenseVolumeValue(final String valueText, final int maxLe } return sb.toString(); } - + public static String toTwoCharVal(final int value) { if (value < 10) { return " " + value; } return Integer.toString(value); } - + public static String toDisplayName(final String text) { if (text.length() < 2) { return text; } return text.charAt(0) + text.substring(1, Math.min(6, text.length())).toLowerCase(); } - - + + public static String padString(final String text, final int pad) { return " ".repeat(Math.max(0, pad)) + text; } - - public static String padEnd(final String text, int paddingLength) { + + public static String padEnd(final String text, final int paddingLength) { if (text.length() == paddingLength) { return text; } @@ -74,19 +78,35 @@ public static String padEnd(final String text, int paddingLength) { } return text + " ".repeat(paddingLength - text.length()); } - + public static String limit(final String value, final int max) { return value.substring(0, Math.min(max, value.length())); } - + public static String reduceAscii(final String name, final int maxLen) { - String result = toAsciiDisplay(name, maxLen + 10); + final String result = toAsciiDisplay(name, maxLen + 10); if (result.length() <= maxLen) { return result; } return result.replace(" ", ""); } - + + public static String toAscii(final String value) { + final StringBuilder b = new StringBuilder(); + for (int i = 0; i < value.length(); i++) { + final char c = value.charAt(i); + if (c < 128) { + b.append(c); + } else { + final int replacement = getReplace(c); + if (replacement >= 0) { + b.append(REPLACE[replacement]); + } + } + } + return b.toString(); + } + public static String toAsciiDisplay(final String name, final int maxLen) { final StringBuilder b = new StringBuilder(); for (int i = 0; i < name.length() && b.length() < maxLen; i++) { @@ -105,7 +125,7 @@ public static String toAsciiDisplay(final String name, final int maxLen) { } return b.toString(); } - + private static int getReplace(final char c) { for (int i = 0; i < SPECIALS.length; i++) { if (c == SPECIALS[i]) { @@ -114,5 +134,5 @@ private static int getReplace(final char c) { } return -1; } - + } diff --git a/src/main/java/com/bitwig/extensions/controllers/mcu/bindings/display/ParameterDisplayBinding.java b/src/main/java/com/bitwig/extensions/controllers/mcu/bindings/display/ParameterDisplayBinding.java deleted file mode 100644 index 9cbd04f9..00000000 --- a/src/main/java/com/bitwig/extensions/controllers/mcu/bindings/display/ParameterDisplayBinding.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.bitwig.extensions.controllers.mcu.bindings.display; - -import com.bitwig.extension.controller.api.Parameter; -import com.bitwig.extensions.controllers.mcu.display.DisplayManager; -import com.bitwig.extensions.controllers.mcu.layer.ControlMode; -import com.bitwig.extensions.controllers.mcu.value.StringValueConverter; - -public class ParameterDisplayBinding extends AbstractDisplayBinding { - private final StringValueConverter converter; - - public ParameterDisplayBinding(final DisplayManager target, final ControlMode mode, - final DisplayTarget displayTargetIndex, final Parameter parameter) { - this(target, mode, displayTargetIndex, parameter, s -> s); - } - - public ParameterDisplayBinding(final DisplayManager target, final ControlMode mode, - final DisplayTarget displayTargetIndex, final Parameter parameter, final StringValueConverter converter) { - super(target, mode, displayTargetIndex, parameter); - parameter.exists().addValueObserver(this::handleExists); - parameter.displayedValue().addValueObserver(this::handleValueChange); - this.converter = converter; - this.lastValue = converter.convert(parameter.displayedValue().get()); - } - - private void handleValueChange(final String newValue) { - this.lastValue = newValue; - if (isActive()) { - updateDisplay(); - } - } - -} diff --git a/src/main/java/com/bitwig/extensions/controllers/mcu/bindings/display/ParameterValueDisplayBinding.java b/src/main/java/com/bitwig/extensions/controllers/mcu/bindings/display/ParameterValueDisplayBinding.java index ede6e417..394c4970 100644 --- a/src/main/java/com/bitwig/extensions/controllers/mcu/bindings/display/ParameterValueDisplayBinding.java +++ b/src/main/java/com/bitwig/extensions/controllers/mcu/bindings/display/ParameterValueDisplayBinding.java @@ -8,11 +8,6 @@ public class ParameterValueDisplayBinding extends AbstractDisplayBinding { private final DoubleValueConverter converter; - public ParameterValueDisplayBinding(final DisplayManager target, final ControlMode mode, - final DisplayTarget displayTargetIndex, final Parameter parameter) { - this(target, mode, displayTargetIndex, parameter, value -> Double.toString(value)); - } - public ParameterValueDisplayBinding(final DisplayManager target, final ControlMode mode, final DisplayTarget displayTargetIndex, final Parameter parameter, final DoubleValueConverter converter) { super(target, mode, displayTargetIndex, parameter); diff --git a/src/main/java/com/bitwig/extensions/controllers/mcu/bindings/display/StringDisplayBinding.java b/src/main/java/com/bitwig/extensions/controllers/mcu/bindings/display/StringDisplayBinding.java index f2f81485..994d3799 100644 --- a/src/main/java/com/bitwig/extensions/controllers/mcu/bindings/display/StringDisplayBinding.java +++ b/src/main/java/com/bitwig/extensions/controllers/mcu/bindings/display/StringDisplayBinding.java @@ -2,6 +2,7 @@ import com.bitwig.extension.controller.api.BooleanValue; import com.bitwig.extension.controller.api.StringValue; +import com.bitwig.extensions.controllers.mcu.StringUtil; import com.bitwig.extensions.controllers.mcu.bindings.ResetableBinding; import com.bitwig.extensions.controllers.mcu.display.DisplayManager; import com.bitwig.extensions.controllers.mcu.layer.ControlMode; @@ -24,7 +25,7 @@ public StringDisplayBinding(final DisplayManager target, final ControlMode mode, public StringDisplayBinding(final DisplayManager target, final ControlMode mode, final DisplayTarget displayTargetIndex, final StringValue stringValue, final BooleanValue existsValue) { - this(target, mode, displayTargetIndex, stringValue, existsValue, s -> s); + this(target, mode, displayTargetIndex, stringValue, existsValue, s -> StringUtil.toAsciiDisplay(s, 8)); } private void handleValueChange(final String newValue) { @@ -36,7 +37,7 @@ private void handleValueChange(final String newValue) { @Override public void reset() { - this.lastValue = getSource().get(); + this.lastValue = stringConversion.convert(getSource().get()); if (isActive()) { updateDisplay(); } diff --git a/src/main/java/com/bitwig/extensions/controllers/mcu/bindings/display/StringRowDisplayBinding.java b/src/main/java/com/bitwig/extensions/controllers/mcu/bindings/display/StringRowDisplayBinding.java index bf6e003c..c00b2e48 100644 --- a/src/main/java/com/bitwig/extensions/controllers/mcu/bindings/display/StringRowDisplayBinding.java +++ b/src/main/java/com/bitwig/extensions/controllers/mcu/bindings/display/StringRowDisplayBinding.java @@ -1,6 +1,7 @@ package com.bitwig.extensions.controllers.mcu.bindings.display; import com.bitwig.extension.controller.api.StringValue; +import com.bitwig.extensions.controllers.mcu.StringUtil; import com.bitwig.extensions.controllers.mcu.display.DisplayManager; import com.bitwig.extensions.controllers.mcu.display.DisplayRow; import com.bitwig.extensions.controllers.mcu.layer.ControlMode; @@ -12,7 +13,7 @@ public StringRowDisplayBinding(final DisplayManager target, final ControlMode mo super(target, mode, DisplayTarget.of(row.getRowIndex(), -1, sectionIndex), stringValue); exists = true; stringValue.addValueObserver(this::handleValueChange); - this.lastValue = stringValue.get(); + this.lastValue = StringUtil.toAscii(stringValue.get()); } protected void updateDisplay() { @@ -20,7 +21,7 @@ protected void updateDisplay() { } private void handleValueChange(final String newValue) { - this.lastValue = newValue; + this.lastValue = StringUtil.toAscii(newValue); if (isActive()) { updateDisplay(); } diff --git a/src/main/java/com/bitwig/extensions/controllers/mcu/devices/DeviceManager.java b/src/main/java/com/bitwig/extensions/controllers/mcu/devices/DeviceManager.java index 235132f9..55584c31 100644 --- a/src/main/java/com/bitwig/extensions/controllers/mcu/devices/DeviceManager.java +++ b/src/main/java/com/bitwig/extensions/controllers/mcu/devices/DeviceManager.java @@ -3,31 +3,31 @@ import com.bitwig.extension.controller.api.Parameter; public interface DeviceManager { - + //void initiateBrowsing(final BrowserConfiguration browser, Type type); - + //void addBrowsing(final BrowserConfiguration browser, boolean after); - + //void setInfoLayer(DisplayLayer infoLayer); - + //void enableInfo(InfoSource type); - + void disableInfo(); - + //InfoSource getInfoSource(); - + Parameter getParameter(int index); - + //ParameterPage getParameterPage(int index); - + void navigateDeviceParameters(final int direction); - + //void handleResetInvoked(final int index, final ModifierValueObject modifier); - DeviceTypeFollower getCurrentFollower(); - + DeviceTypeFollower getDeviceFollower(); + boolean isSpecificDevicePresent(); - + int getPageCount(); - + } diff --git a/src/main/java/com/bitwig/extensions/controllers/mcu/devices/DeviceTypeFollower.java b/src/main/java/com/bitwig/extensions/controllers/mcu/devices/DeviceTypeFollower.java index 503b6c34..6fc66512 100644 --- a/src/main/java/com/bitwig/extensions/controllers/mcu/devices/DeviceTypeFollower.java +++ b/src/main/java/com/bitwig/extensions/controllers/mcu/devices/DeviceTypeFollower.java @@ -1,9 +1,15 @@ package com.bitwig.extensions.controllers.mcu.devices; import com.bitwig.extension.callback.BooleanValueChangedCallback; -import com.bitwig.extension.controller.api.*; +import com.bitwig.extension.controller.api.BooleanValue; +import com.bitwig.extension.controller.api.CursorTrack; +import com.bitwig.extension.controller.api.Device; +import com.bitwig.extension.controller.api.DeviceBank; +import com.bitwig.extension.controller.api.DeviceMatcher; +import com.bitwig.extension.controller.api.PinnableCursorDevice; import com.bitwig.extensions.controllers.mcu.CursorDeviceControl; import com.bitwig.extensions.controllers.mcu.VPotMode; +import com.bitwig.extensions.controllers.mcu.value.BasicIntValue; import com.bitwig.extensions.framework.values.BooleanValueObject; public class DeviceTypeFollower { @@ -12,20 +18,24 @@ public class DeviceTypeFollower { private final Device focusDevice; private final CursorDeviceControl cursorDeviceControl; private final BooleanValue cursorOnDevice; + private final BasicIntValue trackIndex = new BasicIntValue(); + private int chainIndex = -1; - + public DeviceTypeFollower(final CursorDeviceControl cursorDeviceControl, final DeviceMatcher matcher, - final VPotMode potMode) { + final VPotMode potMode) { this.cursorDeviceControl = cursorDeviceControl; final CursorTrack cursorTrack = cursorDeviceControl.getCursorTrack(); deviceBank = cursorTrack.createDeviceBank(1); this.potMode = potMode; deviceBank.setDeviceMatcher(matcher); - + focusDevice = deviceBank.getItemAt(0); focusDevice.exists().markInterested(); focusDevice.name().markInterested(); - + + cursorTrack.position().addValueObserver(pos -> trackIndex.set(pos)); + final PinnableCursorDevice cursorDevice = cursorDeviceControl.getCursorDevice(); if (potMode.getAssign() == VPotMode.BitwigType.DEVICE) { final BooleanValueObject matchesTyp = new BooleanValueObject(); @@ -50,19 +60,19 @@ public DeviceTypeFollower(final CursorDeviceControl cursorDeviceControl, final D } }); } - + public void addOnCursorListener(final BooleanValueChangedCallback booleanValueChangedCallback) { cursorOnDevice.addValueObserver(booleanValueChangedCallback); } - + public Device getFocusDevice() { return focusDevice; } - + public Device getCurrentDevice() { return cursorDeviceControl.getCursorDevice(); } - + public void addNewDeviceAfter() { if (focusDevice.exists().get()) { focusDevice.afterDeviceInsertionPoint().browse(); @@ -70,7 +80,7 @@ public void addNewDeviceAfter() { deviceBank.browseToInsertDevice(0); } } - + public void addNewDeviceBefore() { if (focusDevice.exists().get()) { focusDevice.beforeDeviceInsertionPoint().browse(); @@ -78,7 +88,7 @@ public void addNewDeviceBefore() { deviceBank.browseToInsertDevice(0); } } - + public void initiateBrowsing() { if (focusDevice.exists().get()) { focusDevice.replaceDeviceInsertionPoint().browse(); @@ -86,12 +96,14 @@ public void initiateBrowsing() { deviceBank.browseToInsertDevice(0); } } - + public void ensurePosition() { - final int currentDiveChainLocation = cursorDeviceControl.getCursorDevice().position().get(); if (!cursorOnDevice.get()) { cursorDeviceControl.getCursorDevice().selectDevice(focusDevice); } } - + + public BasicIntValue getTrackIndex() { + return trackIndex; + } } diff --git a/src/main/java/com/bitwig/extensions/controllers/mcu/devices/SpecificDevice.java b/src/main/java/com/bitwig/extensions/controllers/mcu/devices/SpecificDevice.java index 6d68b579..8a120bd3 100644 --- a/src/main/java/com/bitwig/extensions/controllers/mcu/devices/SpecificDevice.java +++ b/src/main/java/com/bitwig/extensions/controllers/mcu/devices/SpecificDevice.java @@ -81,7 +81,7 @@ public BooleanValue getExists() { } @Override - public DeviceTypeFollower getCurrentFollower() { + public DeviceTypeFollower getDeviceFollower() { return deviceFollower; } diff --git a/src/main/java/com/bitwig/extensions/controllers/mcu/display/LcdDisplay.java b/src/main/java/com/bitwig/extensions/controllers/mcu/display/LcdDisplay.java index a922ffda..2157508d 100644 --- a/src/main/java/com/bitwig/extensions/controllers/mcu/display/LcdDisplay.java +++ b/src/main/java/com/bitwig/extensions/controllers/mcu/display/LcdDisplay.java @@ -1,5 +1,8 @@ package com.bitwig.extensions.controllers.mcu.display; +import java.util.Arrays; +import java.util.List; + import com.bitwig.extension.controller.api.HardwareSurface; import com.bitwig.extension.controller.api.HardwareTextDisplay; import com.bitwig.extension.controller.api.MidiOut; @@ -10,87 +13,84 @@ import com.bitwig.extensions.framework.di.Context; import com.bitwig.extensions.framework.values.Midi; -import java.util.Arrays; -import java.util.List; - /** * Represents 2x56 LCD display on the MCU or an extender. */ public class LcdDisplay { private static final int DISPLAY_LEN = 55; private static final int ROW2_START = 56; - + private final byte[] rowDisplayBuffer = { // - (byte) 0XF0, 0, 0, 0X66, 0x14, 0x12, 0, // z: the grid number Zone number 0-3 * 28 - 32, 32, 32, 0, 0, 0, 0, 0, 0, 0, // 7: 10 Chars - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 7: 10 Chars - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 7: 10 Chars - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 7: 10 Chars - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 7: 10 Chars - 0, 0, 0, 0, 0, 32, 32, (byte) 247}; - + (byte) 0XF0, 0, 0, 0X66, 0x14, 0x12, 0, // z: the grid number Zone number 0-3 * 28 + 32, 32, 32, 0, 0, 0, 0, 0, 0, 0, // 7: 10 Chars + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 7: 10 Chars + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 7: 10 Chars + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 7: 10 Chars + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 7: 10 Chars + 0, 0, 0, 0, 0, 32, 32, (byte) 247 + }; + private final byte[] segBuffer; private final byte[] segBufferExp; private final DisplayPart part; private final HardwareTextDisplay displayRep; private final boolean topRowFlipped; - public String sysHead; - - private final String[][] lastSendGrids = new String[][]{{"", "", "", "", "", "", "", "", ""}, // - {"", "", "", "", "", "", "", "", ""}}; - private final String[] lastSentRows = new String[]{"", ""}; - private final boolean[] fullTextMode = new boolean[]{false, false}; - + private final String[][] lastSendGrids = new String[][] { + {"", "", "", "", "", "", "", "", ""}, // + {"", "", "", "", "", "", "", "", ""} + }; + private final String[] lastSentRows = new String[] {"", ""}; + private final boolean[] fullTextMode = new boolean[] {false, false}; private final MidiOut midiOut; - private VuMode vuMode = VuMode.LED; - private boolean displayBarGraphEnabled = true; private boolean isLowerDisplay; - private final int displayLen; - private final int segmentLength; private final int segmentOffset; private final boolean hasDedicatedVu; - private final char[][] lines = new char[2][60]; - + public String sysHead; + public LcdDisplay(final Context context, final int sectionIndex, final MidiOut midiOut, final SectionType type, - final DisplayPart part, ControllerConfig controllerConfig) { + final DisplayPart part, final ControllerConfig controllerConfig) { this.midiOut = midiOut; this.hasDedicatedVu = controllerConfig.isHasDedicateVu(); this.topRowFlipped = controllerConfig.isTopDisplayRowsFlipped(); this.part = part; - HardwareSurface surface = context.getService(HardwareSurface.class); - GlobalStates states = context.getService(GlobalStates.class); + final HardwareSurface surface = context.getService(HardwareSurface.class); + final GlobalStates states = context.getService(GlobalStates.class); displayRep = surface.createHardwareTextDisplay("DISPLAY_SIMU_" + part + "_" + sectionIndex, 2); - + //initSimulation(driver, sectionIndex, part); - + if (part == DisplayPart.LOWER) { isLowerDisplay = true; rowDisplayBuffer[3] = 0X67; rowDisplayBuffer[4] = 0x15; rowDisplayBuffer[5] = 0x13; sysHead = "f0 00 00 67 15 "; - segBuffer = new byte[]{ // - (byte) 240, 0, 0, 0X67, 0x15, 0x13, 0, // z: the grid number Zone number 0-3 * 28 - 0, 0, 0, 0, 0, 32, // 7: 10 Chars - (byte) 247}; - segBufferExp = new byte[]{ // - (byte) 240, 0, 0, 0X67, 0x15, 0x13, 0, // z: the grid number Zone number 0-3 * 28 - 0, 0, 0, 0, 0, 0, 32, // 7: 10 Chars - (byte) 247}; + segBuffer = new byte[] { // + (byte) 240, 0, 0, 0X67, 0x15, 0x13, 0, // z: the grid number Zone number 0-3 * 28 + 0, 0, 0, 0, 0, 32, // 7: 10 Chars + (byte) 247 + }; + segBufferExp = new byte[] { // + (byte) 240, 0, 0, 0X67, 0x15, 0x13, 0, // z: the grid number Zone number 0-3 * 28 + 0, 0, 0, 0, 0, 0, 32, // 7: 10 Chars + (byte) 247 + }; } else { - segBuffer = new byte[]{ // - (byte) 240, 0, 0, 102, 20, 18, 0, // z: the grid number Zone number 0-3 * 28 - 0, 0, 0, 0, 0, 0, 0, // 7: 10 Chars - (byte) 247}; - segBufferExp = new byte[]{ // - (byte) 240, 0, 0, 102, 20, 18, 0, // z: the grid number Zone number 0-3 * 28 - 0, 0, 0, 0, 0, 0, 0, // 7: 10 Chars - (byte) 247}; + segBuffer = new byte[] { // + (byte) 240, 0, 0, 102, 20, 18, 0, // z: the grid number Zone number 0-3 * 28 + 0, 0, 0, 0, 0, 0, 0, // 7: 10 Chars + (byte) 247 + }; + segBufferExp = new byte[] { // + (byte) 240, 0, 0, 102, 20, 18, 0, // z: the grid number Zone number 0-3 * 28 + 0, 0, 0, 0, 0, 0, 0, // 7: 10 Chars + (byte) 247 + }; if (type == SectionType.XTENDER) { rowDisplayBuffer[4] = 0x15; segBuffer[4] = 0x15; @@ -100,7 +100,7 @@ public LcdDisplay(final Context context, final int sectionIndex, final MidiOut m } } displayLen = LcdDisplay.DISPLAY_LEN + (part == DisplayPart.LOWER && type != SectionType.XTENDER ? 1 : 0); - + if (part == DisplayPart.LOWER) { segmentLength = 6; segmentOffset = 2; @@ -110,28 +110,29 @@ public LcdDisplay(final Context context, final int sectionIndex, final MidiOut m } setVuMode(states.getVuMode().get()); } - -// private void initSimulation(final MackieMcuProExtension driver, final int sectionIndex, final DisplayPart part) { -// driver.getControllerConfig().getSimulationLayout().layoutDisplay(part, sectionIndex, displayRep); -// for (int i = 0; i < 2; i++) { -// Arrays.fill(lines[i], ' '); -// } -// } - + + // private void initSimulation(final MackieMcuProExtension driver, final int sectionIndex, final DisplayPart + // part) { + // driver.getControllerConfig().getSimulationLayout().layoutDisplay(part, sectionIndex, displayRep); + // for (int i = 0; i < 2; i++) { + // Arrays.fill(lines[i], ' '); + // } + // } + public int getSegmentLength() { return segmentLength; } - + public boolean isLowerDisplay() { return isLowerDisplay; } - + public void setFullTextMode(final int row, final boolean fullTextMode) { this.fullTextMode[row] = fullTextMode; setDisplayBarGraphEnabled(!isFullModeActive()); refreshDisplay(); } - + public void setDisplayBarGraphEnabled(final boolean displayBarGraphEnabled) { if (this.displayBarGraphEnabled == displayBarGraphEnabled) { return; @@ -145,11 +146,11 @@ public void setDisplayBarGraphEnabled(final boolean displayBarGraphEnabled) { switchVuMode(VuMode.LED); } } - + private boolean isFullModeActive() { return fullTextMode[0] | fullTextMode[1]; } - + public void setVuMode(final VuMode mode) { if (hasDedicatedVu) { return; @@ -160,7 +161,7 @@ public void setVuMode(final VuMode mode) { refreshDisplay(); } } - + private void switchVuMode(final VuMode mode) { switch (mode) { case LED: @@ -187,20 +188,20 @@ private void switchVuMode(final VuMode mode) { break; } } - + private void resetGrids(final int row) { Arrays.fill(lastSendGrids[row], " "); } - + public void centerText(final int row, final String text) { sendToDisplay(row, pad4Center(text)); } - + @Override public String toString() { return "LcdDisplay " + part; } - + private String pad4Center(final String text) { final int fill = displayLen - text.length(); if (fill < 0) { @@ -211,7 +212,7 @@ private String pad4Center(final String text) { } return StringUtil.padString(text, fill / 2); } - + public void sendDirect(final String topString, final String bottomString) { lastSentRows[0] = topString; lastSentRows[1] = bottomString; @@ -220,23 +221,23 @@ public void sendDirect(final String topString, final String bottomString) { sendFullRow(0, topString); sendFullRow(1, bottomString); } - + public void sendSegmented(final int row, final List texts) { for (int i = 0; i < 8; i++) { - String text = i < texts.size() ? texts.get(i) : ""; + final String text = i < texts.size() ? texts.get(i) : ""; sendToRowFull(row, i, text); } } - + public void sendToDisplay(final int row, final String text) { -// if (text.equals(lastSentRows[row])) { -// return; -// } + // if (text.equals(lastSentRows[row])) { + // return; + // } lastSentRows[row] = text; resetGrids(row); sendFullRow(row, text); } - + public void sendFullRow(final int row, final String text) { rowDisplayBuffer[6] = (byte) (row * LcdDisplay.ROW2_START); final char[] ca = text.toCharArray(); @@ -246,7 +247,7 @@ public void sendFullRow(final int row, final String text) { displayRep.line(row).text().setValue(text); midiOut.sendSysex(rowDisplayBuffer); } - + public void sendToRow(final int row, final int segment, final String text) { if (row > 1 || row < 0) { return; @@ -256,7 +257,7 @@ public void sendToRow(final int row, final int segment, final String text) { sendTextSeg(row, segment, text); } } - + public void sendToRowFull(final int row, final int segment, final String text) { if (row > 1 || row < 0) { return; @@ -266,7 +267,7 @@ public void sendToRowFull(final int row, final int segment, final String text) { sendTextSegFull(row, segment, text); } } - + private void sendTextSegFull(final int row, final int segment, final String text) { segBuffer[6] = (byte) (row * LcdDisplay.ROW2_START + segment * segmentLength + segmentOffset); final char[] ca = text.toCharArray(); @@ -277,7 +278,7 @@ private void sendTextSegFull(final int row, final int segment, final String text midiOut.sendSysex(segBuffer); displayRep.line(row).text().setValue(String.valueOf(lines[row])); } - + private void sendTextSeg(final int row, final int segment, final String text) { final char[] ca = text.toCharArray(); if (segment == 8) { @@ -297,7 +298,7 @@ private void sendTextSeg(final int row, final int segment, final String text) { displayRep.line(row).text().setValue(String.valueOf(lines[row])); } } - + private void handleLastCell(final int row, final int segment, final char[] ca) { segBufferExp[6] = (byte) (row * LcdDisplay.ROW2_START + segment * segmentLength + segmentOffset); for (int i = 0; i < segmentLength; i++) { @@ -308,7 +309,7 @@ private void handleLastCell(final int row, final int segment, final char[] ca) { } midiOut.sendSysex(segBufferExp); } - + public void refreshDisplay() { for (int row = 0; row < 2; row++) { if (fullTextMode[row]) { @@ -320,27 +321,27 @@ public void refreshDisplay() { } } } - + public void sendChar(final int index, final char cx) { midiOut.sendMidi(Midi.CC, 0x30, cx); } - + public void clearAll() { midiOut.sendSysex(sysHead + "62 f7"); sendToDisplay(0, ""); sendToDisplay(1, ""); } - + public void exitMessage() { midiOut.sendSysex(sysHead + "62 f7"); centerText(topRowFlipped ? 1 : 0, "Bitwig Studio"); centerText(topRowFlipped ? 0 : 1, "... not running ..."); } - + public void clearText() { sendToDisplay(0, ""); sendToDisplay(1, ""); } - - + + } diff --git a/src/main/java/com/bitwig/extensions/controllers/mcu/layer/SpecialDeviceModeLayer.java b/src/main/java/com/bitwig/extensions/controllers/mcu/layer/SpecialDeviceModeLayer.java index 251a6346..c30b953f 100644 --- a/src/main/java/com/bitwig/extensions/controllers/mcu/layer/SpecialDeviceModeLayer.java +++ b/src/main/java/com/bitwig/extensions/controllers/mcu/layer/SpecialDeviceModeLayer.java @@ -1,5 +1,6 @@ package com.bitwig.extensions.controllers.mcu.layer; +import com.bitwig.extensions.controllers.mcu.McuExtension; import com.bitwig.extensions.controllers.mcu.VPotMode; import com.bitwig.extensions.controllers.mcu.bindings.ResetableBinding; import com.bitwig.extensions.controllers.mcu.bindings.display.StringRowDisplayBinding; @@ -38,6 +39,7 @@ public SpecialDeviceModeLayer(final Layers layers, final ControlMode mode, final bottomRowInfoText)); device.addUpdateListeners(this::updateBindings); device.addExistChangeListener(this::handleExistenceChanged); + device.getDeviceFollower().getTrackIndex().addListener(this::changeTrackIndex); } private void updateBindings() { @@ -66,6 +68,14 @@ private void resetBindings(final Layer layer) { .forEach(binding -> binding.reset()); } + private void changeTrackIndex(final int index) { + if (active) { + if (device.isSpecificDevicePresent()) { + device.getDeviceFollower().ensurePosition(); + } + } + } + @Override public void assign() { final ControlMode mainMode = !mixer.isFlipped() ? mode : ControlMode.VOLUME; @@ -176,6 +186,10 @@ public void handleInfoState(final boolean start, final Orientation orientation) @Override public void handleModePress(final VPotMode mode, final boolean pressed, final boolean selection) { + McuExtension.println(" Pressed EQ+ %s present=%s", pressed, device.isSpecificDevicePresent()); + if (pressed) { + device.getDeviceFollower().ensurePosition(); + } } } \ No newline at end of file diff --git a/src/main/java/com/bitwig/extensions/controllers/mcu/value/BasicIntValue.java b/src/main/java/com/bitwig/extensions/controllers/mcu/value/BasicIntValue.java new file mode 100644 index 00000000..d2b1ff7b --- /dev/null +++ b/src/main/java/com/bitwig/extensions/controllers/mcu/value/BasicIntValue.java @@ -0,0 +1,30 @@ +package com.bitwig.extensions.controllers.mcu.value; + +import java.util.ArrayList; +import java.util.List; +import java.util.function.IntConsumer; + +public class BasicIntValue { + private int value; + private final List listeners = new ArrayList<>(); + + public void set(final int value) { + if (value != this.value) { + this.value = value; + this.listeners.forEach(listener -> listener.accept(this.value)); + } + } + + public void addListener(final IntConsumer listener) { + this.listeners.add(listener); + } + + public void setImmediately(final int value) { + this.value = value; + } + + public int get() { + return value; + } + +} diff --git a/src/main/resources/Documentation/Controllers/SSL/SSL UF8-UF1.pdf b/src/main/resources/Documentation/Controllers/SSL/SSL UF8-UF1.pdf index 3eff4eae..949776e7 100644 Binary files a/src/main/resources/Documentation/Controllers/SSL/SSL UF8-UF1.pdf and b/src/main/resources/Documentation/Controllers/SSL/SSL UF8-UF1.pdf differ