Skip to content

Commit

Permalink
feat(X-Touch): Replace the useEncoderColors config flag with a more…
Browse files Browse the repository at this point in the history
… advanced `displayColorMode` option, also making it possible to disable display color management altogether
  • Loading branch information
bjoluc committed Nov 16, 2023
1 parent 07e4592 commit d8d5eec
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ Then restart Cubase and configure the MIDI Remote by clicking the "+" button in
The very top of the MIDI Remote script file declares a number of configuration options.
You can edit these options to match your preferences.
Each option is documented in a comment above it.
For an overview of all options, please refer to the [source code on GitHub](https://github.com/bjoluc/cubase-xtouch-midiremote/blob/main/src/config.ts#L27-L54).
For an overview of all options, please refer to the [source code on GitHub](https://github.com/bjoluc/cubase-xtouch-midiremote/blob/main/src/config.ts#L28-L84).

## Drawbacks

Expand Down
21 changes: 15 additions & 6 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export type DevicesConfiguration = Array<"main" | "extender">;
export type ScriptConfiguration = Simplify<
Except<typeof CONFIGURATION, "devices"> & {
devices: DevicesConfiguration;
displayColorMode: "encoders" | "channels" | "none";
}
>;

Expand Down Expand Up @@ -53,16 +54,24 @@ var CONFIGURATION = {
mapMainFaderToControlRoom: true,

/**
* By default, scribble strip displays pick up colors from encoders, i.e., each display uses the
* track color of the channel its encoder value belongs to. When an encoder is unassigned, the
* scribble strip below it falls back to the corresponding mixer channel's color.
* The way scribble strip display colors are determined. Set this to
*
* Setting this option to `false` makes scribble strips ignore encoder colors and always use their
* channels' track colors instead.
* * `"encoders"` to make scribble strip displays pick up colors from encoders, i.e., each
* display uses the track color of the channel its encoder value belongs to. When an encoder is
* unassigned, the scribble strip below it falls back to the corresponding mixer channel's
* color.
*
* * `"channels"` to makes scribble strips ignore encoder colors and always use their channels'
* track colors instead. When a channel is unassigned but its encoder is assigned, the display
* will be lit white anyway.
*
* * `"none"` to disable display color management. In that case, scribble strip displays will
* always be white unless a display's channel and encoder is unassigned, in which case the
* display will revert to black.
*
* @device X-Touch
*/
useEncoderColors: true,
displayColorMode: "encoders",

/**
* If you are frequently using display metering on your MCU, you can set this option to `true` to
Expand Down
9 changes: 7 additions & 2 deletions src/midi/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,17 +142,22 @@ export function bindDeviceToMidi(
const currentEncoderColor = encoderColor.get(context);
const currentChannelColor = channelColor.get(context);

if (config.useEncoderColors) {
if (config.displayColorMode === "encoders") {
// Fall back to channel color if encoder is not assigned
color = currentEncoderColor.isAssigned ? currentEncoderColor : currentChannelColor;
} else {
} else if (config.displayColorMode === "channels") {
color = currentChannelColor;

// Use white if an encoder has a color but the channel has none. Otherwise, encoder titles
// on unassigned channels would not be readable.
if (!currentChannelColor.isAssigned && currentEncoderColor.isAssigned) {
color = { r: 1, g: 1, b: 1 };
}
} else {
color =
currentChannelColor.isAssigned || currentEncoderColor.isAssigned
? { r: 1, g: 1, b: 1 }
: { r: 0, g: 0, b: 0 };
}

device.colorManager?.setChannelColorRgb(context, channelIndex, color);
Expand Down

0 comments on commit d8d5eec

Please sign in to comment.