Added bare minimum functional
This commit is contained in:
parent
873a84b47a
commit
25af899ca7
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -54,3 +54,5 @@ pids
|
|||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
|
||||
config.js
|
5
config.example.js
Normal file
5
config.example.js
Normal file
|
@ -0,0 +1,5 @@
|
|||
const config = {
|
||||
dllPath: 'C:\\Program Files (x86)\\VB\\Voicemeeter\\VoicemeeterRemote64.dll',
|
||||
headerPath: 'C:\\Program Files (x86)\\VB\\Voicemeeter\\VoicemeeterRemote.h',
|
||||
};
|
||||
module.exports = config;
|
22
package-lock.json
generated
22
package-lock.json
generated
|
@ -1,11 +1,11 @@
|
|||
{
|
||||
"name": "backend",
|
||||
"name": "voicemeeter-remote-backend",
|
||||
"version": "0.0.1",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "backend",
|
||||
"name": "voicemeeter-remote-backend",
|
||||
"version": "0.0.1",
|
||||
"license": "UNLICENSED",
|
||||
"dependencies": {
|
||||
|
@ -13,7 +13,8 @@
|
|||
"@nestjs/core": "^10.0.0",
|
||||
"@nestjs/platform-express": "^10.0.0",
|
||||
"reflect-metadata": "^0.2.0",
|
||||
"rxjs": "^7.8.1"
|
||||
"rxjs": "^7.8.1",
|
||||
"voicemeeter-remote-library": "file:../library"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nestjs/cli": "^10.0.0",
|
||||
|
@ -39,6 +40,17 @@
|
|||
"typescript": "^5.1.3"
|
||||
}
|
||||
},
|
||||
"../library": {
|
||||
"version": "1.0.0",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"koffi": "^2.8.11"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ts-node": "^10.9.2",
|
||||
"typescript": "^5.5.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@ampproject/remapping": {
|
||||
"version": "2.3.0",
|
||||
"resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.3.0.tgz",
|
||||
|
@ -8258,6 +8270,10 @@
|
|||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/voicemeeter-remote-library": {
|
||||
"resolved": "../library",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/walker": {
|
||||
"version": "1.0.8",
|
||||
"resolved": "https://registry.npmjs.org/walker/-/walker-1.0.8.tgz",
|
||||
|
|
|
@ -24,7 +24,8 @@
|
|||
"@nestjs/core": "^10.0.0",
|
||||
"@nestjs/platform-express": "^10.0.0",
|
||||
"reflect-metadata": "^0.2.0",
|
||||
"rxjs": "^7.8.1"
|
||||
"rxjs": "^7.8.1",
|
||||
"voicemeeter-remote-library": "file:../library"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nestjs/cli": "^10.0.0",
|
||||
|
|
|
@ -1,12 +1,23 @@
|
|||
import { Controller, Get } from '@nestjs/common';
|
||||
import { AppService } from './app.service';
|
||||
import {
|
||||
Controller,
|
||||
Get,
|
||||
Header,
|
||||
HttpException,
|
||||
HttpStatus,
|
||||
Query,
|
||||
} from '@nestjs/common';
|
||||
import { AppService, IOType } from './app.service';
|
||||
|
||||
@Controller()
|
||||
export class AppController {
|
||||
constructor(private readonly appService: AppService) {}
|
||||
|
||||
@Get()
|
||||
getHello(): string {
|
||||
return this.appService.getHello();
|
||||
@Get('/type')
|
||||
getType() {
|
||||
return this.appService.getType();
|
||||
}
|
||||
@Get('/io')
|
||||
getIO() {
|
||||
return this.appService.getAvailableIOs();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
import { Module } from '@nestjs/common';
|
||||
import { AppController } from './app.controller';
|
||||
import { AppService } from './app.service';
|
||||
import { StripController } from './strip.controller';
|
||||
|
||||
@Module({
|
||||
imports: [],
|
||||
controllers: [AppController],
|
||||
controllers: [AppController, StripController],
|
||||
providers: [AppService],
|
||||
})
|
||||
export class AppModule {}
|
||||
|
|
|
@ -1,8 +1,50 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import {
|
||||
BeforeApplicationShutdown,
|
||||
Injectable,
|
||||
OnApplicationShutdown,
|
||||
OnModuleInit,
|
||||
Query,
|
||||
} from '@nestjs/common';
|
||||
import * as config from '../config.js';
|
||||
import { Control, Strip } from 'voicemeeter-remote-library/dist';
|
||||
import { VoicemeeterType } from 'voicemeeter-remote-library/dist/VMR/Control';
|
||||
|
||||
export enum IOType {
|
||||
STRIP,
|
||||
BUS,
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class AppService {
|
||||
getHello(): string {
|
||||
return 'Hello World!';
|
||||
export class AppService implements OnModuleInit {
|
||||
private control = new Control(config.dllPath, config.headerPath);
|
||||
private strips: Strip[];
|
||||
// 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),
|
||||
);
|
||||
}
|
||||
|
||||
getType() {
|
||||
return {
|
||||
typeId: this.control.voicemeeterType,
|
||||
type: VoicemeeterType[this.control.voicemeeterType],
|
||||
};
|
||||
}
|
||||
getAvailableIOs() {
|
||||
return {
|
||||
buses: this.control.availableBuses,
|
||||
strips: this.control.availableStrips,
|
||||
};
|
||||
}
|
||||
|
||||
getGain(IOType: IOType, id: number) {
|
||||
return this.strips[id].Gain;
|
||||
}
|
||||
|
||||
setGain(IOType: IOType, id: number, gain: number) {
|
||||
return (this.strips[id].Gain = gain);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ import { AppModule } from './app.module';
|
|||
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.create(AppModule);
|
||||
app.enableShutdownHooks();
|
||||
await app.listen(3000);
|
||||
}
|
||||
bootstrap();
|
||||
|
|
40
src/strip.controller.ts
Normal file
40
src/strip.controller.ts
Normal file
|
@ -0,0 +1,40 @@
|
|||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Get,
|
||||
Header,
|
||||
HostParam,
|
||||
HttpException,
|
||||
HttpStatus,
|
||||
Param,
|
||||
Patch,
|
||||
Post,
|
||||
Query,
|
||||
} from '@nestjs/common';
|
||||
import { AppService, IOType } from './app.service';
|
||||
|
||||
@Controller('/strip/:stripId')
|
||||
export class StripController {
|
||||
constructor(private readonly appService: AppService) {}
|
||||
@Get('/gain')
|
||||
getGain(@Param('stripId') stripId: string) {
|
||||
return { gain: this.appService.getGain(IOType.STRIP, +stripId) };
|
||||
}
|
||||
@Patch('/gain')
|
||||
setGain(
|
||||
@Param('stripId') stripId: string,
|
||||
@Body() { gain }: { gain: number },
|
||||
) {
|
||||
if (gain === undefined)
|
||||
throw new HttpException(
|
||||
'Gain parameter not specified',
|
||||
HttpStatus.BAD_REQUEST,
|
||||
);
|
||||
if (typeof gain !== 'number' || isNaN(gain))
|
||||
throw new HttpException(
|
||||
'Invalid gain parameter type. Must be a number',
|
||||
HttpStatus.BAD_REQUEST,
|
||||
);
|
||||
return { gain: this.appService.setGain(IOType.STRIP, +stripId, gain) };
|
||||
}
|
||||
}
|
1
tsconfig.build.tsbuildinfo
Normal file
1
tsconfig.build.tsbuildinfo
Normal file
File diff suppressed because one or more lines are too long
|
@ -1,5 +1,7 @@
|
|||
{
|
||||
"watchOptions": {"excludeDirectories": ["../library/logs"]},
|
||||
"compilerOptions": {
|
||||
// "strict": true,
|
||||
"module": "commonjs",
|
||||
"declaration": true,
|
||||
"removeComments": true,
|
||||
|
@ -9,6 +11,7 @@
|
|||
"target": "ES2021",
|
||||
"sourceMap": true,
|
||||
"outDir": "./dist",
|
||||
"allowJs": true,
|
||||
"baseUrl": "./",
|
||||
"incremental": true,
|
||||
"skipLibCheck": true,
|
||||
|
|
Loading…
Reference in New Issue
Block a user