mirror of
https://github.com/onyx-and-iris/vmr-http.git
synced 2026-04-07 02:13:31 +00:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9760bc8338 | |||
| 44c14dfeeb | |||
| 252de84f11 | |||
| a82cbd2bc6 | |||
| 6d01b8d2d3 | |||
| d20fb52d4b | |||
| 6ef9be7a61 |
6
.gitignore
vendored
6
.gitignore
vendored
@@ -88,7 +88,7 @@ ipython_config.py
|
|||||||
# pyenv
|
# pyenv
|
||||||
# For a library or package, you might want to ignore these files since the code is
|
# 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:
|
# intended to run in multiple environments; otherwise, check them in:
|
||||||
# .python-version
|
.python-version
|
||||||
|
|
||||||
# pipenv
|
# pipenv
|
||||||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
||||||
@@ -185,9 +185,9 @@ cython_debug/
|
|||||||
.abstra/
|
.abstra/
|
||||||
|
|
||||||
# Visual Studio Code
|
# Visual Studio Code
|
||||||
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
||||||
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
||||||
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
||||||
# you could uncomment the following to ignore the entire vscode folder
|
# you could uncomment the following to ignore the entire vscode folder
|
||||||
# .vscode/
|
# .vscode/
|
||||||
|
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
3.13
|
|
||||||
30
README.md
30
README.md
@@ -14,14 +14,14 @@ pip install vmr-http
|
|||||||
## Run
|
## Run
|
||||||
|
|
||||||
```console
|
```console
|
||||||
uvicorn vmr_http.app:app
|
uvicorn vmr_http:app
|
||||||
```
|
```
|
||||||
|
|
||||||
## Use
|
## Use
|
||||||
|
|
||||||
*Set multiple Strip 0 parameters at once*
|
*Set multiple Strip 0 parameters at once*
|
||||||
|
|
||||||
```console
|
```bash
|
||||||
curl -X 'PATCH' \
|
curl -X 'PATCH' \
|
||||||
'http://127.0.0.1:8000/strip/0' \
|
'http://127.0.0.1:8000/strip/0' \
|
||||||
-H 'accept: application/json' \
|
-H 'accept: application/json' \
|
||||||
@@ -40,7 +40,7 @@ curl -X 'PATCH' \
|
|||||||
|
|
||||||
*Set Strip 1 mute*
|
*Set Strip 1 mute*
|
||||||
|
|
||||||
```console
|
```bash
|
||||||
curl -X 'PATCH' \
|
curl -X 'PATCH' \
|
||||||
'http://127.0.0.1:8000/strip/1' \
|
'http://127.0.0.1:8000/strip/1' \
|
||||||
-H 'accept: application/json' \
|
-H 'accept: application/json' \
|
||||||
@@ -52,7 +52,7 @@ curl -X 'PATCH' \
|
|||||||
|
|
||||||
*Get Bus 3 gain*
|
*Get Bus 3 gain*
|
||||||
|
|
||||||
```console
|
```bash
|
||||||
curl -X 'GET' \
|
curl -X 'GET' \
|
||||||
'http://127.0.0.1:8000/bus/3/gain' \
|
'http://127.0.0.1:8000/bus/3/gain' \
|
||||||
-H 'accept: application/json'
|
-H 'accept: application/json'
|
||||||
@@ -60,12 +60,32 @@ curl -X 'GET' \
|
|||||||
|
|
||||||
*Get Bus 4 Mode*
|
*Get Bus 4 Mode*
|
||||||
|
|
||||||
```console
|
```bash
|
||||||
curl -X 'GET' \
|
curl -X 'GET' \
|
||||||
'http://127.0.0.1:8000/bus/4/mode' \
|
'http://127.0.0.1:8000/bus/4/mode' \
|
||||||
-H 'accept: application/json'
|
-H 'accept: application/json'
|
||||||
```
|
```
|
||||||
|
|
||||||
|
*Set Bus 2 Mode*
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -X 'PATCH' \
|
||||||
|
'http://127.0.0.1:8000/bus/2/mode' \
|
||||||
|
-H 'accept: application/json' \
|
||||||
|
-H 'Content-Type: application/json' \
|
||||||
|
-d '{
|
||||||
|
"mode": "Composite"
|
||||||
|
}'
|
||||||
|
```
|
||||||
|
|
||||||
|
*Healthcheck*
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -X 'GET' \
|
||||||
|
'http://127.0.0.1:8000/health' \
|
||||||
|
-H 'accept: application/json'
|
||||||
|
```
|
||||||
|
|
||||||
## Documentation
|
## 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], visit the link in the startup message when you launch the server.
|
||||||
|
|||||||
@@ -1,15 +1,11 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "vmr-http"
|
name = "vmr-http"
|
||||||
version = "0.3.0"
|
version = "0.4.0"
|
||||||
description = "HTTP API for controlling Voicemeeter"
|
description = "HTTP API for controlling Voicemeeter"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
authors = [{ name = "onyx-and-iris", email = "code@onyxandiris.online" }]
|
authors = [{ name = "onyx-and-iris", email = "code@onyxandiris.online" }]
|
||||||
requires-python = ">=3.10"
|
requires-python = ">=3.10"
|
||||||
dependencies = [
|
dependencies = ["fastapi>=0.135.3", "uvicorn>=0.43.0", "voicemeeter-api>=2.7.2"]
|
||||||
"fastapi>=0.135.3",
|
|
||||||
"uvicorn>=0.43.0",
|
|
||||||
"voicemeeter-api>=2.7.2",
|
|
||||||
]
|
|
||||||
classifiers = [
|
classifiers = [
|
||||||
"Development Status :: 4 - Beta",
|
"Development Status :: 4 - Beta",
|
||||||
"Programming Language :: Python",
|
"Programming Language :: Python",
|
||||||
@@ -26,14 +22,10 @@ requires = ["uv_build>=0.11.3,<0.12.0"]
|
|||||||
build-backend = "uv_build"
|
build-backend = "uv_build"
|
||||||
|
|
||||||
[dependency-groups]
|
[dependency-groups]
|
||||||
dev = [
|
dev = ["fastapi[standard]>=0.135.3", "poethepoet>=0.43.0", "ruff>=0.15.9"]
|
||||||
"fastapi[standard]>=0.135.3",
|
|
||||||
"poethepoet>=0.43.0",
|
|
||||||
"ruff>=0.15.9",
|
|
||||||
]
|
|
||||||
|
|
||||||
[tool.fastapi]
|
[tool.fastapi]
|
||||||
entrypoint = "vmr_http.app:app"
|
entrypoint = "vmr_http:app"
|
||||||
|
|
||||||
[tool.uv.sources]
|
[tool.uv.sources]
|
||||||
voicemeeter-api = { path = "../voicemeeter-api-python", editable = true }
|
voicemeeter-api = { path = "../voicemeeter-api-python", editable = true }
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
"""Voicemeeter HTTP API."""
|
||||||
|
|
||||||
|
from .app import app
|
||||||
|
|
||||||
|
__all__ = ['app']
|
||||||
|
|||||||
15
src/vmr_http/models/eq.py
Normal file
15
src/vmr_http/models/eq.py
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
"""Models for the parameters of an equalizer."""
|
||||||
|
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
from pydantic import BaseModel
|
||||||
|
|
||||||
|
|
||||||
|
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
|
||||||
@@ -5,10 +5,11 @@ from fastapi import APIRouter, Depends
|
|||||||
from vmr_http.dependencies import get_voicemeeter_client
|
from vmr_http.dependencies import get_voicemeeter_client
|
||||||
from vmr_http.models.bus import BusParams
|
from vmr_http.models.bus import BusParams
|
||||||
|
|
||||||
from . import busmode
|
from . import busmode, eq
|
||||||
|
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
router.include_router(busmode.router, tags=['bus mode'])
|
router.include_router(busmode.router, tags=['bus mode'])
|
||||||
|
router.include_router(eq.router, tags=['bus eq'])
|
||||||
|
|
||||||
|
|
||||||
@router.patch('/{index}', tags=['bus'])
|
@router.patch('/{index}', tags=['bus'])
|
||||||
@@ -33,3 +34,10 @@ async def get_gain(index: int, voicemeeter=Depends(get_voicemeeter_client)):
|
|||||||
async def get_mute(index: int, voicemeeter=Depends(get_voicemeeter_client)):
|
async def get_mute(index: int, voicemeeter=Depends(get_voicemeeter_client)):
|
||||||
"""Get the current mute status for the specified bus index."""
|
"""Get the current mute status for the specified bus index."""
|
||||||
return {'mute': voicemeeter.bus[index].mute}
|
return {'mute': voicemeeter.bus[index].mute}
|
||||||
|
|
||||||
|
|
||||||
|
@router.get('/{index}/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]}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
"""module for bus mode related endpoints."""
|
"""module for bus mode related endpoints."""
|
||||||
|
|
||||||
from fastapi import APIRouter, Depends, HTTPException
|
from fastapi import APIRouter, Body, Depends, HTTPException
|
||||||
|
|
||||||
from vmr_http.dependencies import get_voicemeeter_client
|
from vmr_http.dependencies import get_voicemeeter_client
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ _reversed_busmodes = {v: k for k, v in _readable_busmodes.items()}
|
|||||||
|
|
||||||
@router.patch('/{index}/mode')
|
@router.patch('/{index}/mode')
|
||||||
@router.put('/{index}/mode')
|
@router.put('/{index}/mode')
|
||||||
async def update_bus_mode(index: int, mode: str, voicemeeter=Depends(get_voicemeeter_client)):
|
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."""
|
"""Update the bus mode for the specified bus index."""
|
||||||
if mode not in _reversed_busmodes:
|
if mode not in _reversed_busmodes:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
|
|||||||
87
src/vmr_http/web/eq.py
Normal file
87
src/vmr_http/web/eq.py
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
"""module for equalizer related endpoints."""
|
||||||
|
|
||||||
|
from fastapi import APIRouter, Body, Depends
|
||||||
|
|
||||||
|
from vmr_http.dependencies import get_voicemeeter_client
|
||||||
|
from vmr_http.models.eq import EQChannelCellParams
|
||||||
|
|
||||||
|
cell_router = APIRouter()
|
||||||
|
|
||||||
|
|
||||||
|
@cell_router.patch('/{cell_index}')
|
||||||
|
@cell_router.put('/{cell_index}')
|
||||||
|
async def update_strip_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 strip eq channel cell."""
|
||||||
|
cell = voicemeeter.strip[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('/{cell_index}/on')
|
||||||
|
async def get_strip_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 strip eq channel cell."""
|
||||||
|
return {'on': voicemeeter.strip[index].eq.channel[channel_index].cell[cell_index].on}
|
||||||
|
|
||||||
|
|
||||||
|
@cell_router.get('/{cell_index}/type')
|
||||||
|
async def get_strip_eq_channel_cell_type(
|
||||||
|
index: int, channel_index: int, cell_index: int, voicemeeter=Depends(get_voicemeeter_client)
|
||||||
|
):
|
||||||
|
"""Get the current type for the specified strip eq channel cell."""
|
||||||
|
return {'type': voicemeeter.strip[index].eq.channel[channel_index].cell[cell_index].type}
|
||||||
|
|
||||||
|
|
||||||
|
@cell_router.get('/{cell_index}/f')
|
||||||
|
async def get_strip_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 strip eq channel cell."""
|
||||||
|
return {'f': voicemeeter.strip[index].eq.channel[channel_index].cell[cell_index].f}
|
||||||
|
|
||||||
|
|
||||||
|
@cell_router.get('/{cell_index}/gain')
|
||||||
|
async def get_strip_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 strip eq channel cell."""
|
||||||
|
return {'gain': voicemeeter.strip[index].eq.channel[channel_index].cell[cell_index].gain}
|
||||||
|
|
||||||
|
|
||||||
|
@cell_router.get('/{cell_index}/q')
|
||||||
|
async def get_strip_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 strip eq channel cell."""
|
||||||
|
return {'q': voicemeeter.strip[index].eq.channel[channel_index].cell[cell_index].q}
|
||||||
|
|
||||||
|
|
||||||
|
router = APIRouter()
|
||||||
|
router.include_router(cell_router, prefix='/{index}/eq/channel/{channel_index}/cell')
|
||||||
|
|
||||||
|
|
||||||
|
@router.patch('/{index}/eq')
|
||||||
|
@router.put('/{index}/eq')
|
||||||
|
async def update_strip_eq_params(
|
||||||
|
index: int, on: bool = Body(..., embed=True), voicemeeter=Depends(get_voicemeeter_client)
|
||||||
|
):
|
||||||
|
"""Update one or more equalizer parameters for the specified strip index."""
|
||||||
|
strip_eq = voicemeeter.strip[index].eq
|
||||||
|
strip_eq.on = on
|
||||||
|
return {'on': strip_eq.on}
|
||||||
|
|
||||||
|
|
||||||
|
@router.get('/{index}/eq/on')
|
||||||
|
async def get_strip_eq_on(index: int, voicemeeter=Depends(get_voicemeeter_client)):
|
||||||
|
"""Get the current equalizer on status for the specified strip index."""
|
||||||
|
return {'on': voicemeeter.strip[index].eq.on}
|
||||||
@@ -5,12 +5,13 @@ from fastapi import APIRouter, Depends
|
|||||||
from vmr_http.dependencies import get_voicemeeter_client
|
from vmr_http.dependencies import get_voicemeeter_client
|
||||||
from vmr_http.models.strip import StripParams
|
from vmr_http.models.strip import StripParams
|
||||||
|
|
||||||
from . import stripcomp, stripdenoiser, stripgate
|
from . import eq, stripcomp, stripdenoiser, stripgate
|
||||||
|
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
router.include_router(stripcomp.router, prefix='/comp', tags=['strip comp'])
|
router.include_router(stripcomp.router, tags=['strip comp'])
|
||||||
router.include_router(stripgate.router, prefix='/gate', tags=['strip gate'])
|
router.include_router(stripgate.router, tags=['strip gate'])
|
||||||
router.include_router(stripdenoiser.router, prefix='/denoiser', tags=['strip denoiser'])
|
router.include_router(stripdenoiser.router, tags=['strip denoiser'])
|
||||||
|
router.include_router(eq.router, tags=['strip eq'])
|
||||||
|
|
||||||
|
|
||||||
@router.patch('/{index}', tags=['strip'])
|
@router.patch('/{index}', tags=['strip'])
|
||||||
|
|||||||
Reference in New Issue
Block a user