mirror of
https://github.com/onyx-and-iris/vmr-http.git
synced 2026-04-06 18:09:11 +00:00
Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0d6d91c20a | |||
| cbdfddba09 | |||
| 6476be53c5 | |||
| 9760bc8338 | |||
| 44c14dfeeb | |||
| 252de84f11 | |||
| a82cbd2bc6 | |||
| 6d01b8d2d3 | |||
| d20fb52d4b | |||
| 6ef9be7a61 | |||
| 16cfb420cf | |||
| 2ebf926b22 | |||
| cd80c7b763 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -88,7 +88,7 @@ ipython_config.py
|
||||
# pyenv
|
||||
# For a library or package, you might want to ignore these files since the code is
|
||||
# intended to run in multiple environments; otherwise, check them in:
|
||||
# .python-version
|
||||
.python-version
|
||||
|
||||
# pipenv
|
||||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
3.13
|
||||
65
README.md
65
README.md
@@ -14,60 +14,23 @@ pip install vmr-http
|
||||
## Run
|
||||
|
||||
```console
|
||||
uvicorn vmr_http.app:app
|
||||
```
|
||||
|
||||
## Use
|
||||
|
||||
*Set multiple Strip parameters at once*
|
||||
|
||||
```console
|
||||
curl -X 'PUT' \
|
||||
'http://127.0.0.1:8000/strip/0' \
|
||||
-H 'accept: application/json' \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{
|
||||
"gain": -38.7,
|
||||
"mute": true,
|
||||
"mono": true,
|
||||
"A1": true,
|
||||
"A2": false,
|
||||
"A5": true,
|
||||
"B1": true,
|
||||
"B3": true
|
||||
}'
|
||||
```
|
||||
|
||||
*Set Strip mute*
|
||||
|
||||
```console
|
||||
curl -X 'PUT' \
|
||||
'http://127.0.0.1:8000/strip/1/mute' \
|
||||
-H 'accept: application/json' \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{
|
||||
"mute": true
|
||||
}'
|
||||
```
|
||||
|
||||
*Get Bus gain*
|
||||
|
||||
```console
|
||||
curl -X 'GET' \
|
||||
'http://127.0.0.1:8000/bus/3/gain' \
|
||||
-H 'accept: application/json'
|
||||
```
|
||||
|
||||
*Get Bus Mode*
|
||||
|
||||
```console
|
||||
curl -X 'GET' \
|
||||
'http://127.0.0.1:8000/bus/mode/4/mode' \
|
||||
-H 'accept: application/json'
|
||||
uvicorn vmr_http:app
|
||||
```
|
||||
|
||||
## Documentation
|
||||
|
||||
FastAPI [generates automatic docs][auto-docs], visit the link in the startup message when you launch the server.
|
||||
FastAPI generates [automatic docs][auto-docs], simply launch the server and then visit:
|
||||
|
||||
*Swagger UI*
|
||||
- http://localhost:8000/docs
|
||||
|
||||
*ReDoc*
|
||||
- http://localhost:8000/redoc
|
||||
|
||||
---
|
||||
|
||||
## License
|
||||
|
||||
`vban-cli` 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,15 +1,11 @@
|
||||
[project]
|
||||
name = "vmr-http"
|
||||
version = "0.2.0"
|
||||
version = "0.5.0"
|
||||
description = "HTTP API for controlling Voicemeeter"
|
||||
readme = "README.md"
|
||||
authors = [{ name = "onyx-and-iris", email = "code@onyxandiris.online" }]
|
||||
requires-python = ">=3.10"
|
||||
dependencies = [
|
||||
"fastapi>=0.135.3",
|
||||
"uvicorn>=0.43.0",
|
||||
"voicemeeter-api>=2.7.2",
|
||||
]
|
||||
dependencies = ["fastapi>=0.135.3", "uvicorn>=0.43.0", "voicemeeter-api>=2.7.2"]
|
||||
classifiers = [
|
||||
"Development Status :: 4 - Beta",
|
||||
"Programming Language :: Python",
|
||||
@@ -26,14 +22,10 @@ requires = ["uv_build>=0.11.3,<0.12.0"]
|
||||
build-backend = "uv_build"
|
||||
|
||||
[dependency-groups]
|
||||
dev = [
|
||||
"fastapi[standard]>=0.135.3",
|
||||
"poethepoet>=0.43.0",
|
||||
"ruff>=0.15.9",
|
||||
]
|
||||
dev = ["fastapi[standard]>=0.135.3", "poethepoet>=0.43.0", "ruff>=0.15.9"]
|
||||
|
||||
[tool.fastapi]
|
||||
entrypoint = "vmr_http.app:app"
|
||||
entrypoint = "vmr_http:app"
|
||||
|
||||
[tool.uv.sources]
|
||||
voicemeeter-api = { path = "../voicemeeter-api-python", editable = true }
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
"""Voicemeeter HTTP API."""
|
||||
|
||||
from .app import app
|
||||
|
||||
__all__ = ['app']
|
||||
|
||||
@@ -27,15 +27,15 @@ app = FastAPI(
|
||||
{'name': 'bus', 'description': 'Endpoints for controlling bus parameters.'},
|
||||
],
|
||||
)
|
||||
app.include_router(strip.router, prefix='/strip')
|
||||
app.include_router(bus.router, prefix='/bus')
|
||||
app.include_router(strip.router, prefix='/strip/{index}')
|
||||
app.include_router(bus.router, prefix='/bus/{index}')
|
||||
|
||||
|
||||
@app.get('/health')
|
||||
def health_check(voicemeeter=Depends(get_voicemeeter_client)):
|
||||
"""Health check endpoint to verify the service is running."""
|
||||
try:
|
||||
version = voicemeeter.version # Check if we can communicate with Voicemeeter
|
||||
version = voicemeeter.version
|
||||
type_ = voicemeeter.type
|
||||
except CAPIError as e:
|
||||
raise HTTPException(status_code=503, detail=f'Voicemeeter API error: {str(e)}')
|
||||
|
||||
@@ -11,4 +11,3 @@ class BusParams(BaseModel):
|
||||
gain: Optional[float] = None
|
||||
mute: Optional[bool] = None
|
||||
mono: Optional[int] = None
|
||||
eq: Optional[bool] = None
|
||||
|
||||
22
src/vmr_http/models/eq.py
Normal file
22
src/vmr_http/models/eq.py
Normal file
@@ -0,0 +1,22 @@
|
||||
"""Models for the parameters of an equalizer."""
|
||||
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class EQParams(BaseModel):
|
||||
"""Parameters for an equalizer."""
|
||||
|
||||
on: Optional[bool] = None
|
||||
ab: Optional[bool] = None
|
||||
|
||||
|
||||
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
|
||||
@@ -1,55 +1,43 @@
|
||||
"""module for bus-related endpoints."""
|
||||
|
||||
from fastapi import APIRouter, Body, Depends
|
||||
from fastapi import APIRouter, Depends
|
||||
|
||||
from vmr_http.dependencies import get_voicemeeter_client
|
||||
from vmr_http.models.bus import BusParams
|
||||
|
||||
from . import busmode
|
||||
from . import busmode, eq
|
||||
|
||||
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.put('/{index}', tags=['bus'])
|
||||
async def set_bus_params(index: int, request: BusParams, voicemeeter=Depends(get_voicemeeter_client)):
|
||||
"""Set multiple parameters of a bus at once."""
|
||||
@router.patch('', tags=['bus'])
|
||||
@router.put('', tags=['bus'])
|
||||
async def update_bus_params(index: int, params: BusParams, voicemeeter=Depends(get_voicemeeter_client)):
|
||||
"""Update one or more parameters for the specified bus index."""
|
||||
bus = voicemeeter.bus[index]
|
||||
for key, value in request.model_dump(exclude_unset=True).items():
|
||||
updated = {}
|
||||
for key, value in params.model_dump(exclude_unset=True).items():
|
||||
setattr(bus, key, value)
|
||||
|
||||
return {key: getattr(bus, key) for key in request.model_dump(exclude_unset=True)}
|
||||
updated[key] = getattr(bus, key)
|
||||
return updated
|
||||
|
||||
|
||||
@router.get('/{index}/gain', tags=['bus'])
|
||||
@router.get('/gain', tags=['bus'])
|
||||
async def get_gain(index: int, voicemeeter=Depends(get_voicemeeter_client)):
|
||||
"""Get the current gain value for the specified bus index."""
|
||||
return {'gain': voicemeeter.bus[index].gain}
|
||||
|
||||
|
||||
@router.put('/{index}/gain', tags=['bus'])
|
||||
async def set_gain(
|
||||
index: int,
|
||||
gain: float = Body(..., embed=True),
|
||||
voicemeeter=Depends(get_voicemeeter_client),
|
||||
):
|
||||
"""Set the gain value for the specified bus index."""
|
||||
voicemeeter.bus[index].gain = gain
|
||||
return {'gain': voicemeeter.bus[index].gain}
|
||||
|
||||
|
||||
@router.get('/{index}/mute', tags=['bus'])
|
||||
@router.get('/mute', tags=['bus'])
|
||||
async def get_mute(index: int, voicemeeter=Depends(get_voicemeeter_client)):
|
||||
"""Get the current mute status for the specified bus index."""
|
||||
return {'mute': voicemeeter.bus[index].mute}
|
||||
|
||||
|
||||
@router.put('/{index}/mute', tags=['bus'])
|
||||
async def set_mute(
|
||||
index: int,
|
||||
mute: bool = Body(..., embed=True),
|
||||
voicemeeter=Depends(get_voicemeeter_client),
|
||||
):
|
||||
"""Set the mute status for the specified bus index."""
|
||||
voicemeeter.bus[index].mute = mute
|
||||
return {'mute': voicemeeter.bus[index].mute}
|
||||
@router.get('/mono', tags=['bus'])
|
||||
async def get_mono(index: int, voicemeeter=Depends(get_voicemeeter_client)):
|
||||
"""Get the current mono status for the specified bus index."""
|
||||
opts = ['Off', 'On', 'Stereo Reverse']
|
||||
return {'mono': opts[voicemeeter.bus[index].mono]}
|
||||
|
||||
@@ -23,23 +23,19 @@ _readable_busmodes = {
|
||||
_reversed_busmodes = {v: k for k, v in _readable_busmodes.items()}
|
||||
|
||||
|
||||
@router.get('/{index}')
|
||||
async def get_bus_mode(index: int, voicemeeter=Depends(get_voicemeeter_client)):
|
||||
"""Get the current bus mode for the specified bus index."""
|
||||
return {'mode': _readable_busmodes.get(voicemeeter.bus[index].mode.get(), 'Unknown')}
|
||||
|
||||
|
||||
@router.put('/{index}')
|
||||
async def set_bus_mode(
|
||||
index: int,
|
||||
mode: str = Body(..., embed=True),
|
||||
voicemeeter=Depends(get_voicemeeter_client),
|
||||
):
|
||||
"""Set the bus mode for the specified bus index."""
|
||||
@router.patch('')
|
||||
@router.put('')
|
||||
async def update_bus_mode(index: int, mode: str = Body(..., embed=True), voicemeeter=Depends(get_voicemeeter_client)):
|
||||
"""Update the bus mode for the specified bus index."""
|
||||
if mode not in _reversed_busmodes:
|
||||
raise HTTPException(
|
||||
status_code=400, detail=f'Invalid mode. Valid modes are: {", ".join(_reversed_busmodes.keys())}'
|
||||
)
|
||||
|
||||
setattr(voicemeeter.bus[index].mode, _reversed_busmodes[mode], True)
|
||||
return {'mode': _readable_busmodes[_reversed_busmodes[mode]]}
|
||||
|
||||
|
||||
@router.get('')
|
||||
async def get_bus_mode(index: int, voicemeeter=Depends(get_voicemeeter_client)):
|
||||
"""Get the current bus mode for the specified bus index."""
|
||||
return {'mode': _readable_busmodes.get(voicemeeter.bus[index].mode.get(), 'Unknown')}
|
||||
|
||||
96
src/vmr_http/web/eq.py
Normal file
96
src/vmr_http/web/eq.py
Normal file
@@ -0,0 +1,96 @@
|
||||
"""Module for equalizer related endpoints, supporting both strip and bus parents via a factory function."""
|
||||
|
||||
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 get_parent(voicemeeter, index):
|
||||
return getattr(voicemeeter, parent_attr)[index]
|
||||
|
||||
cell_router = APIRouter()
|
||||
|
||||
@cell_router.patch('')
|
||||
@cell_router.put('')
|
||||
async def update_eq_channel_cell_params(
|
||||
index: int,
|
||||
channel_index: int,
|
||||
cell_index: int,
|
||||
params: EQChannelCellParams,
|
||||
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]
|
||||
updated = {}
|
||||
for key, value in params.model_dump(exclude_unset=True).items():
|
||||
setattr(cell, key, value)
|
||||
updated[key] = getattr(cell, key)
|
||||
return updated
|
||||
|
||||
@cell_router.get('/on')
|
||||
async def get_eq_channel_cell_on(
|
||||
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}
|
||||
|
||||
@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}
|
||||
|
||||
@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}
|
||||
|
||||
@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}
|
||||
|
||||
@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}
|
||||
|
||||
router = APIRouter()
|
||||
router.include_router(cell_router, prefix='/channel/{channel_index}/cell/{cell_index}')
|
||||
|
||||
@router.patch('')
|
||||
@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
|
||||
updated = {}
|
||||
for key, value in params.model_dump(exclude_unset=True).items():
|
||||
setattr(eq, key, value)
|
||||
updated[key] = getattr(eq, key)
|
||||
return updated
|
||||
|
||||
@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}
|
||||
|
||||
@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 router
|
||||
@@ -1,227 +1,98 @@
|
||||
"""module for strip-related endpoints."""
|
||||
|
||||
from fastapi import APIRouter, Body, Depends
|
||||
from fastapi import APIRouter, Depends
|
||||
|
||||
from vmr_http.dependencies import get_voicemeeter_client
|
||||
from vmr_http.models.strip import StripParams
|
||||
|
||||
from . import stripcomp, stripdenoiser, stripgate
|
||||
from . import eq, stripcomp, stripdenoiser, stripgate
|
||||
|
||||
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.put('/{index}', tags=['strip'])
|
||||
async def set_strip_params(index: int, request: StripParams, voicemeeter=Depends(get_voicemeeter_client)):
|
||||
"""Set the parameters for the specified strip index."""
|
||||
@router.patch('', tags=['strip'])
|
||||
@router.put('', tags=['strip'])
|
||||
async def update_strip_params(index: int, params: StripParams, voicemeeter=Depends(get_voicemeeter_client)):
|
||||
"""Update one or more parameters for the specified strip index."""
|
||||
strip = voicemeeter.strip[index]
|
||||
for key, value in request.model_dump(exclude_unset=True).items():
|
||||
updated = {}
|
||||
for key, value in params.model_dump(exclude_unset=True).items():
|
||||
setattr(strip, key, value)
|
||||
|
||||
return {key: getattr(strip, key) for key in request.model_dump(exclude_unset=True)}
|
||||
updated[key] = getattr(strip, key)
|
||||
return updated
|
||||
|
||||
|
||||
@router.get('/{index}/gain', tags=['strip'])
|
||||
@router.get('/gain', tags=['strip'])
|
||||
async def get_gain(index: int, voicemeeter=Depends(get_voicemeeter_client)):
|
||||
"""Get the current gain value for the specified strip index."""
|
||||
return {'gain': voicemeeter.strip[index].gain}
|
||||
|
||||
|
||||
@router.put('/{index}/gain', tags=['strip'])
|
||||
async def set_gain(
|
||||
index: int,
|
||||
gain: float = Body(..., embed=True),
|
||||
voicemeeter=Depends(get_voicemeeter_client),
|
||||
):
|
||||
"""Set the gain value for the specified strip index."""
|
||||
voicemeeter.strip[index].gain = gain
|
||||
return {'gain': voicemeeter.strip[index].gain}
|
||||
|
||||
|
||||
@router.get('/{index}/mute', tags=['strip'])
|
||||
@router.get('/mute', tags=['strip'])
|
||||
async def get_mute(index: int, voicemeeter=Depends(get_voicemeeter_client)):
|
||||
"""Get the current mute status for the specified strip index."""
|
||||
return {'mute': voicemeeter.strip[index].mute}
|
||||
|
||||
|
||||
@router.put('/{index}/mute', tags=['strip'])
|
||||
async def set_mute(
|
||||
index: int,
|
||||
mute: bool = Body(..., embed=True),
|
||||
voicemeeter=Depends(get_voicemeeter_client),
|
||||
):
|
||||
"""Set the mute status for the specified strip index."""
|
||||
voicemeeter.strip[index].mute = mute
|
||||
return {'mute': voicemeeter.strip[index].mute}
|
||||
|
||||
|
||||
@router.get('/{index}/mono', tags=['strip'])
|
||||
@router.get('/mono', tags=['strip'])
|
||||
async def get_mono(index: int, voicemeeter=Depends(get_voicemeeter_client)):
|
||||
"""Get the current mono status for the specified strip index."""
|
||||
return {'mono': voicemeeter.strip[index].mono}
|
||||
|
||||
|
||||
@router.put('/{index}/mono', tags=['strip'])
|
||||
async def set_mono(
|
||||
index: int,
|
||||
mono: bool = Body(..., embed=True),
|
||||
voicemeeter=Depends(get_voicemeeter_client),
|
||||
):
|
||||
"""Set the mono status for the specified strip index."""
|
||||
voicemeeter.strip[index].mono = mono
|
||||
return {'mono': voicemeeter.strip[index].mono}
|
||||
|
||||
|
||||
@router.get('/{index}/solo', tags=['strip'])
|
||||
@router.get('/solo', tags=['strip'])
|
||||
async def get_solo(index: int, voicemeeter=Depends(get_voicemeeter_client)):
|
||||
"""Get the current solo status for the specified strip index."""
|
||||
return {'solo': voicemeeter.strip[index].solo}
|
||||
|
||||
|
||||
@router.put('/{index}/solo', tags=['strip'])
|
||||
async def set_solo(
|
||||
index: int,
|
||||
solo: bool = Body(..., embed=True),
|
||||
voicemeeter=Depends(get_voicemeeter_client),
|
||||
):
|
||||
"""Set the solo status for the specified strip index."""
|
||||
voicemeeter.strip[index].solo = solo
|
||||
return {'solo': voicemeeter.strip[index].solo}
|
||||
|
||||
|
||||
@router.get('/{index}/A1', tags=['strip'])
|
||||
@router.get('/A1', tags=['strip'])
|
||||
async def get_A1(index: int, voicemeeter=Depends(get_voicemeeter_client)):
|
||||
"""Get the current A1 output status for the specified strip index."""
|
||||
return {'A1': voicemeeter.strip[index].A1}
|
||||
|
||||
|
||||
@router.put('/{index}/A1', tags=['strip'])
|
||||
async def set_A1(
|
||||
index: int,
|
||||
A1: bool = Body(..., embed=True),
|
||||
voicemeeter=Depends(get_voicemeeter_client),
|
||||
):
|
||||
"""Set the A1 output status for the specified strip index."""
|
||||
voicemeeter.strip[index].A1 = A1
|
||||
return {'A1': voicemeeter.strip[index].A1}
|
||||
|
||||
|
||||
@router.get('/{index}/A2', tags=['strip'])
|
||||
@router.get('/A2', tags=['strip'])
|
||||
async def get_A2(index: int, voicemeeter=Depends(get_voicemeeter_client)):
|
||||
"""Get the current A2 output status for the specified strip index."""
|
||||
return {'A2': voicemeeter.strip[index].A2}
|
||||
|
||||
|
||||
@router.put('/{index}/A2', tags=['strip'])
|
||||
async def set_A2(
|
||||
index: int,
|
||||
A2: bool = Body(..., embed=True),
|
||||
voicemeeter=Depends(get_voicemeeter_client),
|
||||
):
|
||||
"""Set the A2 output status for the specified strip index."""
|
||||
voicemeeter.strip[index].A2 = A2
|
||||
return {'A2': voicemeeter.strip[index].A2}
|
||||
|
||||
|
||||
@router.get('/{index}/A3', tags=['strip'])
|
||||
@router.get('/A3', tags=['strip'])
|
||||
async def get_A3(index: int, voicemeeter=Depends(get_voicemeeter_client)):
|
||||
"""Get the current A3 output status for the specified strip index."""
|
||||
return {'A3': voicemeeter.strip[index].A3}
|
||||
|
||||
|
||||
@router.put('/{index}/A3', tags=['strip'])
|
||||
async def set_A3(
|
||||
index: int,
|
||||
A3: bool = Body(..., embed=True),
|
||||
voicemeeter=Depends(get_voicemeeter_client),
|
||||
):
|
||||
"""Set the A3 output status for the specified strip index."""
|
||||
voicemeeter.strip[index].A3 = A3
|
||||
return {'A3': voicemeeter.strip[index].A3}
|
||||
|
||||
|
||||
@router.get('/{index}/A4', tags=['strip'])
|
||||
@router.get('/A4', tags=['strip'])
|
||||
async def get_A4(index: int, voicemeeter=Depends(get_voicemeeter_client)):
|
||||
"""Get the current A4 output status for the specified strip index."""
|
||||
return {'A4': voicemeeter.strip[index].A4}
|
||||
|
||||
|
||||
@router.put('/{index}/A4', tags=['strip'])
|
||||
async def set_A4(
|
||||
index: int,
|
||||
A4: bool = Body(..., embed=True),
|
||||
voicemeeter=Depends(get_voicemeeter_client),
|
||||
):
|
||||
"""Set the A4 output status for the specified strip index."""
|
||||
voicemeeter.strip[index].A4 = A4
|
||||
return {'A4': voicemeeter.strip[index].A4}
|
||||
|
||||
|
||||
@router.get('/{index}/A5', tags=['strip'])
|
||||
@router.get('/A5', tags=['strip'])
|
||||
async def get_A5(index: int, voicemeeter=Depends(get_voicemeeter_client)):
|
||||
"""Get the current A5 output status for the specified strip index."""
|
||||
return {'A5': voicemeeter.strip[index].A5}
|
||||
|
||||
|
||||
@router.put('/{index}/A5', tags=['strip'])
|
||||
async def set_A5(
|
||||
index: int,
|
||||
A5: bool = Body(..., embed=True),
|
||||
voicemeeter=Depends(get_voicemeeter_client),
|
||||
):
|
||||
"""Set the A5 output status for the specified strip index."""
|
||||
voicemeeter.strip[index].A5 = A5
|
||||
return {'A5': voicemeeter.strip[index].A5}
|
||||
|
||||
|
||||
@router.get('/{index}/B1', tags=['strip'])
|
||||
@router.get('/B1', tags=['strip'])
|
||||
async def get_B1(index: int, voicemeeter=Depends(get_voicemeeter_client)):
|
||||
"""Get the current B1 output status for the specified strip index."""
|
||||
return {'B1': voicemeeter.strip[index].B1}
|
||||
|
||||
|
||||
@router.put('/{index}/B1', tags=['strip'])
|
||||
async def set_B1(
|
||||
index: int,
|
||||
B1: bool = Body(..., embed=True),
|
||||
voicemeeter=Depends(get_voicemeeter_client),
|
||||
):
|
||||
"""Set the B1 output status for the specified strip index."""
|
||||
voicemeeter.strip[index].B1 = B1
|
||||
return {'B1': voicemeeter.strip[index].B1}
|
||||
|
||||
|
||||
@router.get('/{index}/B2', tags=['strip'])
|
||||
@router.get('/B2', tags=['strip'])
|
||||
async def get_B2(index: int, voicemeeter=Depends(get_voicemeeter_client)):
|
||||
"""Get the current B2 output status for the specified strip index."""
|
||||
return {'B2': voicemeeter.strip[index].B2}
|
||||
|
||||
|
||||
@router.put('/{index}/B2', tags=['strip'])
|
||||
async def set_B2(
|
||||
index: int,
|
||||
B2: bool = Body(..., embed=True),
|
||||
voicemeeter=Depends(get_voicemeeter_client),
|
||||
):
|
||||
"""Set the B2 output status for the specified strip index."""
|
||||
voicemeeter.strip[index].B2 = B2
|
||||
return {'B2': voicemeeter.strip[index].B2}
|
||||
|
||||
|
||||
@router.get('/{index}/B3', tags=['strip'])
|
||||
@router.get('/B3', tags=['strip'])
|
||||
async def get_B3(index: int, voicemeeter=Depends(get_voicemeeter_client)):
|
||||
"""Get the current B3 output status for the specified strip index."""
|
||||
return {'B3': voicemeeter.strip[index].B3}
|
||||
|
||||
|
||||
@router.put('/{index}/B3', tags=['strip'])
|
||||
async def set_B3(
|
||||
index: int,
|
||||
B3: bool = Body(..., embed=True),
|
||||
voicemeeter=Depends(get_voicemeeter_client),
|
||||
):
|
||||
"""Set the B3 output status for the specified strip index."""
|
||||
voicemeeter.strip[index].B3 = B3
|
||||
return {'B3': voicemeeter.strip[index].B3}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"""module for strip compressor related endpoints."""
|
||||
|
||||
from fastapi import APIRouter, Body, Depends
|
||||
from fastapi import APIRouter, Depends
|
||||
|
||||
from vmr_http.dependencies import get_voicemeeter_client
|
||||
from vmr_http.models.strip import StripCompParams
|
||||
@@ -8,30 +8,20 @@ from vmr_http.models.strip import StripCompParams
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.put('/{index}/comp')
|
||||
async def set_strip_comp_params(index: int, request: StripCompParams, voicemeeter=Depends(get_voicemeeter_client)):
|
||||
"""Set the compressor parameters for the specified strip index."""
|
||||
@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
|
||||
for key, value in request.model_dump(exclude_unset=True).items():
|
||||
updated = {}
|
||||
for key, value in params.model_dump(exclude_unset=True).items():
|
||||
setattr(strip_comp, key, value)
|
||||
|
||||
return {key: getattr(strip_comp, key) for key in request.model_dump(exclude_unset=True)}
|
||||
updated[key] = getattr(strip_comp, key)
|
||||
return updated
|
||||
|
||||
|
||||
@router.get('/{index}/comp/knob')
|
||||
@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.put('/{index}/comp/knob')
|
||||
async def set_strip_comp_knob(
|
||||
index: int,
|
||||
knob: float = Body(..., embed=True),
|
||||
voicemeeter=Depends(get_voicemeeter_client),
|
||||
):
|
||||
"""Set the compressor knob value for the specified strip index."""
|
||||
strip_comp = voicemeeter.strip[index].comp
|
||||
strip_comp.knob = knob
|
||||
return {'knob': strip_comp.knob}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"""module for strip denoiser related endpoints."""
|
||||
|
||||
from fastapi import APIRouter, Body, Depends
|
||||
from fastapi import APIRouter, Depends
|
||||
|
||||
from vmr_http.dependencies import get_voicemeeter_client
|
||||
from vmr_http.models.strip import StripDenoiserParams
|
||||
@@ -8,21 +8,21 @@ from vmr_http.models.strip import StripDenoiserParams
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.put('/{index}/denoiser')
|
||||
async def set_strip_denoiser_params(
|
||||
index: int,
|
||||
request: StripDenoiserParams,
|
||||
voicemeeter=Depends(get_voicemeeter_client),
|
||||
@router.patch('')
|
||||
@router.put('')
|
||||
async def update_strip_denoiser_params(
|
||||
index: int, params: StripDenoiserParams, voicemeeter=Depends(get_voicemeeter_client)
|
||||
):
|
||||
"""Set the denoiser parameters for the specified strip index."""
|
||||
"""Update one or more denoiser parameters for the specified strip index."""
|
||||
strip_denoiser = voicemeeter.strip[index].denoiser
|
||||
for key, value in request.model_dump(exclude_unset=True).items():
|
||||
updated = {}
|
||||
for key, value in params.model_dump(exclude_unset=True).items():
|
||||
setattr(strip_denoiser, key, value)
|
||||
|
||||
return {key: getattr(strip_denoiser, key) for key in request.model_dump(exclude_unset=True)}
|
||||
updated[key] = getattr(strip_denoiser, key)
|
||||
return updated
|
||||
|
||||
|
||||
@router.get('/{index}/denoiser/knob')
|
||||
@router.get('/knob')
|
||||
async def get_strip_denoiser_knob(
|
||||
index: int,
|
||||
voicemeeter=Depends(get_voicemeeter_client),
|
||||
@@ -30,15 +30,3 @@ async def get_strip_denoiser_knob(
|
||||
"""Get the denoiser knob value for the specified strip index."""
|
||||
strip_denoiser = voicemeeter.strip[index].denoiser
|
||||
return {'knob': strip_denoiser.knob}
|
||||
|
||||
|
||||
@router.put('/{index}/denoiser/knob')
|
||||
async def set_strip_denoiser_knob(
|
||||
index: int,
|
||||
knob: float = Body(..., embed=True),
|
||||
voicemeeter=Depends(get_voicemeeter_client),
|
||||
):
|
||||
"""Set the denoiser knob value for the specified strip index."""
|
||||
strip_denoiser = voicemeeter.strip[index].denoiser
|
||||
strip_denoiser.knob = knob
|
||||
return {'knob': strip_denoiser.knob}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"""module for strip gate related endpoints."""
|
||||
|
||||
from fastapi import APIRouter, Body, Depends
|
||||
from fastapi import APIRouter, Depends
|
||||
|
||||
from vmr_http.dependencies import get_voicemeeter_client
|
||||
from vmr_http.models.strip import StripGateParams
|
||||
@@ -8,30 +8,20 @@ from vmr_http.models.strip import StripGateParams
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.put('/{index}/gate')
|
||||
async def set_strip_gate_params(index: int, request: StripGateParams, voicemeeter=Depends(get_voicemeeter_client)):
|
||||
"""Set the gate parameters for the specified strip index."""
|
||||
@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
|
||||
for key, value in request.model_dump(exclude_unset=True).items():
|
||||
updated = {}
|
||||
for key, value in params.model_dump(exclude_unset=True).items():
|
||||
setattr(strip_gate, key, value)
|
||||
|
||||
return {key: getattr(strip_gate, key) for key in request.model_dump(exclude_unset=True)}
|
||||
updated[key] = getattr(strip_gate, key)
|
||||
return updated
|
||||
|
||||
|
||||
@router.get('/{index}/gate/knob')
|
||||
@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.put('/{index}/gate/knob')
|
||||
async def set_strip_gate_knob(
|
||||
index: int,
|
||||
knob: float = Body(..., embed=True),
|
||||
voicemeeter=Depends(get_voicemeeter_client),
|
||||
):
|
||||
"""Set the gate knob value for the specified strip index."""
|
||||
strip_gate = voicemeeter.strip[index].gate
|
||||
strip_gate.knob = knob
|
||||
return {'knob': strip_gate.knob}
|
||||
|
||||
Reference in New Issue
Block a user