10 Commits

Author SHA1 Message Date
714d2fc972 pass channel + cell indices to each class
update identifier properties to reflect changes.
2025-06-15 20:03:11 +01:00
c797912458 set cell count to 6 (0 up to 5) 2025-06-15 20:02:08 +01:00
William Young
f702b4feb3 Got rid of error with channels and cells not being subscriptable, but now getting -3 error trying to set eq.channel[0].cell[0].on 2025-06-15 11:48:17 -05:00
William Young
f8f10e358f Initial setup adding classes for channels and cells 2025-06-15 10:43:50 -05:00
f7abc5248b remove html reports, keep the badges 2025-02-28 12:38:37 +00:00
fec4315be2 typo fix 2025-02-27 20:34:49 +00:00
a3e3db3c37 move callbacks/observer examples into examples/events/ 2025-02-27 20:33:59 +00:00
3e201443e0 upd env name 2025-02-27 20:26:26 +00:00
868017c79f upd report paths, regenerate badges 2025-02-27 19:57:32 +00:00
795296d71e move tox config into tox.ini
add testenv:genbadges for generating test badges

update README badges
2025-02-27 19:52:37 +00:00
19 changed files with 218 additions and 83 deletions

8
.gitignore vendored
View File

@@ -128,10 +128,12 @@ dmypy.json
# Pyre type checker # Pyre type checker
.pyre/ .pyre/
# test reports
tests/reports/
!tests/reports/badge-*.svg
# test/config # test/config
quick.py test-*.py
config.toml config.toml
vm-api.log
logging.json
.vscode/ .vscode/

7
.pre-commit-config.yaml Normal file
View File

@@ -0,0 +1,7 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace

View File

