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