Skip to content

Commit

Permalink
Merge pull request #91 from ericahrens/api-18
Browse files Browse the repository at this point in the history
Diverse minor issue including assertion errors
  • Loading branch information
NickJAllen authored Jun 17, 2024
2 parents ac206b1 + b7144a4 commit 1d4cc25
Show file tree
Hide file tree
Showing 32 changed files with 222 additions and 93 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class GlobalStates {

private final BooleanValueObject flipped = new BooleanValueObject();
private final BooleanValueObject nameValue = new BooleanValueObject();
private final BooleanValueObject globalView = new BooleanValueObject();
private final BooleanValueObject globalView = new BooleanValueObject(true);
private final BooleanValueObject clipLaunchingActive = new BooleanValueObject();
private final BooleanValueObject duplicateHeld = new BooleanValueObject();
private final BooleanValueObject clearHeld = new BooleanValueObject();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ public void init() {
final List<MainSection> mainSections = new ArrayList<>();
final List<MixerSection> mixerSections = new ArrayList<>();

// showPortINfos(PlatformType.MAC);
// showPortINfos(PlatformType.WINDOWS);
//showPortINfos(PlatformType.MAC);
showPortINfos(PlatformType.WINDOWS);

for (int portIndex = 0; portIndex < controllerConfig.getNrOfExtenders() + 1; portIndex++) {
final MidiProcessor midiProcessor = new MidiProcessor(diContext, portIndex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class TrackBankView {
private final GlobalStates globalStates;
private int selectedIndex;
private int numberOfSendsOverall = 0;
private String trackType = "";

public TrackBankView(final TrackBank trackBank, final GlobalStates globalStates, final boolean isExtended,
final int numberOfSends) {
Expand All @@ -23,7 +24,11 @@ public TrackBankView(final TrackBank trackBank, final GlobalStates globalStates,
this.globalStates = globalStates;
trackColors = new int[trackBank.getSizeOfBank()];
prepareTrackBank();
trackBank.itemCount().addValueObserver(items -> this.itemCount = items);
trackBank.itemCount().addValueObserver(items -> {
this.itemCount = items;
updateSelectedTrackInfo();
});
this.globalStates.getGlobalView().addValueObserver(globalView -> updateSelectedTrackInfo());
}

private void prepareTrackBank() {
Expand All @@ -32,9 +37,6 @@ private void prepareTrackBank() {
final Track track = trackBank.getItemAt(i);
track.sendBank().scrollPosition().markInterested();
track.sendBank().itemCount().markInterested();
if (i == 0) {
track.sendBank().itemCount().addValueObserver(items -> numberOfSendsOverall = items);
}
}
}
trackBank.canScrollChannelsDown().markInterested();
Expand All @@ -45,15 +47,23 @@ private void prepareTrackBank() {
}
}

public void setCursorTrackPosition(final int trackPosition) {
this.selectedIndex = trackPosition;
updateSelectedTrackInfo();
}

public void setTrackType(final String trackType) {
this.trackType = trackType;
updateSelectedTrackInfo();
}

public void setNumberOfSends(final int numberOfSends) {
this.numberOfSendsOverall = numberOfSends;
updateSelectedTrackInfo();
}

private void configureTrack(final Track track, final int index) {
track.color().addValueObserver((r, g, b) -> trackColors[index] = toColor(r, g, b));
track.addIsSelectedInMixerObserver(selected -> {
if (selected) {
this.selectedIndex = index + trackBank.scrollPosition().get();
updateSelectedTrackInfo(track);
}
});
track.trackType().markInterested();
}

private static int toColor(final double r, final double g, final double b) {
Expand All @@ -63,11 +73,16 @@ private static int toColor(final double r, final double g, final double b) {
return red << 16 | green << 8 | blue;
}

private void updateSelectedTrackInfo(final Track track) {
if (track.trackType().get().equals("Master")) {
private void updateSelectedTrackInfo() {
if (globalStates.getGlobalView().get() != isExtended) {
return;
}
if (trackType.equals("Master")) {
globalStates.notifySelectedTrackState("MT", isExtended);
} else if (track.trackType().get().equals("Effect")) {
final int sndPos = numberOfSendsOverall - (itemCount - selectedIndex - 1);
} else if (trackType.equals("Effect")) {
final int sndPos =
isExtended ? numberOfSendsOverall - (itemCount - selectedIndex - 1) : selectedIndex - itemCount;

globalStates.notifySelectedTrackState("F%01d".formatted(sndPos + 1), isExtended);
} else {
globalStates.notifySelectedTrackState("%02d".formatted(selectedIndex + 1), isExtended);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,19 @@ public ViewControl(final ControllerHost host, final ControllerConfig controllerC
new TrackBankView(host.createTrackBank(numberOfHwChannels, numberOfSends, nrOfScenes), globalStates, true,
numberOfSends);

cursorTrack.position().addValueObserver(trackPosition -> {
mainTrackBank.setCursorTrackPosition(trackPosition);
globalTrackBank.setCursorTrackPosition(trackPosition);
});
cursorTrack.trackType().addValueObserver(trackType -> {
mainTrackBank.setTrackType(trackType);
globalTrackBank.setTrackType(trackType);
});
cursorTrack.sendBank().itemCount().addValueObserver(items -> {
mainTrackBank.setNumberOfSends(items);
globalTrackBank.setNumberOfSends(items);
});

mainTrackBank.getTrackBank().followCursorTrack(cursorTrack);
globalTrackBank.getTrackBank().followCursorTrack(cursorTrack);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import com.bitwig.extensions.controllers.mcu.definitions.ManufacturerType;
import com.bitwig.extensions.controllers.mcu.definitions.SubType;
import com.bitwig.extensions.controllers.mcu.display.TimeCodeLed;

public class ControllerConfig {
private boolean hasLowerDisplay;
Expand All @@ -28,6 +29,7 @@ public class ControllerConfig {
private final Map<McuFunction, ButtonAssignment> assignmentMap = new HashMap<>();
private boolean hasTimeCodeLed;
private EncoderBehavior jogWheelBehavior = EncoderBehavior.STEP;
private TimeCodeLed.DisplayType displayType = TimeCodeLed.DisplayType.MCU;

public ControllerConfig(final ManufacturerType manufacturerType, final SubType subType) {
this.manufacturerType = manufacturerType;
Expand Down Expand Up @@ -159,6 +161,14 @@ public boolean isDecelerateJogWheel() {
return decelerateJogWheel;
}

public TimeCodeLed.DisplayType getDisplayType() {
return displayType;
}

public void setDisplayType(final TimeCodeLed.DisplayType displayType) {
this.displayType = displayType;
}

public ControllerConfig setDecelerateJogWheel(final boolean decelerateJogWheel) {
this.decelerateJogWheel = decelerateJogWheel;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public MainHardwareSection(final Context context, final MidiProcessor midiProces
case STEP -> setUp2Complement(midiProcessor);
case STEP_1_65 -> setUpStepped(midiProcessor, config.getJogWheelBehavior());
}
timeCodeLed = config.hasTimecodeLed() ? new TimeCodeLed(midiProcessor) : null;
timeCodeLed = config.hasTimecodeLed() ? new TimeCodeLed(midiProcessor, config.getDisplayType()) : null;
}

private void setUpAccelerated(final MidiProcessor midiProcessor) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public int getNoteNr() {

public void bindToggle(final Layer layer, final SettableBooleanValue value) {
layer.bind(hwButton, hwButton.pressedAction(), () -> value.toggle());
layer.addBinding(layer.bind(value, light.isOn()));
layer.bind(value, light.isOn());
}

public void bindIsPressed(final Layer layer, final BooleanValueChangedCallback callback) {
Expand All @@ -76,23 +76,23 @@ public void bindIsPressed(final Layer layer, final BooleanValueChangedCallback c

public void bindLight(final Layer layer, final BooleanValue value) {
value.markInterested();
layer.addBinding(layer.bind(value, light.isOn()));
layer.bind(value, light.isOn());
}

public void bindLight(final Layer layer, final BooleanSupplier value) {
layer.addBinding(layer.bind(value, light.isOn()));
layer.bind(value, light.isOn());
}

public void bindMomentary(final Layer layer, final BooleanValueObject value) {
layer.bind(hwButton, hwButton.pressedAction(), () -> value.set(true));
layer.bind(hwButton, hwButton.releasedAction(), () -> value.set(false));
layer.addBinding(layer.bind(value, light.isOn()));
layer.bind(value, light.isOn());
}

public void bindMode(final Layer layer, final Consumer<Boolean> consumer, final BooleanSupplier ledState) {
layer.bind(hwButton, hwButton.pressedAction(), () -> consumer.accept(true));
layer.bind(hwButton, hwButton.releasedAction(), () -> consumer.accept(false));
layer.addBinding(layer.bind(ledState, light.isOn()));
layer.bind(ledState, light.isOn());
}

public void bindRelease(final Layer layer, final Runnable action) {
Expand All @@ -109,7 +109,7 @@ public void bindPressed(final Layer layer, final Runnable action) {
}

public void bindHeldLight(final Layer layer) {
layer.addBinding(layer.bind(hwButton.isPressed(), light.isOn()));
layer.bind(hwButton.isPressed(), light.isOn());
}

public void bindPressed(final Layer layer, final HardwareActionBindable action) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

public abstract class AbstractIconExtensionDefinition extends AbstractMcuControllerExtensionDefinition {
private static final String[] PORT_VARIANTS = new String[] {"Anschluss", "Port"};
protected static final String SOFTWARE_VERSION = "0.2";
protected static final String SOFTWARE_VERSION = "1.0";

public AbstractIconExtensionDefinition() {
this(0);
Expand All @@ -27,7 +27,9 @@ public AbstractIconExtensionDefinition(final int nrOfExtenders) {
private String getInPortName(final PlatformType platformType, final String baseDevicePort,
final String portNameVariant, final int port) {
return switch (platformType) {
case WINDOWS -> port == 1 ? baseDevicePort : "MIDIIN%d (%s%s)".formatted(port, baseDevicePort, getFiller());
case WINDOWS -> port == 1
? baseDevicePort + getFiller()
: "MIDIIN%d (%s%s)".formatted(port, baseDevicePort, getFiller());
case LINUX -> "%s MIDI %d".formatted(baseDevicePort, port);
case MAC -> "%s %s %d".formatted(baseDevicePort, portNameVariant, port);
};
Expand All @@ -36,8 +38,9 @@ private String getInPortName(final PlatformType platformType, final String baseD
private String getOutPortName(final PlatformType platformType, final String baseDevicePort,
final String portNameVariant, final int port) {
return switch (platformType) {
case WINDOWS ->
port == 1 ? baseDevicePort : "MIDIOUT%d (%s%s)".formatted(port, baseDevicePort, getFiller());
case WINDOWS -> port == 1
? baseDevicePort + getFiller()
: "MIDIOUT%d (%s%s)".formatted(port, baseDevicePort, getFiller());
case LINUX -> "%s MIDI %d".formatted(baseDevicePort, port);
case MAC -> "%s %s %d".formatted(baseDevicePort, portNameVariant, port);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import com.bitwig.extensions.controllers.mcu.definitions.SubType;

public class IconP1NanoExtensionDefinition extends AbstractIconExtensionDefinition {
private static final UUID DRIVER_ID = UUID.fromString("5cde7e5c-9357-42f9-a984-e24ab3b04a1a");
private static final UUID DRIVER_ID = UUID.fromString("36b7888b-28fb-4cce-b335-62b832449663");
private static final String DEVICE_NAME = "iCON P1-Nano";
protected static final String BASE_DEVICE_PORT = "iCON P1-Nano %s"; //
protected static final String[] VERSIONS = {"V1.21", "V1.22"};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

import java.util.UUID;

public class Iconp1NanoPlus1ExtenderExtensionDefinition extends IconP1NanoExtensionDefinition {
private static final UUID DRIVER_ID = UUID.fromString("8b027591-fc6b-2dbd-9c23-4b8e05b755db");
public class IconP1NanoPlus1ExtenderExtensionDefinition extends IconP1NanoExtensionDefinition {
private static final UUID DRIVER_ID = UUID.fromString("3fb9dd44-f934-41e4-b5c2-83842d1cf526");

public Iconp1NanoPlus1ExtenderExtensionDefinition() {
public IconP1NanoPlus1ExtenderExtensionDefinition() {
this(1);
}

public Iconp1NanoPlus1ExtenderExtensionDefinition(final int nrOfExtenders) {
public IconP1NanoPlus1ExtenderExtensionDefinition(final int nrOfExtenders) {
super(nrOfExtenders);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

import java.util.UUID;

public class Iconp1NanoPlus2ExtenderExtensionDefinition extends IconP1NanoExtensionDefinition {
private static final UUID DRIVER_ID = UUID.fromString("8b027591-fc6b-2dbd-9c71-4b8e05b755db");
public class IconP1NanoPlus2ExtenderExtensionDefinition extends IconP1NanoExtensionDefinition {
private static final UUID DRIVER_ID = UUID.fromString("6208f5aa-017c-4d60-8635-1d1c4a04478a");

public Iconp1NanoPlus2ExtenderExtensionDefinition() {
public IconP1NanoPlus2ExtenderExtensionDefinition() {
this(2);
}

public Iconp1NanoPlus2ExtenderExtensionDefinition(final int nrOfExtenders) {
public IconP1NanoPlus2ExtenderExtensionDefinition(final int nrOfExtenders) {
super(nrOfExtenders);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

import java.util.UUID;

public class Iconp1NanoPlus3ExtenderExtensionDefinition extends IconP1NanoExtensionDefinition {
private static final UUID DRIVER_ID = UUID.fromString("8b027591-fc1a-2dbd-9c71-4b8e05b755db");
public class IconP1NanoPlus3ExtenderExtensionDefinition extends IconP1NanoExtensionDefinition {
private static final UUID DRIVER_ID = UUID.fromString("a0b39436-f6b6-4662-b535-85de86626ad4");

public Iconp1NanoPlus3ExtenderExtensionDefinition() {
public IconP1NanoPlus3ExtenderExtensionDefinition() {
this(3);
}

public Iconp1NanoPlus3ExtenderExtensionDefinition(final int nrOfExtenders) {
public IconP1NanoPlus3ExtenderExtensionDefinition(final int nrOfExtenders) {
super(nrOfExtenders);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
import com.bitwig.extensions.controllers.mcu.config.EncoderBehavior;
import com.bitwig.extensions.controllers.mcu.definitions.ManufacturerType;
import com.bitwig.extensions.controllers.mcu.definitions.SubType;
import com.bitwig.extensions.controllers.mcu.display.TimeCodeLed;

public class IconP1mExtensionDefinition extends AbstractIconExtensionDefinition {
private static final UUID DRIVER_ID = UUID.fromString("8b027591-dc6a-4dbd-9c23-4b8e05b755db");
private static final UUID DRIVER_ID = UUID.fromString("e57683e3-3ff5-4f2b-bee3-6cade432a685");
private static final String DEVICE_NAME = "iCON P1-M";
protected static final String BASE_DEVICE_PORT = "iCON P1-M %s"; //iCON P1-Nano V1.19
protected static final String[] VERSIONS = {"V1.06", "V1.07"};
Expand Down Expand Up @@ -43,7 +44,7 @@ public String getHelpFilePath() {

@Override
protected ControllerConfig createControllerConfig() {
return new ControllerConfig(ManufacturerType.ICON, SubType.P1M) //
final ControllerConfig config = new ControllerConfig(ManufacturerType.ICON, SubType.P1M) //
.setHasDedicateVu(true)//
.setHasLowerDisplay(true) //
.setHasMasterFader(0x8) //
Expand All @@ -56,12 +57,14 @@ protected ControllerConfig createControllerConfig() {
.setJogWheelCoding(EncoderBehavior.ACCEL) //
.setDecelerateJogWheel(true) //
.setHasMasterVu(true);
config.setDisplayType(TimeCodeLed.DisplayType.ICON);
return config;
}

@Override
public String getName() {
if (nrOfExtenders == 0) {
return IconP1mExtensionDefinition.DEVICE_NAME;
return IconP1mExtensionDefinition.DEVICE_NAME + getFiller();
}
return String.format("%s +%d EXTENDER", IconP1mExtensionDefinition.DEVICE_NAME, nrOfExtenders);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.util.UUID;

public class IconP1mPlus1ExtenderExtensionDefinition extends IconP1mExtensionDefinition {
private static final UUID DRIVER_ID = UUID.fromString("8b027591-fc6b-1dbd-9c23-4b8e05b755db");
private static final UUID DRIVER_ID = UUID.fromString("f7166b22-b3de-4c8f-8173-06e0995f102e");

public IconP1mPlus1ExtenderExtensionDefinition() {
this(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.util.UUID;

public class IconP1mPlus2ExtenderExtensionDefinition extends IconP1mExtensionDefinition {
private static final UUID DRIVER_ID = UUID.fromString("8b027591-fc6b-2dbd-9c23-4b8e05b755db");
private static final UUID DRIVER_ID = UUID.fromString("aa9bdf05-be3f-45f1-b9d2-4ec2016c2851");

public IconP1mPlus2ExtenderExtensionDefinition() {
this(2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.util.UUID;

public class IconP1mPlus3ExtenderExtensionDefinition extends IconP1mExtensionDefinition {
private static final UUID DRIVER_ID = UUID.fromString("8b027591-fc6b-4db1-9c23-4b8e05b755db");
private static final UUID DRIVER_ID = UUID.fromString("358db9a4-b7e7-43f4-8a3d-76590c3a28e3");

public IconP1mPlus3ExtenderExtensionDefinition() {
this(3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import com.bitwig.extensions.controllers.mcu.definitions.SubType;

public class IconV1mExtensionDefinition extends AbstractIconExtensionDefinition {
private static final UUID DRIVER_ID = UUID.fromString("faa99215-1162-4159-a513-970342d6dd9d");
private static final UUID DRIVER_ID = UUID.fromString("ee3903ba-e348-40fc-9e52-45e28fb11703");
private static final String DEVICE_NAME = "iCON V1-M";
protected static final String BASE_DEVICE_PORT = "iCON V1-M %s";
protected static final String[] VERSIONS = {"V1.16", "V1.17", "V1.18"};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.util.UUID;

public class IconV1mPlus1ExtenderExtensionDefinition extends IconV1mExtensionDefinition {
private static final UUID DRIVER_ID = UUID.fromString("aaa99215-1162-4159-afc3-970342d6dd9d");
private static final UUID DRIVER_ID = UUID.fromString("db102763-745b-476a-a6ee-f099c3ad1d5e");

public IconV1mPlus1ExtenderExtensionDefinition() {
super(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.util.UUID;

public class IconV1mPlus2ExtenderExtensionDefinition extends IconV1mExtensionDefinition {
private static final UUID DRIVER_ID = UUID.fromString("aaa99216-2262-4159-afc3-970342d6dd9d");
private static final UUID DRIVER_ID = UUID.fromString("ffc8800a-2801-45e0-80cb-928684d83cc9");

public IconV1mPlus2ExtenderExtensionDefinition() {
super(2);
Expand Down
Loading

0 comments on commit 1d4cc25

Please sign in to comment.