modified: src/app.controller.ts
modified: src/app.service.ts modified: src/strip/strip.controller.ts
This commit is contained in:
parent
f5a8f0ee87
commit
b8c778dcc7
|
@ -20,4 +20,8 @@ export class AppController {
|
|||
getIO() {
|
||||
return this.appService.getAvailableIOs();
|
||||
}
|
||||
@Get('/values')
|
||||
getValues() {
|
||||
return this.appService.getValues();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import {
|
|||
import * as config from '../config.js';
|
||||
import { Bus, Control, Strip } from 'voicemeeter-remote-library/dist';
|
||||
import { VoicemeeterType } from 'voicemeeter-remote-library/dist/VMR/Control';
|
||||
import { OutputBuses } from 'voicemeeter-remote-library/dist/VMR/Strip.js';
|
||||
|
||||
export enum IOType {
|
||||
STRIP,
|
||||
|
@ -43,6 +44,20 @@ export class AppService implements OnModuleInit {
|
|||
};
|
||||
}
|
||||
|
||||
getValues() {
|
||||
return {
|
||||
strips: this.strips.map((v) => ({
|
||||
gain: v.Gain,
|
||||
muteState: v.Mute,
|
||||
outputBuses: [
|
||||
...Object.values(v.outputBuses.A),
|
||||
...Object.values(v.outputBuses.B),
|
||||
],
|
||||
})),
|
||||
buses: this.buses.map((v) => ({ gain: v.Gain, muteState: v.Mute })),
|
||||
};
|
||||
}
|
||||
|
||||
getGain(ioType: IOType, id: number) {
|
||||
if (ioType === IOType.BUS) {
|
||||
return this.buses[id].Gain;
|
||||
|
@ -74,4 +89,24 @@ export class AppService implements OnModuleInit {
|
|||
return (this.strips[id].Mute = state);
|
||||
}
|
||||
}
|
||||
|
||||
getStripOutputBuses(stripId: number) {
|
||||
return this.strips[stripId].outputBuses;
|
||||
}
|
||||
|
||||
setStripOutputBuses(stripId: number, outputs: boolean[]) {
|
||||
const buses = {
|
||||
A: Object.fromEntries(
|
||||
outputs
|
||||
.slice(0, this.control.availableBuses.physical)
|
||||
.map((e, i) => [i + 1, e]),
|
||||
),
|
||||
B: Object.fromEntries(
|
||||
outputs
|
||||
.slice(this.control.availableBuses.virtual * -1)
|
||||
.map((e, i) => [i + 1, e]),
|
||||
),
|
||||
} as OutputBuses;
|
||||
return (this.strips[stripId].outputBuses = buses);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,4 +66,31 @@ export class StripController {
|
|||
),
|
||||
};
|
||||
}
|
||||
|
||||
@Get('/outputs')
|
||||
getOutputs(@Param('stripId') stripId: string) {
|
||||
return this.appService.getStripOutputBuses(+stripId);
|
||||
}
|
||||
@Patch('/outputs')
|
||||
setOutputs(
|
||||
@Param('stripId') stripId: string,
|
||||
@Body() { outputs }: { outputs: boolean[] },
|
||||
) {
|
||||
if (outputs === undefined)
|
||||
throw new HttpException(
|
||||
'"outputs" parameter not specified',
|
||||
HttpStatus.BAD_REQUEST,
|
||||
);
|
||||
const busesAmount = this.appService.getAvailableIOs().buses.total;
|
||||
if (
|
||||
!Array.isArray(outputs) ||
|
||||
outputs.some((e) => typeof e !== 'boolean') ||
|
||||
outputs.length < busesAmount
|
||||
)
|
||||
throw new HttpException(
|
||||
`Invalid "outputs" parameter. Must be array with ${busesAmount} boolean(s)`,
|
||||
HttpStatus.BAD_REQUEST,
|
||||
);
|
||||
return this.appService.setStripOutputBuses(+stripId, outputs);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user