@@ -2,9 +2,9 @@
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/onyx-and-iris/voicemeeter-api-python/blob/dev/LICENSE) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/onyx-and-iris/voicemeeter-api-python/blob/dev/LICENSE)
[![Poetry](https://img.shields.io/endpoint?url=https://python-poetry.org/badge/v0.json)](https://python-poetry.org/) [![Poetry](https://img.shields.io/endpoint?url=https://python-poetry.org/badge/v0.json)](https://python-poetry.org/)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff) [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
![Tests Status](./tests/basic.svg?dummy=8484744) ![Tests Status](./tests/reports/badge-basic.svg?dummy=8484744)
![Tests Status](./tests/banana.svg?dummy=8484744) ![Tests Status](./tests/reports/badge-banana.svg?dummy=8484744)
![Tests Status](./tests/potato.svg?dummy=8484744) ![Tests Status](./tests/reports/badge-potato.svg?dummy=8484744)
# Python Wrapper for Voicemeeter API # Python Wrapper for Voicemeeter API

View File

@@ -0,0 +1,9 @@
## About
The purpose of this script is to demonstratehow to utilize the channels and cells that are available as part of the EQ. It should take audio playing in the second virtual strip and then apply a LGF on the first physical at 500 Hz.
## Use
Configured for banana version.
Make sure you are playing audio into the second virtual strip and out of the first physical bus, both channels are unmuted and that you aren't monitoring another mixbus. Then run the script.

View File

@@ -0,0 +1,21 @@
import time
import voicemeeterlib
def main():
KIND_ID = 'banana'
with voicemeeterlib.api(KIND_ID) as vm:
vm.bus[0].eq.on = True
vm.bus[0].eq.channel[0].cell[0].on = True
vm.bus[0].eq.channel[0].cell[0].f = 500
vm.bus[0].eq.channel[0].cell[0].type = 3 # Should correspond to LPF
time.sleep(3)
vm.bus[0].eq.on = False
vm.bus[0].eq.channel[0].cell[0].on = False
vm.bus[0].eq.channel[0].cell[0].f = 50
vm.bus[0].eq.channel[0].cell[0].type = 0
if __name__ == '__main__':
main()

View File

@@ -0,0 +1,8 @@
# Events
If you want to receive updates on certain events there are two routes you can take:
- Register a class that implements an `on_update(self, event) -> None` method on the `{Remote}.subject` class.
- Register callback functions/methods on the `{Remote}.subject` class, one for each type of update.
Included are examples of both approaches.

View File

@@ -41,39 +41,8 @@ test-basic.script = "scripts:test_basic"
test-banana.script = "scripts:test_banana" test-banana.script = "scripts:test_banana"
test-potato.script = "scripts:test_potato" test-potato.script = "scripts:test_potato"
test-all.script = "scripts:test_all" test-all.script = "scripts:test_all"
generate-badges.script = "scripts:generate_badges"
[tool.tox]
legacy_tox_ini = """
[tox]
envlist = py310,py311,py312,py313
[testenv]
passenv = *
setenv = VIRTUALENV_DISCOVERY=pyenv
allowlist_externals = poetry
commands_pre =
poetry install --no-interaction --no-root
commands =
poetry run pytest tests
[testenv:dsl]
setenv = VIRTUALENV_DISCOVERY=pyenv
allowlist_externals = poetry
deps = pyparsing
commands_pre =
poetry install --no-interaction --no-root --without dev
commands =
poetry run python examples/dsl
[testenv:obs]
setenv = VIRTUALENV_DISCOVERY=pyenv
allowlist_externals = poetry
deps = obsws-python
commands_pre =
poetry install --no-interaction --no-root --without dev
commands =
poetry run python examples/obs
"""
[tool.ruff] [tool.ruff]
exclude = [ exclude = [

View File

@@ -9,7 +9,7 @@ def ex_dsl():
def ex_callbacks(): def ex_callbacks():
scriptpath = Path.cwd() / 'examples' / 'callbacks' / '.' scriptpath = Path.cwd() / 'examples' / 'events' / 'callbacks' / '.'
subprocess.run([sys.executable, str(scriptpath)]) subprocess.run([sys.executable, str(scriptpath)])
@@ -33,7 +33,7 @@ def ex_obs():
def ex_observer(): def ex_observer():
scriptpath = Path.cwd() / 'examples' / 'observer' / '.' scriptpath = Path.cwd() / 'examples' / 'events' / 'observer' / '.'
subprocess.run([sys.executable, str(scriptpath)]) subprocess.run([sys.executable, str(scriptpath)])
@@ -53,3 +53,10 @@ def test_all():
steps = [test_basic, test_banana, test_potato] steps = [test_basic, test_banana, test_potato]
for step in steps: for step in steps:
step() step()
def generate_badges():
for kind in ['basic', 'banana', 'potato']:
subprocess.run(
['tox', 'r', '-e', 'genbadge'], env=os.environ.copy() | {'KIND': kind}
)

View File

@@ -1,35 +0,0 @@
Function RunTests {
$coverage = "./tests/pytest_coverage.log"
$run_tests = "pytest --run-slow -v --capture=tee-sys --junitxml=./tests/.coverage.xml"
$match_pattern = "^=|^\s*$|^Running|^Using|^plugins|^collecting|^tests"
if ( Test-Path $coverage ) { Clear-Content $coverage }
ForEach ($line in $(Invoke-Expression $run_tests)) {
If ( $line -Match $match_pattern ) {
if ( $line -Match "^Running tests for kind \[(\w+)\]" ) { $kind = $Matches[1] }
$line | Tee-Object -FilePath $coverage -Append
}
}
Write-Output "$(Get-TimeStamp)" | Out-File $coverage -Append
Invoke-Expression "genbadge tests -t 90 -i ./tests/.coverage.xml -o ./tests/$kind.svg"
}
Function Get-TimeStamp {
return "[{0:MM/dd/yy} {0:HH:mm:ss}]" -f (Get-Date)
}
if ($MyInvocation.InvocationName -ne ".") {
Invoke-Expression ".\.venv\Scripts\Activate.ps1"
@("potato") | ForEach-Object {
$env:KIND = $_
RunTests
}
Invoke-Expression "deactivate"
}

View File

@@ -1 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="68" height="20" role="img" aria-label="tests: 159"><title>tests: 159</title><linearGradient id="s" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="r"><rect width="68" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#r)"><rect width="37" height="20" fill="#555"/><rect x="37" width="31" height="20" fill="#4c1"/><rect width="68" height="20" fill="url(#s)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text aria-hidden="true" x="195" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="270">tests</text><text x="195" y="140" transform="scale(.1)" fill="#fff" textLength="270">tests</text><text aria-hidden="true" x="515" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="210">159</text><text x="515" y="140" transform="scale(.1)" fill="#fff" textLength="210">159</text></g></svg> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="68" height="20" role="img" aria-label="tests: 158"><title>tests: 158</title><linearGradient id="s" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="r"><rect width="68" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#r)"><rect width="37" height="20" fill="#555"/><rect x="37" width="31" height="20" fill="#4c1"/><rect width="68" height="20" fill="url(#s)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text aria-hidden="true" x="195" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="270">tests</text><text x="195" y="140" transform="scale(.1)" fill="#fff" textLength="270">tests</text><text aria-hidden="true" x="515" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="210">158</text><text x="515" y="140" transform="scale(.1)" fill="#fff" textLength="210">158</text></g></svg>

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -1 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="68" height="20" role="img" aria-label="tests: 116"><title>tests: 116</title><linearGradient id="s" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="r"><rect width="68" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#r)"><rect width="37" height="20" fill="#555"/><rect x="37" width="31" height="20" fill="#4c1"/><rect width="68" height="20" fill="url(#s)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text aria-hidden="true" x="195" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="270">tests</text><text x="195" y="140" transform="scale(.1)" fill="#fff" textLength="270">tests</text><text aria-hidden="true" x="515" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="210">116</text><text x="515" y="140" transform="scale(.1)" fill="#fff" textLength="210">116</text></g></svg> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="68" height="20" role="img" aria-label="tests: 115"><title>tests: 115</title><linearGradient id="s" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="r"><rect width="68" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#r)"><rect width="37" height="20" fill="#555"/><rect x="37" width="31" height="20" fill="#4c1"/><rect width="68" height="20" fill="url(#s)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text aria-hidden="true" x="195" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="270">tests</text><text x="195" y="140" transform="scale(.1)" fill="#fff" textLength="270">tests</text><text aria-hidden="true" x="515" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="210">115</text><text x="515" y="140" transform="scale(.1)" fill="#fff" textLength="210">115</text></g></svg>

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -1 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="68" height="20" role="img" aria-label="tests: 184"><title>tests: 184</title><linearGradient id="s" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="r"><rect width="68" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#r)"><rect width="37" height="20" fill="#555"/><rect x="37" width="31" height="20" fill="#4c1"/><rect width="68" height="20" fill="url(#s)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text aria-hidden="true" x="195" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="270">tests</text><text x="195" y="140" transform="scale(.1)" fill="#fff" textLength="270">tests</text><text aria-hidden="true" x="515" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="210">184</text><text x="515" y="140" transform="scale(.1)" fill="#fff" textLength="210">184</text></g></svg> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="68" height="20" role="img" aria-label="tests: 183"><title>tests: 183</title><linearGradient id="s" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="r"><rect width="68" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#r)"><rect width="37" height="20" fill="#555"/><rect x="37" width="31" height="20" fill="#4c1"/><rect width="68" height="20" fill="url(#s)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text aria-hidden="true" x="195" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="270">tests</text><text x="195" y="140" transform="scale(.1)" fill="#fff" textLength="270">tests</text><text aria-hidden="true" x="515" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="210">183</text><text x="515" y="140" transform="scale(.1)" fill="#fff" textLength="210">183</text></g></svg>

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

42
tox.ini Normal file
View File

@@ -0,0 +1,42 @@
[tox]
envlist = py310,py311,py312,py313
[testenv]
passenv = *
setenv = VIRTUALENV_DISCOVERY=pyenv
allowlist_externals = poetry
commands_pre =
poetry install --no-interaction --no-root
commands =
poetry run pytest tests
[testenv:genbadge]
passenv = *
setenv = VIRTUALENV_DISCOVERY=pyenv
allowlist_externals = poetry
deps =
genbadge[all]
pytest-html
commands_pre =
poetry install --no-interaction --no-root
commands =
poetry run pytest --capture=tee-sys --junitxml=./tests/reports/junit-${KIND}.xml --html=./tests/reports/${KIND}.html tests
poetry run genbadge tests -t 90 -i ./tests/reports/junit-${KIND}.xml -o ./tests/reports/badge-${KIND}.svg
[testenv:dsl]
setenv = VIRTUALENV_DISCOVERY=pyenv
allowlist_externals = poetry
deps = pyparsing
commands_pre =
poetry install --no-interaction --no-root --without dev
commands =
poetry run python examples/dsl
[testenv:obs]
setenv = VIRTUALENV_DISCOVERY=pyenv
allowlist_externals = poetry
deps = obsws-python
commands_pre =
poetry install --no-interaction --no-root --without dev
commands =
poetry run python examples/obs

View File

@@ -88,6 +88,24 @@ class Bus(IRemote):
class BusEQ(IRemote): class BusEQ(IRemote):
@classmethod
def make(cls, remote, i):
"""
Factory method for BusEQ.
Returns a BusEQ class.
"""
kls = (cls,)
return type(
'BusEQ',
kls,
{
'channel': tuple(
BusEQCh.make(remote, i, j) for j in range(remote.kind.channels)
)
},
)
@property @property
def identifier(self) -> str: def identifier(self) -> str:
return f'Bus[{self.index}].eq' return f'Bus[{self.index}].eq'
@@ -109,6 +127,85 @@ class BusEQ(IRemote):
self.setter('ab', 1 if val else 0) self.setter('ab', 1 if val else 0)
class BusEQCh(IRemote):
@classmethod
def make(cls, remote, i, j):
"""
Factory method for Bus EQ channel.
Returns a BusEQCh class.
"""
kls = (cls,)
return type(
'BusEQCh',
kls,
{
'cell': tuple(
BusEQChCell(remote, i, j, k) for k in range(remote.kind.cells)
)
},
)
def __init__(self, remote, i, j):
super().__init__(remote, i)
self.channel_index = j
@property
def identifier(self) -> str:
return f'Bus[{self.index}].eq.channel[{self.channel_index}]'
class BusEQChCell(IRemote):
def __init__(self, remote, i, j, k):
super().__init__(remote, i)
self.channel_index = j
self.cell_index = k
@property
def identifier(self) -> str:
return f'Bus[{self.index}].eq.channel[{self.channel_index}].cell[{self.cell_index}]'
@property
def on(self) -> bool:
return self.getter('on') == 1
@on.setter
def on(self, val: bool):
self.setter('on', 1 if val else 0)
@property
def type(self) -> int:
return int(self.getter('type'))
@type.setter
def type(self, val: int):
self.setter('type', val)
@property
def f(self) -> float:
return round(self.getter('f'), 1)
@f.setter
def f(self, val: float):
self.setter('f', val)
@property
def gain(self) -> float:
return round(self.getter('gain'), 1)
@gain.setter
def gain(self, val: float):
self.setter('gain', val)
@property
def q(self) -> float:
return round(self.getter('q'), 1)
@q.setter
def q(self, val: float):
self.setter('q', val)
class PhysicalBus(Bus): class PhysicalBus(Bus):
@classmethod @classmethod
def make(cls, remote, i, kind): def make(cls, remote, i, kind):
@@ -321,7 +418,7 @@ def bus_factory(is_phys_bus, remote, i) -> Union[PhysicalBus, VirtualBus]:
{ {
'levels': BusLevel(remote, i), 'levels': BusLevel(remote, i),
'mode': BUSMODEMIXIN_cls(remote, i), 'mode': BUSMODEMIXIN_cls(remote, i),
'eq': BusEQ(remote, i), 'eq': BusEQ.make(remote, i),
}, },
)(remote, i) )(remote, i)

View File

@@ -31,6 +31,8 @@ class KindMapClass(metaclass=SingletonType):
asio: tuple asio: tuple
insert: int insert: int
composite: int composite: int
channels: int
cells: int
@property @property
def phys_in(self) -> int: def phys_in(self) -> int:
@@ -76,6 +78,8 @@ class BasicMap(KindMapClass):
asio: tuple = (0, 0) asio: tuple = (0, 0)
insert: int = 0 insert: int = 0
composite: int = 0 composite: int = 0
channels: int = 0
cells: int = 0
@dataclass(frozen=True) @dataclass(frozen=True)
@@ -86,6 +90,8 @@ class BananaMap(KindMapClass):
asio: tuple = (6, 8) asio: tuple = (6, 8)
insert: int = 22 insert: int = 22
composite: int = 8 composite: int = 8
channels: int = 9
cells: int = 6
@dataclass(frozen=True) @dataclass(frozen=True)
@@ -96,6 +102,8 @@ class PotatoMap(KindMapClass):
asio: tuple = (10, 8) asio: tuple = (10, 8)
insert: int = 34 insert: int = 34
composite: int = 8 composite: int = 8
channels: int = 9
cells: int = 6
def kind_factory(kind_id): def kind_factory(kind_id):