-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #78 from ericahrens/api-18
Added Akai APC64 and some improvements for Launchpads Mk3
- Loading branch information
Showing
118 changed files
with
10,170 additions
and
5,145 deletions.
There are no files selected for viewing
91 changes: 91 additions & 0 deletions
91
src/main/java/com/bitwig/extensions/controllers/akai/apc/common/AbstractSessionLayer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
package com.bitwig.extensions.controllers.akai.apc.common; | ||
|
||
import com.bitwig.extension.controller.api.ClipLauncherSlot; | ||
import com.bitwig.extension.controller.api.SettableBooleanValue; | ||
import com.bitwig.extension.controller.api.Track; | ||
import com.bitwig.extension.controller.api.TrackBank; | ||
import com.bitwig.extensions.controllers.akai.apc.common.led.LedBehavior; | ||
import com.bitwig.extensions.controllers.akai.apc.common.led.RgbLightState; | ||
import com.bitwig.extensions.controllers.novation.commonsmk3.ColorLookup; | ||
import com.bitwig.extensions.framework.Layer; | ||
import com.bitwig.extensions.framework.Layers; | ||
|
||
public abstract class AbstractSessionLayer extends Layer { | ||
protected final int[][] colorIndex = new int[8][8]; | ||
protected SettableBooleanValue clipLauncherOverdub; | ||
|
||
public AbstractSessionLayer(final Layers layers) { | ||
super(layers, "SESSION_LAYER"); | ||
} | ||
|
||
protected abstract boolean isPlaying(); | ||
|
||
protected abstract boolean isShiftHeld(); | ||
|
||
protected RgbLightState getState(final Track track, final ClipLauncherSlot slot, final int trackIndex, | ||
final int sceneIndex) { | ||
if (slot.hasContent().get()) { | ||
final int color = colorIndex[sceneIndex][trackIndex]; | ||
if (slot.isSelected().get() && isShiftHeld()) { | ||
return RgbLightState.WHITE_BRIGHT; | ||
} | ||
if (slot.isRecordingQueued().get()) { | ||
return RgbLightState.RED.behavior(LedBehavior.BLINK_4); | ||
} else if (slot.isRecording().get()) { | ||
return RgbLightState.RED.behavior(LedBehavior.PULSE_2); | ||
} else if (slot.isPlaybackQueued().get()) { | ||
return RgbLightState.of(color, LedBehavior.BLINK_4); | ||
} else if (slot.isStopQueued().get()) { | ||
return RgbLightState.GREEN_PLAY.behavior(LedBehavior.BLINK_8); | ||
} else if (slot.isPlaying().get() && track.isQueuedForStop().get()) { | ||
return RgbLightState.GREEN.behavior(LedBehavior.BLINK_8); | ||
} else if (slot.isPlaying().get()) { | ||
if (clipLauncherOverdub.get() && track.arm().get()) { | ||
return RgbLightState.RED.behavior(LedBehavior.PULSE_2); | ||
} else { | ||
if (isPlaying()) { | ||
return RgbLightState.GREEN_PLAY; | ||
} | ||
return RgbLightState.GREEN; | ||
} | ||
} | ||
return RgbLightState.of(color); | ||
} | ||
if (slot.isSelected().get() && isShiftHeld()) { | ||
return RgbLightState.WHITE_DIM; | ||
} | ||
if (slot.isRecordingQueued().get()) { | ||
return RgbLightState.RED.behavior(LedBehavior.BLINK_8); // Possibly Track Color | ||
} else if (track.arm().get()) { | ||
return RgbLightState.RED.behavior(LedBehavior.LIGHT_25); | ||
} | ||
return RgbLightState.OFF; | ||
} // V ultra_X_39-- | ||
|
||
protected void markTrackBank(TrackBank bank) { | ||
bank.canScrollBackwards().markInterested(); | ||
bank.canScrollForwards().markInterested(); | ||
bank.sceneBank().canScrollBackwards().markInterested(); | ||
bank.sceneBank().canScrollForwards().markInterested(); | ||
} | ||
|
||
protected void markTrack(final Track track) { | ||
track.isStopped().markInterested(); | ||
track.mute().markInterested(); | ||
track.solo().markInterested(); | ||
track.isQueuedForStop().markInterested(); | ||
track.arm().markInterested(); | ||
} | ||
|
||
protected void prepareSlot(final ClipLauncherSlot slot, final int sceneIndex, final int trackIndex) { | ||
slot.hasContent().markInterested(); | ||
slot.isPlaying().markInterested(); | ||
slot.isStopQueued().markInterested(); | ||
slot.isRecordingQueued().markInterested(); | ||
slot.isRecording().markInterested(); | ||
slot.isPlaybackQueued().markInterested(); | ||
slot.isSelected().markInterested(); | ||
slot.color().addValueObserver((r, g, b) -> colorIndex[sceneIndex][trackIndex] = ColorLookup.toColor(r, g, b)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/main/java/com/bitwig/extensions/controllers/akai/apc/common/OrientationFollowType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.bitwig.extensions.controllers.akai.apc.common; | ||
|
||
import java.util.Arrays; | ||
|
||
public enum OrientationFollowType { | ||
AUTOMATIC("Automatic", "Auto"), // | ||
FIXED_VERTICAL("Mix Panel Layout", "Mixer"), // | ||
FIXED_HORIZONTAL("Arrange Panel Layout", "Arrange"); | ||
|
||
private final String label; | ||
private final String shortLabel; | ||
|
||
OrientationFollowType(final String label, final String shortLabel) { | ||
this.label = label; | ||
this.shortLabel = shortLabel; | ||
} | ||
|
||
public String getLabel() { | ||
return label; | ||
} | ||
|
||
public String getShortLabel() { | ||
return shortLabel; | ||
} | ||
|
||
public static OrientationFollowType toType(final String value) { | ||
return Arrays.stream(OrientationFollowType.values()) | ||
.filter(type -> type.label.equals(value)) | ||
.findFirst() | ||
.orElse(OrientationFollowType.FIXED_VERTICAL); | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
src/main/java/com/bitwig/extensions/controllers/akai/apc/common/PanelLayout.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.bitwig.extensions.controllers.akai.apc.common; | ||
|
||
public enum PanelLayout { | ||
VERTICAL, | ||
HORIZONTAL | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/main/java/com/bitwig/extensions/controllers/akai/apc/common/control/ClickEncoder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package com.bitwig.extensions.controllers.akai.apc.common.control; | ||
|
||
import java.util.function.IntConsumer; | ||
|
||
import com.bitwig.extension.controller.api.ControllerHost; | ||
import com.bitwig.extension.controller.api.HardwareActionBindable; | ||
import com.bitwig.extension.controller.api.HardwareSurface; | ||
import com.bitwig.extension.controller.api.MidiIn; | ||
import com.bitwig.extension.controller.api.Parameter; | ||
import com.bitwig.extension.controller.api.RelativeHardwareKnob; | ||
import com.bitwig.extension.controller.api.RelativeHardwareValueMatcher; | ||
import com.bitwig.extension.controller.api.SettableRangedValue; | ||
import com.bitwig.extensions.framework.Layer; | ||
|
||
public class ClickEncoder { | ||
private final RelativeHardwareKnob encoder; | ||
private final ControllerHost host; | ||
|
||
public ClickEncoder(int ccNr, final ControllerHost host, final HardwareSurface surface, MidiIn midiIn) { | ||
encoder = surface.createRelativeHardwareKnob("ENCODER_" + ccNr); | ||
this.host = host; | ||
final RelativeHardwareValueMatcher stepUpMatcher = | ||
midiIn.createRelativeValueMatcher("(status == 176 && data1 == %d && data2==1)".formatted(ccNr), 1); | ||
final RelativeHardwareValueMatcher stepDownMatcher = | ||
midiIn.createRelativeValueMatcher("(status == 176 && data1 == %d && data2==127)".formatted(ccNr), -1); | ||
|
||
final RelativeHardwareValueMatcher matcher = | ||
host.createOrRelativeHardwareValueMatcher(stepDownMatcher, stepUpMatcher); | ||
encoder.setAdjustValueMatcher(matcher); | ||
encoder.setStepSize(1); | ||
} | ||
|
||
public void setStepSize(final double value) { | ||
encoder.setStepSize(value); | ||
} | ||
|
||
public void bindParameter(final Layer layer, final Parameter parameter) { | ||
final RelativeValueBinding binding = new RelativeValueBinding(encoder, parameter); | ||
layer.addBinding(binding); | ||
} | ||
|
||
public void bind(final Layer layer, final SettableRangedValue value) { | ||
final RelativeValueBinding binding = new RelativeValueBinding(encoder, value); | ||
layer.addBinding(binding); | ||
} | ||
|
||
public void bind(final Layer layer, IntConsumer action) { | ||
final HardwareActionBindable incAction = host.createAction(() -> action.accept(1), () -> "+"); | ||
final HardwareActionBindable decAction = host.createAction(() -> action.accept(-1), () -> "-"); | ||
layer.bind(encoder, host.createRelativeHardwareControlStepTarget(incAction, decAction)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../apcmk2/control/RelativeValueBinding.java → .../common/control/RelativeValueBinding.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
.../akai/apcmk2/control/SingleLedButton.java → ...i/apc/common/control/SingleLedButton.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.