Skip to content

Commit

Permalink
Code style
Browse files Browse the repository at this point in the history
  • Loading branch information
NickJAllen committed Jan 11, 2024
1 parent 9421f5e commit 90f6feb
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.bitwig.extensions.controllers.arturia.minilab3;

import java.util.Arrays;

import com.bitwig.extension.controller.api.ClipLauncherSlot;
import com.bitwig.extension.controller.api.MultiStateHardwareLight;
import com.bitwig.extension.controller.api.Track;
import com.bitwig.extension.controller.api.TrackBank;
import com.bitwig.extensions.framework.Layer;

import java.util.Arrays;

public class ClipLaunchingLayer extends Layer {

private final RgbLightState[] sceneSlotColors = new RgbLightState[8];
Expand All @@ -17,8 +17,6 @@ public class ClipLaunchingLayer extends Layer {
private final MiniLab3Extension driver;
private int blinkState;
private long clipsStopTiming = 800;
private final byte[] colorBuffer = new byte[24];
private final byte[] currentBuffer = new byte[24];

public ClipLaunchingLayer(final MiniLab3Extension driver) {
super(driver.getLayers(), "CLIP LAUNCHER");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,52 @@
package com.bitwig.extensions.controllers.arturia.minilab3;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executors;
import java.util.function.IntConsumer;

import com.bitwig.extension.api.util.midi.ShortMidiMessage;
import com.bitwig.extension.callback.ShortMidiMessageReceivedCallback;
import com.bitwig.extension.controller.ControllerExtension;
import com.bitwig.extension.controller.api.*;
import com.bitwig.extension.controller.api.AbsoluteHardwareControl;
import com.bitwig.extension.controller.api.AbsoluteHardwareKnob;
import com.bitwig.extension.controller.api.BooleanValue;
import com.bitwig.extension.controller.api.ControllerHost;
import com.bitwig.extension.controller.api.CursorDeviceFollowMode;
import com.bitwig.extension.controller.api.CursorRemoteControlsPage;
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.DocumentState;
import com.bitwig.extension.controller.api.HardwareActionBindable;
import com.bitwig.extension.controller.api.HardwareButton;
import com.bitwig.extension.controller.api.HardwareSlider;
import com.bitwig.extension.controller.api.HardwareSurface;
import com.bitwig.extension.controller.api.InternalHardwareLightState;
import com.bitwig.extension.controller.api.MidiIn;
import com.bitwig.extension.controller.api.MidiOut;
import com.bitwig.extension.controller.api.NoteInput;
import com.bitwig.extension.controller.api.Parameter;
import com.bitwig.extension.controller.api.PinnableCursorDevice;
import com.bitwig.extension.controller.api.Preferences;
import com.bitwig.extension.controller.api.RelativeHardwareKnob;
import com.bitwig.extension.controller.api.RelativeHardwareValueMatcher;
import com.bitwig.extension.controller.api.RemoteControl;
import com.bitwig.extension.controller.api.Scene;
import com.bitwig.extension.controller.api.SettableEnumValue;
import com.bitwig.extension.controller.api.SettableRangedValue;
import com.bitwig.extension.controller.api.StringValue;
import com.bitwig.extension.controller.api.TrackBank;
import com.bitwig.extension.controller.api.Transport;
import com.bitwig.extensions.framework.Layer;
import com.bitwig.extensions.framework.Layers;
import com.bitwig.extensions.framework.values.BasicStringValue;
import com.bitwig.extensions.framework.values.BooleanValueObject;
import com.bitwig.extensions.framework.values.ValueObject;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executors;
import java.util.function.IntConsumer;

public class MiniLab3Extension extends ControllerExtension {

public static final int NUM_PADS_TRACK = 8;
Expand Down Expand Up @@ -68,7 +98,7 @@ public class MiniLab3Extension extends ControllerExtension {
private Transport transport;
private PinnableCursorDevice primaryDevice;
private FocusMode recordFocusMode = FocusMode.ARRANGER;
private EncoderStateMaschine encoderStateMaschine = new EncoderStateMaschine();
private final EncoderStateMaschine encoderStateMaschine = new EncoderStateMaschine();

protected MiniLab3Extension(final MiniLab3ExtensionDefinition definition, final ControllerHost host) {
super(definition, host);
Expand Down Expand Up @@ -280,15 +310,15 @@ private void setUpFollowArturiaDevice() {


private void setUpPreferences() {
DocumentState documentState = getHost().getDocumentState(); // THIS
final DocumentState documentState = getHost().getDocumentState(); // THIS
final SettableEnumValue recordButtonAssignment = documentState.getEnumSetting("Record Button assignment", //
"Transport", new String[]{FocusMode.LAUNCHER.getDescriptor(), FocusMode.ARRANGER.getDescriptor()},
recordFocusMode.getDescriptor());
recordButtonAssignment.addValueObserver(value -> {
recordFocusMode = FocusMode.toMode(value);
updateTrackInfo();
});
Preferences preferences = getHost().getPreferences();
final Preferences preferences = getHost().getPreferences();
final SettableEnumValue clipStopTiming = preferences.getEnumSetting("Long press to stop clip", //
"Clip", new String[]{"Fast", "Medium", "Standard"}, "Medium");
clipStopTiming.addValueObserver(clipLaunchingLayer::setClipStopTiming);
Expand Down Expand Up @@ -582,7 +612,7 @@ private void mainEncoderShiftAction(final int dir) {
}
}

private void navigateScenesOrPads(int dir) {
private void navigateScenesOrPads(final int dir) {
if (padBank.get() == PadBank.BANK_A) {
oled.enableValues(DisplayMode.SCENE);
oled.sendTextInfo(DisplayMode.SCENE, cursorTrack.name().get(), sceneTrackItem.name().get(), true);
Expand Down Expand Up @@ -660,8 +690,8 @@ public TrackBank getViewTrackBank() {
}

public void updateBankState(final InternalHardwareLightState state) {
if (state instanceof RgbBankLightState) {
sysExHandler.sendBankState((RgbBankLightState) state);
if (state instanceof final RgbBankLightState lightState) {
sysExHandler.sendBankState(lightState);
}
}

Expand Down Expand Up @@ -713,7 +743,7 @@ public void flush() {
/**
* Make sure no scene is launched upon release.
*/
public void notifyTurn(boolean shift) {
public void notifyTurn(final boolean shift) {
encoderStateMaschine.notifyTurn(shift);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ public HardwareLightVisualState getVisualState() {

@Override
public boolean equals(final Object obj) {
if (obj instanceof RgbBankLightState) {
final RgbBankLightState other = (RgbBankLightState) obj;
if (obj instanceof final RgbBankLightState other) {
return other.bank == bank && Arrays.equals(other.colors, colors);
}
return false;
Expand Down

0 comments on commit 90f6feb

Please sign in to comment.