Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,5 @@ dmypy.json
.Trashes
ehthumbs.db
Thumbs.db

node_modules/
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@
<!-- 8 Channel Strips -->
<PlacementBank target="RemoteBank" pagesize="8" name="ChannelBankElement">
<foreach variable="$ch" count="8">
<Strip onConnect="onConnectChannel($ch)">
<Strip>
<Value control="fader[$ch]" param="volume"/>
<Toggle control="solo[$ch]" param="solo" options="momentary"/>
<Value control="encoder[$ch]" param="pan"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,78 @@
// @ts-check

// @ts-ignore
include_file("resource://com.presonus.musicdevices/sdk/controlsurfacecomponent.js");
// @ts-ignore
include_file("resource://com.presonus.musicdevices/sdk/musicprotocol.js");
// @ts-ignore
include_file("LaunchkeyProtocol.js");

var PadSectionMode;
(function (PadSectionMode) {
PadSectionMode[PadSectionMode["kNone"] = 0] = "kNone";
PadSectionMode[PadSectionMode["kLauncher"] = 1] = "kLauncher";
PadSectionMode[PadSectionMode["kModeMin"] = 0] = "kModeMin";
PadSectionMode[PadSectionMode["kModeMax"] = 1] = "kModeMax";
})(PadSectionMode || (PadSectionMode = {}));

class LaunchkeyComponent extends PreSonus.ControlSurfaceComponent {
const PadSectionMode = {};
PadSectionMode[PadSectionMode.kNone = 0] = "kNone";
PadSectionMode[PadSectionMode.kLauncher = 1] = "kLauncher";
PadSectionMode[PadSectionMode["kModeMin"] = 0] = "kModeMin";
PadSectionMode[PadSectionMode.kModeMax = 1] = "kModeMax";


/**
* @type {typeof import("presonus_studioone_5_sdk/src/controlsurfacecomponent.ts").PreSonus["ControlSurfaceComponent"]}
*/
// @ts-ignore
const ControlSurfaceComponent = PreSonus.ControlSurfaceComponent;
/**
* @type {typeof import("presonus_studioone_5_sdk/src/controlsurfacecomponent.ts").PreSonus["PadSectionRole"] & { kLauncherInput: string }}
*/
// @ts-ignore
const PadSectionRole = PreSonus.PadSectionRole;
/**
* @type { { kCombined: number }}
*/
// @ts-ignore
const PadSectionLauncherMode = PreSonus.PadSectionLauncherMode;

/**
* @typedef {{
* classID: string;
* model: {
* root: {
* findColorTable: (arg0: string) => {addColor: (arg0: any) => void; };
* find: (arg0: string) => {component: Component; };
* };
* };
* paramList: {
* addInteger: (arg0: number, arg1: number, arg2: string) => {value: number; setValue: (value: number, flags: boolean) => void; };
* addColor: (arg0: string) => {value: string; fromString: (arg0: string) => void; };
* };
* }} HostComponent
*/

/**
* @typedef {{
* addNullHandler: () => void;
* addHandlerForRole: (role: string) => void;
* setActiveHandler: (mode: number) => void;
* getHandler: (mode: number) => {setMappingMode: (mappingMode: number) => void; };
* }} Component
*/

class LaunchkeyComponent extends ControlSurfaceComponent {
/**
* @param {HostComponent} hostComponent
*/
onInit(hostComponent) {
super.onInit(hostComponent);
this.debugLog = false;
this.model = hostComponent.model;

let root = this.model.root;
let colorMapper = root.findColorTable("DAWModeColors");
const root = this.model.root;
const colorMapper = root.findColorTable("DAWModeColors");
if (colorMapper) {
LaunchkeyProtocol.kPadColors.forEach((tableColor) => {
colorMapper.addColor(tableColor);
});
}

let paramList = hostComponent.paramList;
const paramList = hostComponent.paramList;
this.padSectionMode = paramList.addInteger(PadSectionMode.kModeMin, PadSectionMode.kModeMax, "padSectionMode");

// Launchkey-specific color parameters
Expand All @@ -44,12 +92,12 @@ class LaunchkeyComponent extends PreSonus.ControlSurfaceComponent {
this.magentaColorParam.fromString("#FF00FF");

this.padSection = root.find("PadSectionElement");
let c = this.padSection.component;
const c = this.padSection.component;
c.addNullHandler();
c.addHandlerForRole(PreSonus.PadSectionRole.kLauncherInput);
c.addHandlerForRole(PadSectionRole.kLauncherInput);

let launcherInputHandler = this.padSection.component.getHandler(PadSectionMode.kLauncher);
launcherInputHandler.setMappingMode(PreSonus.PadSectionLauncherMode.kCombined);
const launcherInputHandler = this.padSection.component.getHandler(PadSectionMode.kLauncher);
launcherInputHandler.setMappingMode(PadSectionLauncherMode.kCombined);
this.launcherHandler = launcherInputHandler;

this.updatePadSectionMode(PadSectionMode.kNone);
Expand All @@ -68,12 +116,20 @@ class LaunchkeyComponent extends PreSonus.ControlSurfaceComponent {
super.onExit();
}

/**
* @param {boolean} state
*/
onSuspend(state) {
if (state && this.padSectionMode.value == PadSectionMode.kLauncher)
if (state && this.padSectionMode && this.padSectionMode.value == PadSectionMode.kLauncher)
this.padSectionMode.setValue(PadSectionMode.kNone, true);
}
/**
* @param {number} mode
*/
updatePadSectionMode(mode) {
this.padSection.component.setActiveHandler(mode);
if (this.padSection) {
this.padSection.component.setActiveHandler(mode);
}
}
}

Expand All @@ -86,7 +142,7 @@ class LaunchkeyMK1Component extends LaunchkeyComponent {
super.onInit(hostComponent);

// Launchkey MK1 specific initialization
let paramList = hostComponent.paramList;
const paramList = hostComponent.paramList;
this.inControlMode = paramList.addParam("inControlMode");
this.inControlMode.setSignalAlways(true);
}
Expand Down
Loading