modified: src/app.module.ts
modified: src/app.service.ts modified: src/bus/bus.controller.ts modified: src/main.ts
This commit is contained in:
parent
01a13e099e
commit
f5a8f0ee87
|
@ -2,11 +2,11 @@ import { Module } from '@nestjs/common';
|
|||
import { AppController } from './app.controller';
|
||||
import { AppService } from './app.service';
|
||||
import { StripController } from './strip/strip.controller';
|
||||
import { Bus } from './bus/bus.controller';
|
||||
import { BusController } from './bus/bus.controller';
|
||||
|
||||
@Module({
|
||||
imports: [],
|
||||
controllers: [AppController, StripController],
|
||||
providers: [AppService, Bus],
|
||||
controllers: [AppController, StripController, BusController],
|
||||
providers: [AppService],
|
||||
})
|
||||
export class AppModule {}
|
||||
|
|
|
@ -6,7 +6,7 @@ import {
|
|||
Query,
|
||||
} from '@nestjs/common';
|
||||
import * as config from '../config.js';
|
||||
import { Control, Strip } from 'voicemeeter-remote-library/dist';
|
||||
import { Bus, Control, Strip } from 'voicemeeter-remote-library/dist';
|
||||
import { VoicemeeterType } from 'voicemeeter-remote-library/dist/VMR/Control';
|
||||
|
||||
export enum IOType {
|
||||
|
@ -18,13 +18,16 @@ export enum IOType {
|
|||
export class AppService implements OnModuleInit {
|
||||
private control = new Control(config.dllPath, config.headerPath);
|
||||
private strips: Strip[];
|
||||
// private buses: Bus[];
|
||||
private buses: Bus[];
|
||||
async onModuleInit() {
|
||||
await this.control.initialize();
|
||||
this.control.login();
|
||||
this.strips = [...Array(this.getAvailableIOs().strips.total).keys()].map(
|
||||
(id) => new Strip(this.control, id),
|
||||
);
|
||||
this.buses = [...Array(this.getAvailableIOs().buses.total).keys()].map(
|
||||
(id) => new Bus(this.control, id),
|
||||
);
|
||||
}
|
||||
|
||||
getType() {
|
||||
|
@ -40,19 +43,35 @@ export class AppService implements OnModuleInit {
|
|||
};
|
||||
}
|
||||
|
||||
getGain(IOType: IOType, id: number) {
|
||||
return this.strips[id].Gain;
|
||||
getGain(ioType: IOType, id: number) {
|
||||
if (ioType === IOType.BUS) {
|
||||
return this.buses[id].Gain;
|
||||
} else if (ioType === IOType.STRIP) {
|
||||
return this.strips[id].Gain;
|
||||
}
|
||||
}
|
||||
|
||||
setGain(IOType: IOType, id: number, gain: number) {
|
||||
return (this.strips[id].Gain = gain);
|
||||
setGain(ioType: IOType, id: number, gain: number) {
|
||||
if (ioType === IOType.BUS) {
|
||||
return (this.buses[id].Gain = gain);
|
||||
} else if (ioType === IOType.STRIP) {
|
||||
return (this.strips[id].Gain = gain);
|
||||
}
|
||||
}
|
||||
|
||||
getMuteState(IOType: IOType, id: number) {
|
||||
return this.strips[id].Mute;
|
||||
getMuteState(ioType: IOType, id: number) {
|
||||
if (ioType === IOType.BUS) {
|
||||
return this.buses[id].Mute;
|
||||
} else if (ioType === IOType.STRIP) {
|
||||
return this.strips[id].Mute;
|
||||
}
|
||||
}
|
||||
|
||||
setMuteState(IOType: IOType, id: number, state: boolean) {
|
||||
return (this.strips[id].Mute = state);
|
||||
setMuteState(ioType: IOType, id: number, state: boolean) {
|
||||
if (ioType === IOType.BUS) {
|
||||
return (this.buses[id].Mute = state);
|
||||
} else if (ioType === IOType.STRIP) {
|
||||
return (this.strips[id].Mute = state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import {
|
|||
import { AppService, IOType } from 'src/app.service';
|
||||
|
||||
@Controller('/bus/:busId')
|
||||
export class Bus {
|
||||
export class BusController {
|
||||
constructor(private readonly appService: AppService) {}
|
||||
|
||||
@Get('/gain')
|
||||
|
|
|
@ -4,6 +4,7 @@ import { AppModule } from './app.module';
|
|||
async function bootstrap() {
|
||||
const app = await NestFactory.create(AppModule);
|
||||
app.enableShutdownHooks();
|
||||
await app.listen(3000);
|
||||
app.enableCors({origin: "*"})
|
||||
await app.listen(3001);
|
||||
}
|
||||
bootstrap();
|
||||
|
|
Loading…
Reference in New Issue
Block a user