mirror of
https://github.com/onyx-and-iris/vmr-http.git
synced 2026-04-06 09:59:11 +00:00
Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e849d7739b | |||
| 07bcdd17fb | |||
| 112679450f | |||
| a2acbe1ac2 | |||
| 921cf8796d | |||
| a492006d67 | |||
| 20756f489f | |||
| a19d1f1e1d | |||
| 3e65a2afea | |||
| b7b35c796a | |||
| 64a27913c2 |
175
API_EXAMPLES.md
Normal file
175
API_EXAMPLES.md
Normal file
@ -0,0 +1,175 @@
|
||||
# API Usage
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- The FastAPI server must be running (default: http://localhost:8000)
|
||||
|
||||
---
|
||||
|
||||
## App Router
|
||||
|
||||
### */health*
|
||||
|
||||
```console
|
||||
curl -X 'GET' \
|
||||
'http://127.0.0.1:8000/health' \
|
||||
-H 'accept: application/json'
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Strip Router
|
||||
|
||||
### */strip/{index}*
|
||||
|
||||
> Get single parameter
|
||||
|
||||
```console
|
||||
curl -X 'GET' \
|
||||
'http://127.0.0.1:8000/strip/0/gain' \
|
||||
-H 'accept: application/json'
|
||||
```
|
||||
|
||||
> Set single parameter
|
||||
|
||||
```console
|
||||
curl -X 'PATCH' \
|
||||
'http://127.0.0.1:8000/strip/0' \
|
||||
-H 'accept: application/json' \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{
|
||||
"mute": true,
|
||||
}'
|
||||
```
|
||||
|
||||
> Set multiple parameters
|
||||
|
||||
```console
|
||||
curl -X 'PATCH' \
|
||||
'http://127.0.0.1:8000/strip/0' \
|
||||
-H 'accept: application/json' \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{
|
||||
"gain": -36.8,
|
||||
"mute": true,
|
||||
"mono": false,
|
||||
"solo": true,
|
||||
"A1": true,
|
||||
"A2": false,
|
||||
"A3": true,
|
||||
"B1": false,
|
||||
"B2": true,
|
||||
}'
|
||||
```
|
||||
|
||||
## Strip Gate Router
|
||||
|
||||
### */strip/{index}/gate*
|
||||
|
||||
> Get single parameter
|
||||
|
||||
```console
|
||||
curl -X 'GET' \
|
||||
'http://127.0.0.1:8000/strip/0/gate/knob' \
|
||||
-H 'accept: application/json'
|
||||
```
|
||||
|
||||
> Set multiple parameters
|
||||
|
||||
```console
|
||||
curl -X 'PATCH' \
|
||||
'http://127.0.0.1:8000/strip/0/gate' \
|
||||
-H 'accept: application/json' \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{
|
||||
"threshold": -28.7,
|
||||
"damping": -60,
|
||||
"attack": 2
|
||||
}'
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Bus Router
|
||||
|
||||
### */bus/{index}*
|
||||
|
||||
> Get single parameter
|
||||
|
||||
```console
|
||||
curl -X 'GET' \
|
||||
'http://127.0.0.1:8000/bus/0/mono' \
|
||||
-H 'accept: application/json'
|
||||
```
|
||||
|
||||
> Set single parameter
|
||||
|
||||
```console
|
||||
curl -X 'PATCH' \
|
||||
'http://127.0.0.1:8000/bus/0' \
|
||||
-H 'accept: application/json' \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{
|
||||
"gain": -32.8,
|
||||
}'
|
||||
```
|
||||
|
||||
> Set multiple parameters
|
||||
|
||||
```console
|
||||
curl -X 'PATCH' \
|
||||
'http://127.0.0.1:8000/bus/0' \
|
||||
-H 'accept: application/json' \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{
|
||||
"gain": -18.7,
|
||||
"mute": false,
|
||||
"mono": 1
|
||||
}'
|
||||
```
|
||||
|
||||
## Bus EQ Channel Cell Router
|
||||
|
||||
### */bus/{index}/eq/channel/{channel_index}/cell/{cell_index}*
|
||||
|
||||
> Get single parameter
|
||||
|
||||
```console
|
||||
curl -X 'GET' \
|
||||
'http://127.0.0.1:8000/bus/0/eq/channel/0/cell/0/type' \
|
||||
-H 'accept: application/json'
|
||||
```
|
||||
|
||||
> Set single parameter
|
||||
|
||||
```console
|
||||
curl -X 'PATCH' \
|
||||
'http://127.0.0.1:8000/bus/0/eq/channel/0/cell/0' \
|
||||
-H 'accept: application/json' \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{
|
||||
"q": 9.5
|
||||
}'
|
||||
```
|
||||
|
||||
> Set multiple parameters
|
||||
|
||||
```console
|
||||
curl -X 'PATCH' \
|
||||
'http://127.0.0.1:8000/bus/0/eq/channel/0/cell/0' \
|
||||
-H 'accept: application/json' \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{
|
||||
"on": true,
|
||||
"type": 4,
|
||||
"f": 538.2,
|
||||
"gain": -0.6,
|
||||
"q": 9.5
|
||||
}'
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## More
|
||||
|
||||
For a full list of endpoints and schemas, see the [Swagger UI](http://localhost:8000/docs) or [ReDoc](http://localhost:8000/redoc).
|
||||
@ -19,7 +19,9 @@ uvicorn vmr_http:app
|
||||
|
||||
## Documentation
|
||||
|
||||
FastAPI generates [automatic docs][auto-docs], simply launch the server and then visit:
|
||||
For a few examples see [API_EXAMPLES](./API_EXAMPLES.md).
|
||||
|
||||
For an exhaustive list of the endpoints FastAPI generates [automatic docs][auto-docs], simply launch the server and then visit:
|
||||
|
||||
*Swagger UI*
|
||||
- http://localhost:8000/docs
|
||||
@ -31,6 +33,6 @@ FastAPI generates [automatic docs][auto-docs], simply launch the server and then
|
||||
|
||||
## License
|
||||
|
||||
`vban-cli` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.
|
||||
`vmr-http` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.
|
||||
|
||||
[auto-docs]: https://fastapi.tiangolo.com/features/#automatic-docs
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name = "vmr-http"
|
||||
version = "0.5.0"
|
||||
version = "0.7.1"
|
||||
description = "HTTP API for controlling Voicemeeter"
|
||||
readme = "README.md"
|
||||
authors = [{ name = "onyx-and-iris", email = "code@onyxandiris.online" }]
|
||||
|
||||
@ -2,12 +2,12 @@
|
||||
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import BaseModel
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
class BusParams(BaseModel):
|
||||
"""Parameters for a single bus."""
|
||||
|
||||
gain: Optional[float] = None
|
||||
mute: Optional[bool] = None
|
||||
mono: Optional[int] = None
|
||||
gain: Optional[float] = Field(None, ge=-60.0, le=12.0, description='Gain value for the bus')
|
||||
mute: Optional[bool] = Field(None, description='Mute status for the bus')
|
||||
mono: Optional[int] = Field(None, description='Mono status for the bus')
|
||||
|
||||
@ -2,21 +2,21 @@
|
||||
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import BaseModel
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
class EQParams(BaseModel):
|
||||
"""Parameters for an equalizer."""
|
||||
|
||||
on: Optional[bool] = None
|
||||
ab: Optional[bool] = None
|
||||
on: Optional[bool] = Field(None, description='Whether the equalizer is enabled or not.')
|
||||
ab: Optional[bool] = Field(None, description='Whether the equalizer is in mode A/B.')
|
||||
|
||||
|
||||
class EQChannelCellParams(BaseModel):
|
||||
"""Parameters for an equalizer channel."""
|
||||
|
||||
on: Optional[bool] = None
|
||||
type: Optional[int] = None
|
||||
f: Optional[float] = None
|
||||
gain: Optional[float] = None
|
||||
q: Optional[float] = None
|
||||
on: Optional[bool] = Field(None, description='Whether the equalizer channel is enabled or not.')
|
||||
type: Optional[int] = Field(None, ge=0, le=6, description='Type of the equalizer channel.')
|
||||
f: Optional[float] = Field(None, ge=20.0, le=20000.0, description='Frequency of the equalizer channel.')
|
||||
gain: Optional[float] = Field(None, ge=-36.0, le=18.0, description='Gain of the equalizer channel.')
|
||||
q: Optional[float] = Field(None, ge=0.3, le=100.0, description='Q factor of the equalizer channel.')
|
||||
|
||||
@ -2,53 +2,53 @@
|
||||
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import BaseModel
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
class StripParams(BaseModel):
|
||||
"""Parameters for a single strip."""
|
||||
|
||||
gain: Optional[float] = None
|
||||
mute: Optional[bool] = None
|
||||
mono: Optional[bool] = None
|
||||
solo: Optional[bool] = None
|
||||
A1: Optional[bool] = None
|
||||
A2: Optional[bool] = None
|
||||
A3: Optional[bool] = None
|
||||
A4: Optional[bool] = None
|
||||
A5: Optional[bool] = None
|
||||
B1: Optional[bool] = None
|
||||
B2: Optional[bool] = None
|
||||
B3: Optional[bool] = None
|
||||
gain: Optional[float] = Field(None, ge=-60.0, le=12.0, description='Gain value for the strip')
|
||||
mute: Optional[bool] = Field(None, description='Mute status for the strip')
|
||||
mono: Optional[bool] = Field(None, description='Mono status for the strip')
|
||||
solo: Optional[bool] = Field(None, description='Solo status for the strip')
|
||||
A1: Optional[bool] = Field(None, description='A1 output status for the strip')
|
||||
A2: Optional[bool] = Field(None, description='A2 output status for the strip')
|
||||
A3: Optional[bool] = Field(None, description='A3 output status for the strip')
|
||||
A4: Optional[bool] = Field(None, description='A4 output status for the strip')
|
||||
A5: Optional[bool] = Field(None, description='A5 output status for the strip')
|
||||
B1: Optional[bool] = Field(None, description='B1 output status for the strip')
|
||||
B2: Optional[bool] = Field(None, description='B2 output status for the strip')
|
||||
B3: Optional[bool] = Field(None, description='B3 output status for the strip')
|
||||
|
||||
|
||||
class StripCompParams(BaseModel):
|
||||
"""Parameters for the compressor of a strip."""
|
||||
|
||||
knob: Optional[float] = None
|
||||
gainin: Optional[float] = None
|
||||
ratio: Optional[float] = None
|
||||
threshold: Optional[float] = None
|
||||
attack: Optional[float] = None
|
||||
release: Optional[float] = None
|
||||
knee: Optional[float] = None
|
||||
gainout: Optional[float] = None
|
||||
makeup: Optional[bool] = None
|
||||
knob: Optional[float] = Field(None, ge=0.0, le=10.0, description='Compressor knob value for the strip')
|
||||
gainin: Optional[float] = Field(None, ge=-24.0, le=24.0, description='Compressor gain in value for the strip')
|
||||
ratio: Optional[float] = Field(None, ge=1.0, le=8.0, description='Compressor ratio value for the strip')
|
||||
threshold: Optional[float] = Field(None, ge=-40.0, le=-3.0, description='Compressor threshold value for the strip')
|
||||
attack: Optional[float] = Field(None, ge=0.0, le=200.0, description='Compressor attack value for the strip')
|
||||
release: Optional[float] = Field(None, ge=0.0, le=5000.0, description='Compressor release value for the strip')
|
||||
knee: Optional[float] = Field(None, ge=0.0, le=1.0, description='Compressor knee value for the strip')
|
||||
gainout: Optional[float] = Field(None, ge=-24.0, le=24.0, description='Compressor gain out value for the strip')
|
||||
makeup: Optional[bool] = Field(None, description='Compressor makeup status for the strip')
|
||||
|
||||
|
||||
class StripGateParams(BaseModel):
|
||||
"""Parameters for the gate of a strip."""
|
||||
|
||||
knob: Optional[float] = None
|
||||
threshold: Optional[float] = None
|
||||
damping: Optional[float] = None
|
||||
bpsidechain: Optional[float] = None
|
||||
attack: Optional[float] = None
|
||||
hold: Optional[float] = None
|
||||
release: Optional[float] = None
|
||||
knob: Optional[float] = Field(None, ge=0.0, le=10.0, description='Gate knob value for the strip')
|
||||
threshold: Optional[float] = Field(None, ge=-60.0, le=-10.0, description='Gate threshold value for the strip')
|
||||
damping: Optional[float] = Field(None, ge=-60.0, le=-10.0, description='Gate damping value for the strip')
|
||||
bpsidechain: Optional[float] = Field(None, ge=100.0, le=4000.0, description='Gate sidechain value for the strip')
|
||||
attack: Optional[float] = Field(None, ge=0.0, le=1000.0, description='Gate attack value for the strip')
|
||||
hold: Optional[float] = Field(None, ge=0.0, le=5000.0, description='Gate hold value for the strip')
|
||||
release: Optional[float] = Field(None, ge=0.0, le=5000.0, description='Gate release value for the strip')
|
||||
|
||||
|
||||
class StripDenoiserParams(BaseModel):
|
||||
"""Parameters for the denoiser of a strip."""
|
||||
|
||||
knob: Optional[float] = None
|
||||
knob: Optional[float] = Field(None, ge=0.0, le=10.0, description='Denoiser knob value for the strip')
|
||||
|
||||
@ -0,0 +1,5 @@
|
||||
"""API endpoints for controlling various Voicemeeter components."""
|
||||
|
||||
from . import bus, strip
|
||||
|
||||
__all__ = ['bus', 'strip']
|
||||
5
src/vmr_http/web/bus/__init__.py
Normal file
5
src/vmr_http/web/bus/__init__.py
Normal file
@ -0,0 +1,5 @@
|
||||
"""module for bus-related endpoints, including the bus equalizer."""
|
||||
|
||||
from .bus import router
|
||||
|
||||
__all__ = ['router']
|
||||
@ -4,12 +4,13 @@ from fastapi import APIRouter, Depends
|
||||
|
||||
from vmr_http.dependencies import get_voicemeeter_client
|
||||
from vmr_http.models.bus import BusParams
|
||||
from vmr_http.web import eq
|
||||
|
||||
from . import busmode, eq
|
||||
from . import mode
|
||||
|
||||
router = APIRouter()
|
||||
router.include_router(busmode.router, prefix='/mode', tags=['bus mode'])
|
||||
router.include_router(eq.create_router(parent_router_kind='bus'), prefix='/eq', tags=['bus eq'])
|
||||
router.include_router(mode.router, prefix='/mode', tags=['bus mode'])
|
||||
router.include_router(eq.create_router(eq_kind='bus'), prefix='/eq', tags=['bus eq'])
|
||||
|
||||
|
||||
@router.patch('', tags=['bus'])
|
||||
@ -1,18 +1,20 @@
|
||||
"""Module for equalizer related endpoints, supporting both strip and bus parents via a factory function."""
|
||||
|
||||
from typing import Literal
|
||||
|
||||
from fastapi import APIRouter, Depends
|
||||
|
||||
from vmr_http.dependencies import get_voicemeeter_client
|
||||
from vmr_http.models.eq import EQChannelCellParams, EQParams
|
||||
|
||||
|
||||
def create_router(parent_router_kind: str) -> APIRouter:
|
||||
"""Create an APIRouter for equalizer endpoints, with the specified parent kind ('strip' or 'bus')."""
|
||||
if parent_router_kind not in ('strip', 'bus'):
|
||||
raise ValueError(f'Invalid router kind: {parent_router_kind}')
|
||||
parent_attr = parent_router_kind
|
||||
def create_router(eq_kind: str) -> APIRouter:
|
||||
"""Create an APIRouter for equalizer endpoints, with the specified kind ('strip' or 'bus')."""
|
||||
if eq_kind not in ('strip', 'bus'):
|
||||
raise ValueError(f'Invalid router kind: {eq_kind}')
|
||||
parent_attr: Literal['strip', 'bus'] = eq_kind
|
||||
|
||||
def get_parent(voicemeeter, index):
|
||||
def target_cls(voicemeeter, index):
|
||||
return getattr(voicemeeter, parent_attr)[index]
|
||||
|
||||
cell_router = APIRouter()
|
||||
@ -27,7 +29,7 @@ def create_router(parent_router_kind: str) -> APIRouter:
|
||||
voicemeeter=Depends(get_voicemeeter_client),
|
||||
):
|
||||
"""Update one or more parameters for the specified eq channel cell."""
|
||||
cell = get_parent(voicemeeter, index).eq.channel[channel_index].cell[cell_index]
|
||||
cell = target_cls(voicemeeter, index).eq.channel[channel_index].cell[cell_index]
|
||||
updated = {}
|
||||
for key, value in params.model_dump(exclude_unset=True).items():
|
||||
setattr(cell, key, value)
|
||||
@ -39,35 +41,35 @@ def create_router(parent_router_kind: str) -> APIRouter:
|
||||
index: int, channel_index: int, cell_index: int, voicemeeter=Depends(get_voicemeeter_client)
|
||||
):
|
||||
"""Get the current on status for the specified eq channel cell."""
|
||||
return {'on': get_parent(voicemeeter, index).eq.channel[channel_index].cell[cell_index].on}
|
||||
return {'on': target_cls(voicemeeter, index).eq.channel[channel_index].cell[cell_index].on}
|
||||
|
||||
@cell_router.get('/type')
|
||||
async def get_eq_channel_cell_type(
|
||||
index: int, channel_index: int, cell_index: int, voicemeeter=Depends(get_voicemeeter_client)
|
||||
):
|
||||
"""Get the current type for the specified eq channel cell."""
|
||||
return {'type': get_parent(voicemeeter, index).eq.channel[channel_index].cell[cell_index].type}
|
||||
return {'type': target_cls(voicemeeter, index).eq.channel[channel_index].cell[cell_index].type}
|
||||
|
||||
@cell_router.get('/f')
|
||||
async def get_eq_channel_cell_f(
|
||||
index: int, channel_index: int, cell_index: int, voicemeeter=Depends(get_voicemeeter_client)
|
||||
):
|
||||
"""Get the current f value for the specified eq channel cell."""
|
||||
return {'f': get_parent(voicemeeter, index).eq.channel[channel_index].cell[cell_index].f}
|
||||
return {'f': target_cls(voicemeeter, index).eq.channel[channel_index].cell[cell_index].f}
|
||||
|
||||
@cell_router.get('/gain')
|
||||
async def get_eq_channel_cell_gain(
|
||||
index: int, channel_index: int, cell_index: int, voicemeeter=Depends(get_voicemeeter_client)
|
||||
):
|
||||
"""Get the current gain value for the specified eq channel cell."""
|
||||
return {'gain': get_parent(voicemeeter, index).eq.channel[channel_index].cell[cell_index].gain}
|
||||
return {'gain': target_cls(voicemeeter, index).eq.channel[channel_index].cell[cell_index].gain}
|
||||
|
||||
@cell_router.get('/q')
|
||||
async def get_eq_channel_cell_q(
|
||||
index: int, channel_index: int, cell_index: int, voicemeeter=Depends(get_voicemeeter_client)
|
||||
):
|
||||
"""Get the current q value for the specified eq channel cell."""
|
||||
return {'q': get_parent(voicemeeter, index).eq.channel[channel_index].cell[cell_index].q}
|
||||
return {'q': target_cls(voicemeeter, index).eq.channel[channel_index].cell[cell_index].q}
|
||||
|
||||
router = APIRouter()
|
||||
router.include_router(cell_router, prefix='/channel/{channel_index}/cell/{cell_index}')
|
||||
@ -76,7 +78,7 @@ def create_router(parent_router_kind: str) -> APIRouter:
|
||||
@router.put('')
|
||||
async def update_eq_params(index: int, params: EQParams, voicemeeter=Depends(get_voicemeeter_client)):
|
||||
"""Update one or more equalizer parameters for the specified index."""
|
||||
eq = get_parent(voicemeeter, index).eq
|
||||
eq = target_cls(voicemeeter, index).eq
|
||||
updated = {}
|
||||
for key, value in params.model_dump(exclude_unset=True).items():
|
||||
setattr(eq, key, value)
|
||||
@ -86,11 +88,11 @@ def create_router(parent_router_kind: str) -> APIRouter:
|
||||
@router.get('/on')
|
||||
async def get_eq_on(index: int, voicemeeter=Depends(get_voicemeeter_client)):
|
||||
"""Get the current equalizer on status for the specified index."""
|
||||
return {'on': get_parent(voicemeeter, index).eq.on}
|
||||
return {'on': target_cls(voicemeeter, index).eq.on}
|
||||
|
||||
@router.get('/ab')
|
||||
async def get_eq_ab(index: int, voicemeeter=Depends(get_voicemeeter_client)):
|
||||
"""Get the current equalizer A/B status for the specified index."""
|
||||
return {'ab': get_parent(voicemeeter, index).eq.ab}
|
||||
return {'ab': target_cls(voicemeeter, index).eq.ab}
|
||||
|
||||
return router
|
||||
|
||||
5
src/vmr_http/web/strip/__init__.py
Normal file
5
src/vmr_http/web/strip/__init__.py
Normal file
@ -0,0 +1,5 @@
|
||||
"""module for strip-related endpoints, including the strip equalizer."""
|
||||
|
||||
from .strip import router
|
||||
|
||||
__all__ = ['router']
|
||||
83
src/vmr_http/web/strip/comp.py
Normal file
83
src/vmr_http/web/strip/comp.py
Normal file
@ -0,0 +1,83 @@
|
||||
"""module for strip compressor related endpoints."""
|
||||
|
||||
from fastapi import APIRouter, Depends
|
||||
|
||||
from vmr_http.dependencies import get_voicemeeter_client
|
||||
from vmr_http.models.strip import StripCompParams
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.patch('')
|
||||
@router.put('')
|
||||
async def update_strip_comp_params(index: int, params: StripCompParams, voicemeeter=Depends(get_voicemeeter_client)):
|
||||
"""Update one or more compressor parameters for the specified strip index."""
|
||||
strip_comp = voicemeeter.strip[index].comp
|
||||
updated = {}
|
||||
for key, value in params.model_dump(exclude_unset=True).items():
|
||||
setattr(strip_comp, key, value)
|
||||
updated[key] = getattr(strip_comp, key)
|
||||
return updated
|
||||
|
||||
|
||||
@router.get('/knob')
|
||||
async def get_strip_comp_knob(index: int, voicemeeter=Depends(get_voicemeeter_client)):
|
||||
"""Get the current compressor knob value for the specified strip index."""
|
||||
strip_comp = voicemeeter.strip[index].comp
|
||||
return {'knob': strip_comp.knob}
|
||||
|
||||
|
||||
@router.get('/gainin')
|
||||
async def get_strip_comp_gainin(index: int, voicemeeter=Depends(get_voicemeeter_client)):
|
||||
"""Get the current compressor gain in value for the specified strip index."""
|
||||
strip_comp = voicemeeter.strip[index].comp
|
||||
return {'gainin': strip_comp.gainin}
|
||||
|
||||
|
||||
@router.get('/ratio')
|
||||
async def get_strip_comp_ratio(index: int, voicemeeter=Depends(get_voicemeeter_client)):
|
||||
"""Get the current compressor ratio value for the specified strip index."""
|
||||
strip_comp = voicemeeter.strip[index].comp
|
||||
return {'ratio': strip_comp.ratio}
|
||||
|
||||
|
||||
@router.get('/threshold')
|
||||
async def get_strip_comp_threshold(index: int, voicemeeter=Depends(get_voicemeeter_client)):
|
||||
"""Get the current compressor threshold value for the specified strip index."""
|
||||
strip_comp = voicemeeter.strip[index].comp
|
||||
return {'threshold': strip_comp.threshold}
|
||||
|
||||
|
||||
@router.get('/attack')
|
||||
async def get_strip_comp_attack(index: int, voicemeeter=Depends(get_voicemeeter_client)):
|
||||
"""Get the current compressor attack value for the specified strip index."""
|
||||
strip_comp = voicemeeter.strip[index].comp
|
||||
return {'attack': strip_comp.attack}
|
||||
|
||||
|
||||
@router.get('/release')
|
||||
async def get_strip_comp_release(index: int, voicemeeter=Depends(get_voicemeeter_client)):
|
||||
"""Get the current compressor release value for the specified strip index."""
|
||||
strip_comp = voicemeeter.strip[index].comp
|
||||
return {'release': strip_comp.release}
|
||||
|
||||
|
||||
@router.get('/knee')
|
||||
async def get_strip_comp_knee(index: int, voicemeeter=Depends(get_voicemeeter_client)):
|
||||
"""Get the current compressor knee value for the specified strip index."""
|
||||
strip_comp = voicemeeter.strip[index].comp
|
||||
return {'knee': strip_comp.knee}
|
||||
|
||||
|
||||
@router.get('/gainout')
|
||||
async def get_strip_comp_gainout(index: int, voicemeeter=Depends(get_voicemeeter_client)):
|
||||
"""Get the current compressor gain out value for the specified strip index."""
|
||||
strip_comp = voicemeeter.strip[index].comp
|
||||
return {'gainout': strip_comp.gainout}
|
||||
|
||||
|
||||
@router.get('/makeup')
|
||||
async def get_strip_comp_makeup(index: int, voicemeeter=Depends(get_voicemeeter_client)):
|
||||
"""Get the current compressor makeup status for the specified strip index."""
|
||||
strip_comp = voicemeeter.strip[index].comp
|
||||
return {'makeup': strip_comp.makeup}
|
||||
27
src/vmr_http/web/strip/gainlayer.py
Normal file
27
src/vmr_http/web/strip/gainlayer.py
Normal file
@ -0,0 +1,27 @@
|
||||
"""module for strip gain layer related endpoints."""
|
||||
|
||||
from fastapi import APIRouter, Body, Depends
|
||||
|
||||
from vmr_http.dependencies import get_voicemeeter_client
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.patch('')
|
||||
@router.put('')
|
||||
async def update_strip_comp_params(
|
||||
index: int,
|
||||
gainlayer_index: int,
|
||||
level: float = Body(..., ge=-60.0, le=12.0, embed=True),
|
||||
voicemeeter=Depends(get_voicemeeter_client),
|
||||
):
|
||||
"""Update one or more compressor parameters for the specified strip index."""
|
||||
gainlayer = voicemeeter.strip[index].gainlayer[gainlayer_index]
|
||||
gainlayer.gain = level
|
||||
return {'gain_layer': {'level': gainlayer.gain}}
|
||||
|
||||
|
||||
@router.get('/level')
|
||||
async def get_strip_gain_layer_level(index: int, gainlayer_index: int, voicemeeter=Depends(get_voicemeeter_client)):
|
||||
"""Get the current gain layer level for the specified strip index."""
|
||||
return {'gain_layer': {'level': voicemeeter.strip[index].gainlayer[gainlayer_index].gain}}
|
||||
69
src/vmr_http/web/strip/gate.py
Normal file
69
src/vmr_http/web/strip/gate.py
Normal file
@ -0,0 +1,69 @@
|
||||
"""module for strip gate related endpoints."""
|
||||
|
||||
from fastapi import APIRouter, Depends
|
||||
|
||||
from vmr_http.dependencies import get_voicemeeter_client
|
||||
from vmr_http.models.strip import StripGateParams
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.patch('')
|
||||
@router.put('')
|
||||
async def update_strip_gate_params(index: int, params: StripGateParams, voicemeeter=Depends(get_voicemeeter_client)):
|
||||
"""Update one or more gate parameters for the specified strip index."""
|
||||
strip_gate = voicemeeter.strip[index].gate
|
||||
updated = {}
|
||||
for key, value in params.model_dump(exclude_unset=True).items():
|
||||
setattr(strip_gate, key, value)
|
||||
updated[key] = getattr(strip_gate, key)
|
||||
return updated
|
||||
|
||||
|
||||
@router.get('/knob')
|
||||
async def get_strip_gate_knob(index: int, voicemeeter=Depends(get_voicemeeter_client)):
|
||||
"""Get the current gate knob value for the specified strip index."""
|
||||
strip_gate = voicemeeter.strip[index].gate
|
||||
return {'knob': strip_gate.knob}
|
||||
|
||||
|
||||
@router.get('/threshold')
|
||||
async def get_strip_gate_threshold(index: int, voicemeeter=Depends(get_voicemeeter_client)):
|
||||
"""Get the current gate threshold value for the specified strip index."""
|
||||
strip_gate = voicemeeter.strip[index].gate
|
||||
return {'threshold': strip_gate.threshold}
|
||||
|
||||
|
||||
@router.get('/damping')
|
||||
async def get_strip_gate_damping(index: int, voicemeeter=Depends(get_voicemeeter_client)):
|
||||
"""Get the current gate damping value for the specified strip index."""
|
||||
strip_gate = voicemeeter.strip[index].gate
|
||||
return {'damping': strip_gate.damping}
|
||||
|
||||
|
||||
@router.get('/bpsidechain')
|
||||
async def get_strip_gate_bpsidechain(index: int, voicemeeter=Depends(get_voicemeeter_client)):
|
||||
"""Get the current gate sidechain value for the specified strip index."""
|
||||
strip_gate = voicemeeter.strip[index].gate
|
||||
return {'bpsidechain': strip_gate.bpsidechain}
|
||||
|
||||
|
||||
@router.get('/attack')
|
||||
async def get_strip_gate_attack(index: int, voicemeeter=Depends(get_voicemeeter_client)):
|
||||
"""Get the current gate attack value for the specified strip index."""
|
||||
strip_gate = voicemeeter.strip[index].gate
|
||||
return {'attack': strip_gate.attack}
|
||||
|
||||
|
||||
@router.get('/hold')
|
||||
async def get_strip_gate_hold(index: int, voicemeeter=Depends(get_voicemeeter_client)):
|
||||
"""Get the current gate hold value for the specified strip index."""
|
||||
strip_gate = voicemeeter.strip[index].gate
|
||||
return {'hold': strip_gate.hold}
|
||||
|
||||
|
||||
@router.get('/release')
|
||||
async def get_strip_gate_release(index: int, voicemeeter=Depends(get_voicemeeter_client)):
|
||||
"""Get the current gate release value for the specified strip index."""
|
||||
strip_gate = voicemeeter.strip[index].gate
|
||||
return {'release': strip_gate.release}
|
||||
@ -4,14 +4,16 @@ from fastapi import APIRouter, Depends
|
||||
|
||||
from vmr_http.dependencies import get_voicemeeter_client
|
||||
from vmr_http.models.strip import StripParams
|
||||
from vmr_http.web import eq
|
||||
|
||||
from . import eq, stripcomp, stripdenoiser, stripgate
|
||||
from . import comp, denoiser, gainlayer, gate
|
||||
|
||||
router = APIRouter()
|
||||
router.include_router(stripcomp.router, prefix='/comp', tags=['strip comp'])
|
||||
router.include_router(stripgate.router, prefix='/gate', tags=['strip gate'])
|
||||
router.include_router(stripdenoiser.router, prefix='/denoiser', tags=['strip denoiser'])
|
||||
router.include_router(eq.create_router(parent_router_kind='strip'), prefix='/eq', tags=['strip eq'])
|
||||
router.include_router(gainlayer.router, prefix='/gainlayer/{gainlayer_index}', tags=['strip gainlayer'])
|
||||
router.include_router(comp.router, prefix='/comp', tags=['strip comp'])
|
||||
router.include_router(gate.router, prefix='/gate', tags=['strip gate'])
|
||||
router.include_router(denoiser.router, prefix='/denoiser', tags=['strip denoiser'])
|
||||
router.include_router(eq.create_router(eq_kind='strip'), prefix='/eq', tags=['strip eq'])
|
||||
|
||||
|
||||
@router.patch('', tags=['strip'])
|
||||
@ -1,27 +0,0 @@
|
||||
"""module for strip compressor related endpoints."""
|
||||
|
||||
from fastapi import APIRouter, Depends
|
||||
|
||||
from vmr_http.dependencies import get_voicemeeter_client
|
||||
from vmr_http.models.strip import StripCompParams
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.patch('')
|
||||
@router.put('')
|
||||
async def update_strip_comp_params(index: int, params: StripCompParams, voicemeeter=Depends(get_voicemeeter_client)):
|
||||
"""Update one or more compressor parameters for the specified strip index."""
|
||||
strip_comp = voicemeeter.strip[index].comp
|
||||
updated = {}
|
||||
for key, value in params.model_dump(exclude_unset=True).items():
|
||||
setattr(strip_comp, key, value)
|
||||
updated[key] = getattr(strip_comp, key)
|
||||
return updated
|
||||
|
||||
|
||||
@router.get('/knob')
|
||||
async def get_strip_comp_knob(index: int, voicemeeter=Depends(get_voicemeeter_client)):
|
||||
"""Get the current compressor knob value for the specified strip index."""
|
||||
strip_comp = voicemeeter.strip[index].comp
|
||||
return {'knob': strip_comp.knob}
|
||||
@ -1,27 +0,0 @@
|
||||
"""module for strip gate related endpoints."""
|
||||
|
||||
from fastapi import APIRouter, Depends
|
||||
|
||||
from vmr_http.dependencies import get_voicemeeter_client
|
||||
from vmr_http.models.strip import StripGateParams
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.patch('')
|
||||
@router.put('')
|
||||
async def update_strip_gate_params(index: int, params: StripGateParams, voicemeeter=Depends(get_voicemeeter_client)):
|
||||
"""Update one or more gate parameters for the specified strip index."""
|
||||
strip_gate = voicemeeter.strip[index].gate
|
||||
updated = {}
|
||||
for key, value in params.model_dump(exclude_unset=True).items():
|
||||
setattr(strip_gate, key, value)
|
||||
updated[key] = getattr(strip_gate, key)
|
||||
return updated
|
||||
|
||||
|
||||
@router.get('/knob')
|
||||
async def get_strip_gate_knob(index: int, voicemeeter=Depends(get_voicemeeter_client)):
|
||||
"""Get the current gate knob value for the specified strip index."""
|
||||
strip_gate = voicemeeter.strip[index].gate
|
||||
return {'knob': strip_gate.knob}
|
||||
Loading…
x
Reference in New Issue
Block a user