125 lines
3.5 KiB
TypeScript
125 lines
3.5 KiB
TypeScript
|
import { VMObject } from "./VMObject";
|
||
|
import { minType } from "./decorators/minVersion";
|
||
|
import { validation } from "./decorators/validation";
|
||
|
import { Control } from "./Control";
|
||
|
|
||
|
export type OutputBuses = Record<"A" | "B", Record<number, boolean>>;
|
||
|
|
||
|
export class Strip extends VMObject {
|
||
|
@validation()
|
||
|
public get Mono(): boolean {
|
||
|
return this.getParamValueBoolean(
|
||
|
this.buildParameterString("Mono")
|
||
|
)[1];
|
||
|
}
|
||
|
public set Mono(v: boolean) {
|
||
|
this.setParamValueBoolean(this.buildParameterString("Mono"), v);
|
||
|
}
|
||
|
|
||
|
@validation()
|
||
|
public get Mute(): boolean {
|
||
|
return this.getParamValueBoolean(
|
||
|
this.buildParameterString("Mute")
|
||
|
)[1];
|
||
|
}
|
||
|
public set Mute(v: boolean) {
|
||
|
this.setParamValueBoolean(this.buildParameterString("Mute"), v);
|
||
|
}
|
||
|
|
||
|
@validation()
|
||
|
public get Solo(): boolean {
|
||
|
return this.getParamValueBoolean(
|
||
|
this.buildParameterString("Solo")
|
||
|
)[1];
|
||
|
}
|
||
|
public set Solor(v: boolean) {
|
||
|
this.setParamValueBoolean(this.buildParameterString("Solo"), v);
|
||
|
}
|
||
|
|
||
|
@validation()
|
||
|
public get MuteCenter(): boolean {
|
||
|
return this.getParamValueBoolean(this.buildParameterString("MC"))[1];
|
||
|
}
|
||
|
public set MuteCenter(v: boolean) {
|
||
|
this.setParamValueBoolean(this.buildParameterString("MC"), v);
|
||
|
}
|
||
|
|
||
|
@validation()
|
||
|
public get Gain(): number {
|
||
|
return this.getParamValueNumber(this.buildParameterString("Gain"))[1];
|
||
|
}
|
||
|
public set Gain(v: number) {
|
||
|
this.setParamValueNumber(this.buildParameterString("Gain"), v);
|
||
|
}
|
||
|
|
||
|
@minType(3)
|
||
|
public get GainLayers(): number[] {
|
||
|
const buses: number[] = [];
|
||
|
for (let i = 0; i < this.control.availableBuses.total; i++) {
|
||
|
buses.push(
|
||
|
this.getParamValueNumber(
|
||
|
this.buildParameterString("GainLayer", i)
|
||
|
)[1]
|
||
|
);
|
||
|
}
|
||
|
return buses;
|
||
|
}
|
||
|
public set GainLayers(changedBuses: (undefined | number)[]) {
|
||
|
let script = "";
|
||
|
for (let i = 0; i < changedBuses.length; i++) {
|
||
|
const gainForBus = changedBuses[i];
|
||
|
script += `${this.buildParameterString(
|
||
|
"GainLayer", i,
|
||
|
)} = ${gainForBus};`;
|
||
|
}
|
||
|
this.setParameters(script);
|
||
|
}
|
||
|
|
||
|
@validation()
|
||
|
public get outputBuses() {
|
||
|
const buses: OutputBuses = { A: {}, B: {} };
|
||
|
for (let i = 0; i < this.control.availableBuses.physical; i++) {
|
||
|
buses["A"][i + 1] = this.getParamValueBoolean(
|
||
|
this.buildParameterString(`A${i + 1}`)
|
||
|
)[1];
|
||
|
}
|
||
|
for (let i = 0; i < this.control.availableBuses.virtual; i++) {
|
||
|
buses["B"][i + 1] = this.getParamValueBoolean(
|
||
|
this.buildParameterString(`B${i + 1}`)
|
||
|
)[1];
|
||
|
}
|
||
|
return buses;
|
||
|
}
|
||
|
public set outputBuses(changedBuses: Partial<OutputBuses>) {
|
||
|
let script = "";
|
||
|
if (changedBuses.A !== undefined)
|
||
|
for (const busId in changedBuses.A) {
|
||
|
if (Object.prototype.hasOwnProperty.call(changedBuses.A, busId)) {
|
||
|
const element = changedBuses.A[busId];
|
||
|
script += `${this.buildParameterString(`A${busId}`)} = ${
|
||
|
element ? "1" : "0"
|
||
|
};`;
|
||
|
}
|
||
|
}
|
||
|
if (changedBuses.B !== undefined)
|
||
|
for (const busId in changedBuses.B) {
|
||
|
if (Object.prototype.hasOwnProperty.call(changedBuses.B, busId)) {
|
||
|
const outputToBus = changedBuses.B[busId];
|
||
|
script += `${this.buildParameterString(`B${busId}`)} = ${
|
||
|
outputToBus ? "1" : "0"
|
||
|
};`;
|
||
|
}
|
||
|
}
|
||
|
this.setParameters(script);
|
||
|
}
|
||
|
|
||
|
constructor(control: Control, public id: number) {
|
||
|
// control.validation();
|
||
|
super(control, "Strip", id);
|
||
|
}
|
||
|
|
||
|
initialize(): void {
|
||
|
console.log("Nothing to initialize");
|
||
|
}
|
||
|
}
|