4 Commits

Author SHA1 Message Date
a82cbd2bc6 update bus mode PATCH endpoint
accepting {mode: value} is a little redundant but I prefer it to modifying the bus endpoint.

added bus mode PATCH example to README

patch bump
2026-04-05 02:26:26 +01:00
6d01b8d2d3 add bus mono route
patch bump
2026-04-05 02:13:45 +01:00
d20fb52d4b export app, fastapi entrypoint
patch bump
2026-04-05 01:41:15 +01:00
6ef9be7a61 add healtcheck example 2026-04-05 01:32:29 +01:00
6 changed files with 40 additions and 16 deletions

View File

@@ -14,7 +14,7 @@ pip install vmr-http
## Run ## Run
```console ```console
uvicorn vmr_http.app:app uvicorn vmr_http:app
``` ```
## Use ## Use
@@ -66,6 +66,26 @@ curl -X 'GET' \
-H 'accept: application/json' -H 'accept: application/json'
``` ```
*Set Bus 2 Mode*
```console
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*
```console
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.

View File

@@ -1,15 +1,11 @@
[project] [project]
name = "vmr-http" name = "vmr-http"
version = "0.3.0" version = "0.3.3"
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 }

View File

@@ -0,0 +1,5 @@
"""Voicemeeter HTTP API."""
from .app import app
__all__ = ['app']

View File

@@ -33,3 +33,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]}

View File

@@ -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(

2
uv.lock generated
View File

@@ -1151,7 +1151,7 @@ wheels = [
[[package]] [[package]]
name = "vmr-http" name = "vmr-http"
version = "0.3.0" version = "0.3.3"
source = { editable = "." } source = { editable = "." }
dependencies = [ dependencies = [
{ name = "fastapi" }, { name = "fastapi" },