28 Commits

Author SHA1 Message Date
b291c3a477 minor version bump 2026-02-27 20:36:54 +00:00
c335d35b9f fix config extends section 2026-02-27 20:16:04 +00:00
911d2f64a6 import abc namespace 2026-02-08 09:09:59 +00:00
e58d6c7242 remove comments 2026-01-18 19:57:12 +00:00
870a95b41e upd Strip Comp/Gate/EQ in README 2026-01-18 18:08:40 +00:00
59880bf582 remove comments 2026-01-18 17:22:20 +00:00
cc58d1f081 implement {strip}.gate 2026-01-18 17:06:10 +00:00
e37dea38b3 upd Run Tests in README 2026-01-18 15:25:05 +00:00
7f3b0ac7c9 upd examples to read conn from env 2026-01-18 15:17:00 +00:00
0512fac710 implement parametric eq 2026-01-18 15:16:48 +00:00
d439da725c implement parametric eq 2026-01-18 14:42:07 +00:00
45ffed9f63 implement audibility knobs (inc comp, gate, denoiser) 2026-01-18 13:13:05 +00:00
14f79d1388 move namedtuples 2026-01-18 12:22:53 +00:00
b45bd38706 use namedtuples to improve readability 2026-01-18 12:19:16 +00:00
312b5c5842 refactor header dataclasses 2026-01-18 11:43:43 +00:00
ed8e281f7f remove unused func 2026-01-17 13:25:06 +00:00
efdcfce387 refactor gainlayers and bus gains 2026-01-17 13:19:43 +00:00
ad88286509 implement 3d parameters 2026-01-17 12:29:10 +00:00
ecbdd2778f add classmethod from_bytes() to both RT packets NBS0/NBS1 2026-01-17 10:06:28 +00:00
1babf85a89 upd poethepoet ver
have poe read from .env file
rename script tasks

add py313 to tox env list
2026-01-17 09:38:44 +00:00
fbd1d54f9b upd tests 2026-01-17 09:37:50 +00:00
96e9d6f4fd upd the interface to read/write multiple private/public packets.
{VirtualStrip}.bass/mid/treble implemented reading from public packet NBS=1
2026-01-17 09:37:31 +00:00
51394c0076 add VbanVMParamStrip defining the VMPARAMSTRIP_PACKET struct. 2026-01-17 09:35:33 +00:00
91feccc509 default bps to 256000 (same as VBAN-Text-Client SDK example) see https://github.com/vburel2018/VBAN-Text-Client
patch bump
2025-01-25 02:06:42 +00:00
c9c365ac54 rename test poe scripts
add passenv = * to [testenv]
2025-01-25 02:00:54 +00:00
1742ff839e add ip kwarg default value 2025-01-21 16:23:59 +00:00
5299d9ec6b log factory steps at debug level 2025-01-17 20:49:39 +00:00
bc2cd3e7a5 test against localhost
run tests through formatter

remove sel test from bus bool params
2025-01-17 15:01:40 +00:00
28 changed files with 1368 additions and 495 deletions

4
.gitignore vendored
View File

@@ -151,8 +151,8 @@ cython_debug/
# option (not recommended) you can uncomment the following to ignore the entire idea folder. # option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/ #.idea/
# quick test # test files
quick.py test-*.py
#config #config
config.toml config.toml

View File

@@ -11,6 +11,22 @@ Before any major/minor/patch bump all unit tests will be run to verify they pass
- [x] - [x]
## [2.6.0] - 2026-02-26
### Added
- support for packet with [ident:1](https://github.com/onyx-and-iris/Voicemeeter-SDK/blob/3be2c1c36563afbd6df3da8436406c77d2cc1f10/VoicemeeterRemote.h#L982) in VBAN TEXT subprotocol.
- This includes Strip 3D, PEQ, comp, gate, denoiser and pitch parameters.
## [2.5.2] - 2025-01-25
### Changed
- ip kwargs defaults to 'localhost'
- bps kwarg defaults to 256000.
- factory builder steps now logged at `DEBUG` level.
- Internal socket changes, they don't affect interface usage.
## [2.4.9] - 2023-08-13 ## [2.4.9] - 2023-08-13
### Added ### Added

View File

@@ -80,10 +80,10 @@ class ManyThings:
def main(): def main():
kind_id = 'banana' KIND_ID = 'banana'
with vban_cmd.api( with vban_cmd.api(
kind_id, ip='gamepc.local', port=6980, streamname='Command1' KIND_ID, ip='gamepc.local', port=6980, streamname='Command1'
) as vban: ) as vban:
do = ManyThings(vban) do = ManyThings(vban)
do.things() do.things()
@@ -171,9 +171,7 @@ example:
print(vban.strip[4].comp.knob) print(vban.strip[4].comp.knob)
``` ```
Strip Comp properties are defined as write only. Strip Comp `knob` is defined for all versions, all other parameters potato only.
`knob` defined for all versions, all other parameters potato only.
##### Strip.Gate ##### Strip.Gate
@@ -193,9 +191,7 @@ example:
vban.strip[2].gate.attack = 300.8 vban.strip[2].gate.attack = 300.8
``` ```
Strip Gate properties are defined as write only, potato version only. Strip Gate `knob` is defined for all versions, all other parameters potato only.
`knob` defined for all versions, all other parameters potato only.
##### Strip.Denoiser ##### Strip.Denoiser
@@ -212,7 +208,32 @@ The following properties are available.
- `on`: boolean - `on`: boolean
- `ab`: boolean - `ab`: boolean
Strip EQ properties are defined as write only, potato version only. example:
```python
vban.strip[0].eq.ab = True
```
##### Strip.EQ.Channel.Cell
The following properties are available.
- `on`: boolean
- `type`: int, from 0 up to 6
- `f`: float, from 20.0 up to 20_000.0
- `gain`: float, from -36.0 up to 18.0
- `q`: float, from 0.3 up to 100
example:
```python
vban.strip[0].eq.channel[0].cell[2].on = True
vban.strip[1].eq.channel[0].cell[2].f = 5000
```
Strip EQ parameters are defined for PhysicalStrips, potato version only.
Only channel[0] properties are readable over VBAN.
##### Gainlayers ##### Gainlayers
@@ -400,8 +421,8 @@ You just need to define a key `extends` in the config TOML, that names the confi
Three example 'extender' configs are included with the repo. You may load them with: Three example 'extender' configs are included with the repo. You may load them with:
```python ```python
import voicemeeterlib import vban_cmd
with voicemeeterlib.api('banana') as vm: with vban_cmd.api('banana') as vm:
vm.apply_config('extender') vm.apply_config('extender')
``` ```
@@ -482,9 +503,11 @@ print(vban.event.get())
You may pass the following optional keyword arguments: You may pass the following optional keyword arguments:
- `ip`: str, ip or hostname of remote machine - `ip`: str='localhost', ip or hostname of remote machine
- `streamname`: str, name of the stream to connect to.
- `port`: int=6980, vban udp port of remote machine. - `port`: int=6980, vban udp port of remote machine.
- `streamname`: str='Command1', name of the stream to connect to.
- `bps`: int=256000, bps rate of the stream.
- `channel`: int=0, channel on which to send the UDP requests.
- `pdirty`: boolean=False, parameter updates - `pdirty`: boolean=False, parameter updates
- `ldirty`: boolean=False, level updates - `ldirty`: boolean=False, level updates
- `timeout`: int=5, amount of time (seconds) to wait for an incoming RT data packet (parameter states). - `timeout`: int=5, amount of time (seconds) to wait for an incoming RT data packet (parameter states).
@@ -526,13 +549,15 @@ with vban_cmd.api('banana', **opts) as vban:
... ...
``` ```
## Tests ### Run tests
First make sure you installed the [development dependencies](https://github.com/onyx-and-iris/vban-cmd-python#installation) Install [poetry](https://python-poetry.org/docs/#installation) and then:
Then from tests directory: ```powershell
poetry poe test-basic
`pytest -v` poetry poe test-banana
poetry poe test-potato
```
## Resources ## Resources

View File

@@ -23,10 +23,10 @@ class ManyThings:
def main(): def main():
kind_id = 'banana' KIND_ID = 'banana'
with vban_cmd.api( with vban_cmd.api(
kind_id, ip='gamepc.local', port=6980, streamname='Command1' KIND_ID, ip='gamepc.local', port=6980, streamname='Command1'
) as vban: ) as vban:
do = ManyThings(vban) do = ManyThings(vban)
do.things() do.things()

View File

@@ -1,4 +1,5 @@
import logging import logging
import os
import tkinter as tk import tkinter as tk
from tkinter import ttk from tkinter import ttk
@@ -100,7 +101,14 @@ class App(tk.Tk):
def main(): def main():
with vban_cmd.api('banana', ldirty=True) as vban: KIND_ID = 'banana'
conn = {
'ip': os.environ.get('VBANCMD_IP', 'localhost'),
'port': int(os.environ.get('VBANCMD_PORT', 6980)),
'streamname': os.environ.get('VBANCMD_STREAMNAME', 'Command1'),
}
with vban_cmd.api(KIND_ID, ldirty=True, **conn) as vban:
app = App(vban) app = App(vban)
app.mainloop() app.mainloop()

View File

@@ -1,3 +1,4 @@
import os
import threading import threading
from logging import config from logging import config
@@ -92,8 +93,13 @@ class Observer:
def main(): def main():
KIND_ID = 'potato' KIND_ID = 'potato'
conn = {
'ip': os.environ.get('VBANCMD_IP', 'localhost'),
'port': int(os.environ.get('VBANCMD_PORT', 6980)),
'streamname': os.environ.get('VBANCMD_STREAMNAME', 'Command1'),
}
with vban_cmd.api(KIND_ID) as vban: with vban_cmd.api(KIND_ID, **conn) as vban:
stop_event = threading.Event() stop_event = threading.Event()
with Observer(vban, stop_event): with Observer(vban, stop_event):

View File

@@ -1,4 +1,5 @@
import logging import logging
import os
import vban_cmd import vban_cmd
@@ -23,8 +24,13 @@ class App:
def main(): def main():
KIND_ID = 'banana' KIND_ID = 'banana'
conn = {
'ip': os.environ.get('VBANCMD_IP', 'localhost'),
'port': int(os.environ.get('VBANCMD_PORT', 6980)),
'streamname': os.environ.get('VBANCMD_STREAMNAME', 'Command1'),
}
with vban_cmd.api(KIND_ID, pdirty=True, ldirty=True) as vban: with vban_cmd.api(KIND_ID, pdirty=True, ldirty=True, **conn) as vban:
App(vban) App(vban)
while _ := input('Press <Enter> to exit\n'): while _ := input('Press <Enter> to exit\n'):

View File

@@ -1,19 +1,15 @@
[project] [project]
name = "vban-cmd" name = "vban-cmd"
version = "2.5.0" version = "2.6.0"
description = "Python interface for the VBAN RT Packet Service (Sendtext)" description = "Python interface for the VBAN RT Packet Service (Sendtext)"
authors = [ authors = [{ name = "Onyx and Iris", email = "code@onyxandiris.online" }]
{name = "Onyx and Iris",email = "code@onyxandiris.online"}
]
license = { text = "MIT" } license = { text = "MIT" }
readme = "README.md" readme = "README.md"
requires-python = ">=3.10" requires-python = ">=3.10"
dependencies = [ dependencies = ["tomli (>=2.0.1,<3.0) ; python_version < '3.11'"]
"tomli (>=2.0.1,<3.0) ; python_version < '3.11'",
]
[tool.poetry.requires-plugins] [tool.poetry.requires-plugins]
poethepoet = "^0.32.1" poethepoet = "^0.35.0"
[tool.poetry.group.dev.dependencies] [tool.poetry.group.dev.dependencies]
pytest = "^8.3.4" pytest = "^8.3.4"
@@ -26,21 +22,25 @@ virtualenv-pyenv = "^0.5.0"
requires = ["poetry-core>=2.0.0,<3.0.0"] requires = ["poetry-core>=2.0.0,<3.0.0"]
build-backend = "poetry.core.masonry.api" build-backend = "poetry.core.masonry.api"
[tool.poe]
envfile = ".env"
[tool.poe.tasks] [tool.poe.tasks]
gui.script = "scripts:ex_gui" gui.script = "scripts:ex_gui"
obs.script = "scripts:ex_obs" obs.script = "scripts:ex_obs"
observer.script = "scripts:ex_observer" observer.script = "scripts:ex_observer"
basic.script = "scripts:test_basic" test-basic.script = "scripts:test_basic"
banana.script = "scripts:test_banana" test-banana.script = "scripts:test_banana"
potato.script = "scripts:test_potato" test-potato.script = "scripts:test_potato"
all.script = "scripts:test_all" test-all.script = "scripts:test_all"
[tool.tox] [tool.tox]
legacy_tox_ini = """ legacy_tox_ini = """
[tox] [tox]
envlist = py310,py311,py312 envlist = py310,py311,py312,py313
[testenv] [testenv]
passenv = *
setenv = VIRTUALENV_DISCOVERY=pyenv setenv = VIRTUALENV_DISCOVERY=pyenv
allowlist_externals = poetry allowlist_externals = poetry
commands = commands =
@@ -135,7 +135,4 @@ docstring-code-line-length = "dynamic"
max-complexity = 10 max-complexity = 10
[tool.ruff.lint.per-file-ignores] [tool.ruff.lint.per-file-ignores]
"__init__.py" = [ "__init__.py" = ["E402", "F401"]
"E402",
"F401",
]

View File

@@ -19,18 +19,15 @@ def ex_observer():
def test_basic(): def test_basic():
os.environ['KIND'] = 'basic' subprocess.run(['tox'], env=os.environ.copy() | {'KIND': 'basic'})
subprocess.run(['tox'])
def test_banana(): def test_banana():
os.environ['KIND'] = 'banana' subprocess.run(['tox'], env=os.environ.copy() | {'KIND': 'banana'})
subprocess.run(['tox'])
def test_potato(): def test_potato():
os.environ['KIND'] = 'potato' subprocess.run(['tox'], env=os.environ.copy() | {'KIND': 'potato'})
subprocess.run(['tox'])
def test_all(): def test_all():

View File

@@ -7,16 +7,13 @@ import vban_cmd
from vban_cmd.kinds import KindId from vban_cmd.kinds import KindId
from vban_cmd.kinds import request_kind_map as kindmap from vban_cmd.kinds import request_kind_map as kindmap
# get KIND_ID from env var, otherwise set to random # get KIND from environment, if not set default to potato
KIND_ID = os.environ.get( KIND_ID = os.environ.get('KIND', 'potato')
'KIND', random.choice(tuple(kind_id.name.lower() for kind_id in KindId))
)
opts = { opts = {
'ip': 'ws.local', 'ip': os.getenv('VBANCMD_IP', 'localhost'),
'streamname': 'workstation', 'streamname': os.getenv('VBANCMD_STREAMNAME', 'Command1'),
'port': 6980, 'port': int(os.getenv('VBANCMD_PORT', 6980)),
'bps': 0,
} }
vban = vban_cmd.api(KIND_ID, **opts) vban = vban_cmd.api(KIND_ID, **opts)

View File

@@ -1,7 +1,7 @@
def pytest_addoption(parser): def pytest_addoption(parser):
parser.addoption( parser.addoption(
"--run-slow", '--run-slow',
action="store_true", action='store_true',
default=False, default=False,
help="Run slow tests", help='Run slow tests',
) )

View File

@@ -12,27 +12,27 @@ class TestSetAndGetBoolHigher:
@classmethod @classmethod
def setup_class(cls): def setup_class(cls):
vban.apply_config("example") vban.apply_config('example')
time.sleep(0.1) time.sleep(0.1)
@pytest.mark.skipif( @pytest.mark.skipif(
"not config.getoption('--run-slow')", "not config.getoption('--run-slow')",
reason="Only run when --run-slow is given", reason='Only run when --run-slow is given',
) )
def test_it_tests_config_string(self): def test_it_tests_config_string(self):
assert "PhysStrip" in vban.strip[data.phys_in].label assert 'PhysStrip' in vban.strip[data.phys_in].label
assert "VirtStrip" in vban.strip[data.virt_in].label assert 'VirtStrip' in vban.strip[data.virt_in].label
@pytest.mark.skipif( @pytest.mark.skipif(
"not config.getoption('--run-slow')", "not config.getoption('--run-slow')",
reason="Only run when --run-slow is given", reason='Only run when --run-slow is given',
) )
def test_it_tests_config_bool(self): def test_it_tests_config_bool(self):
assert vban.strip[0].A1 == True assert vban.strip[0].A1
@pytest.mark.skipif( @pytest.mark.skipif(
"not config.getoption('--run-slow')", "not config.getoption('--run-slow')",
reason="Only run when --run-slow is given", reason='Only run when --run-slow is given',
) )
def test_it_tests_config_busmode(self): def test_it_tests_config_busmode(self):
assert vban.bus[data.phys_out].mode.get() == "composite" assert vban.bus[data.phys_out].mode.get() == 'composite'

View File

@@ -3,7 +3,7 @@ import re
import pytest import pytest
import vban_cmd import vban_cmd
from tests import data, vban from tests import vban
class TestErrors: class TestErrors:
@@ -12,26 +12,26 @@ class TestErrors:
def test_it_tests_an_unknown_kind(self): def test_it_tests_an_unknown_kind(self):
with pytest.raises( with pytest.raises(
vban_cmd.error.VBANCMDError, vban_cmd.error.VBANCMDError,
match=f"Unknown Voicemeeter kind 'unknown_kind'", match="Unknown Voicemeeter kind 'unknown_kind'",
): ):
vban_cmd.api("unknown_kind") vban_cmd.api('unknown_kind')
def test_it_tests_an_unknown_config_name(self): def test_it_tests_an_unknown_config_name(self):
EXPECTED_MSG = "\n".join( EXPECTED_MSG = '\n'.join(
( (
f"No config with name 'unknown' is loaded into memory", "No config with name 'unknown' is loaded into memory",
f"Known configs: {list(vban.configs.keys())}", f'Known configs: {list(vban.configs.keys())}',
) )
) )
with pytest.raises(vban_cmd.error.VBANCMDError, match=re.escape(EXPECTED_MSG)): with pytest.raises(vban_cmd.error.VBANCMDError, match=re.escape(EXPECTED_MSG)):
vban.apply_config("unknown") vban.apply_config('unknown')
def test_it_tests_an_invalid_config_key(self): def test_it_tests_an_invalid_config_key(self):
CONFIG = { CONFIG = {
"strip-0": {"A1": True, "B1": True, "gain": -6.0}, 'strip-0': {'A1': True, 'B1': True, 'gain': -6.0},
"bus-0": {"mute": True, "eq": {"on": True}}, 'bus-0': {'mute': True, 'eq': {'on': True}},
"unknown-0": {"state": True}, 'unknown-0': {'state': True},
"vban-out-1": {"name": "streamname"}, 'vban-out-1': {'name': 'streamname'},
} }
with pytest.raises(ValueError, match="invalid config key 'unknown-0'"): with pytest.raises(ValueError, match="invalid config key 'unknown-0'"):
vban.apply(CONFIG) vban.apply(CONFIG)

View File

@@ -7,15 +7,15 @@ class TestRemoteFactories:
__test__ = True __test__ = True
@pytest.mark.skipif( @pytest.mark.skipif(
data.name != "basic", data.name != 'basic',
reason="Skip test if kind is not basic", reason='Skip test if kind is not basic',
) )
def test_it_tests_remote_attrs_for_basic(self): def test_it_tests_remote_attrs_for_basic(self):
assert hasattr(vban, "strip") assert hasattr(vban, 'strip')
assert hasattr(vban, "bus") assert hasattr(vban, 'bus')
assert hasattr(vban, "command") assert hasattr(vban, 'command')
assert hasattr(vban, "button") assert hasattr(vban, 'button')
assert hasattr(vban, "vban") assert hasattr(vban, 'vban')
assert len(vban.strip) == 3 assert len(vban.strip) == 3
assert len(vban.bus) == 2 assert len(vban.bus) == 2
@@ -23,15 +23,15 @@ class TestRemoteFactories:
assert len(vban.vban.instream) == 6 and len(vban.vban.outstream) == 5 assert len(vban.vban.instream) == 6 and len(vban.vban.outstream) == 5
@pytest.mark.skipif( @pytest.mark.skipif(
data.name != "banana", data.name != 'banana',
reason="Skip test if kind is not basic", reason='Skip test if kind is not basic',
) )
def test_it_tests_remote_attrs_for_banana(self): def test_it_tests_remote_attrs_for_banana(self):
assert hasattr(vban, "strip") assert hasattr(vban, 'strip')
assert hasattr(vban, "bus") assert hasattr(vban, 'bus')
assert hasattr(vban, "command") assert hasattr(vban, 'command')
assert hasattr(vban, "button") assert hasattr(vban, 'button')
assert hasattr(vban, "vban") assert hasattr(vban, 'vban')
assert len(vban.strip) == 5 assert len(vban.strip) == 5
assert len(vban.bus) == 5 assert len(vban.bus) == 5
@@ -39,15 +39,15 @@ class TestRemoteFactories:
assert len(vban.vban.instream) == 10 and len(vban.vban.outstream) == 9 assert len(vban.vban.instream) == 10 and len(vban.vban.outstream) == 9
@pytest.mark.skipif( @pytest.mark.skipif(
data.name != "potato", data.name != 'potato',
reason="Skip test if kind is not basic", reason='Skip test if kind is not basic',
) )
def test_it_tests_remote_attrs_for_potato(self): def test_it_tests_remote_attrs_for_potato(self):
assert hasattr(vban, "strip") assert hasattr(vban, 'strip')
assert hasattr(vban, "bus") assert hasattr(vban, 'bus')
assert hasattr(vban, "command") assert hasattr(vban, 'command')
assert hasattr(vban, "button") assert hasattr(vban, 'button')
assert hasattr(vban, "vban") assert hasattr(vban, 'vban')
assert len(vban.strip) == 8 assert len(vban.strip) == 8
assert len(vban.bus) == 8 assert len(vban.bus) == 8

View File

@@ -3,17 +3,17 @@ import pytest
from tests import data, vban from tests import data, vban
@pytest.mark.parametrize("value", [False, True]) @pytest.mark.parametrize('value', [False, True])
class TestSetAndGetBoolHigher: class TestSetAndGetBoolHigher:
__test__ = True __test__ = True
"""strip tests, physical and virtual""" """strip tests, physical and virtual"""
@pytest.mark.parametrize( @pytest.mark.parametrize(
"index,param", 'index,param',
[ [
(data.phys_in, "mute"), (data.phys_in, 'mute'),
(data.virt_in, "solo"), (data.virt_in, 'solo'),
], ],
) )
def test_it_sets_and_gets_strip_bool_params(self, index, param, value): def test_it_sets_and_gets_strip_bool_params(self, index, param, value):
@@ -21,13 +21,13 @@ class TestSetAndGetBoolHigher:
assert getattr(vban.strip[index], param) == value assert getattr(vban.strip[index], param) == value
@pytest.mark.skipif( @pytest.mark.skipif(
data.name == "banana", data.name == 'banana',
reason="Only test if logged into Basic or Potato version", reason='Only test if logged into Basic or Potato version',
) )
@pytest.mark.parametrize( @pytest.mark.parametrize(
"index,param", 'index,param',
[ [
(data.phys_in, "mc"), (data.phys_in, 'mc'),
], ],
) )
def test_it_sets_and_gets_strip_bool_params_mc(self, index, param, value): def test_it_sets_and_gets_strip_bool_params_mc(self, index, param, value):
@@ -37,10 +37,9 @@ class TestSetAndGetBoolHigher:
""" bus tests, physical and virtual """ """ bus tests, physical and virtual """
@pytest.mark.parametrize( @pytest.mark.parametrize(
"index,param", 'index,param',
[ [
(data.phys_out, "mute"), (data.phys_out, 'mute'),
(data.virt_out, "sel"),
], ],
) )
def test_it_sets_and_gets_bus_bool_params(self, index, param, value): def test_it_sets_and_gets_bus_bool_params(self, index, param, value):
@@ -51,17 +50,17 @@ class TestSetAndGetBoolHigher:
""" bus modes tests, physical and virtual """ """ bus modes tests, physical and virtual """
@pytest.mark.parametrize( @pytest.mark.parametrize(
"index,param", 'index,param',
[ [
(data.phys_out, "normal"), (data.phys_out, 'normal'),
(data.phys_out, "amix"), (data.phys_out, 'amix'),
(data.phys_out, "rearonly"), (data.phys_out, 'rearonly'),
(data.virt_out, "normal"), (data.virt_out, 'normal'),
(data.virt_out, "upmix41"), (data.virt_out, 'upmix41'),
(data.virt_out, "composite"), (data.virt_out, 'composite'),
], ],
) )
def test_it_sets_and_gets_bus_bool_params(self, index, param, value): def test_it_sets_and_gets_bus_mode_bool_params(self, index, param, value):
# here it only makes sense to set/get bus modes as True # here it only makes sense to set/get bus modes as True
if not value: if not value:
value = True value = True
@@ -71,8 +70,8 @@ class TestSetAndGetBoolHigher:
""" command tests """ """ command tests """
@pytest.mark.parametrize( @pytest.mark.parametrize(
"param", 'param',
[("lock")], [('lock')],
) )
def test_it_sets_command_bool_params(self, param, value): def test_it_sets_command_bool_params(self, param, value):
setattr(vban.command, param, value) setattr(vban.command, param, value)
@@ -86,10 +85,10 @@ class TestSetAndGetIntHigher:
"""strip tests, physical and virtual""" """strip tests, physical and virtual"""
@pytest.mark.parametrize( @pytest.mark.parametrize(
"index,param,value", 'index,param,value',
[ [
(data.virt_in, "k", 0), (data.virt_in, 'k', 0),
(data.virt_in, "k", 4), (data.virt_in, 'k', 4),
], ],
) )
def test_it_sets_and_gets_strip_bool_params(self, index, param, value): def test_it_sets_and_gets_strip_bool_params(self, index, param, value):
@@ -103,12 +102,12 @@ class TestSetAndGetFloatHigher:
"""strip tests, physical and virtual""" """strip tests, physical and virtual"""
@pytest.mark.parametrize( @pytest.mark.parametrize(
"index,param,value", 'index,param,value',
[ [
(data.phys_in, "gain", -3.6), (data.phys_in, 'gain', -3.6),
(data.phys_in, "gain", 3.6), (data.phys_in, 'gain', 3.6),
(data.virt_in, "gain", -5.8), (data.virt_in, 'gain', -5.8),
(data.virt_in, "gain", 5.8), (data.virt_in, 'gain', 5.8),
], ],
) )
def test_it_sets_and_gets_strip_float_params(self, index, param, value): def test_it_sets_and_gets_strip_float_params(self, index, param, value):
@@ -116,18 +115,20 @@ class TestSetAndGetFloatHigher:
assert getattr(vban.strip[index], param) == value assert getattr(vban.strip[index], param) == value
@pytest.mark.parametrize( @pytest.mark.parametrize(
"index,value", 'index,value',
[(data.phys_in, 2), (data.phys_in, 2), (data.virt_in, 8), (data.virt_in, 8)], [(data.phys_in, 2), (data.phys_in, 2), (data.virt_in, 8), (data.virt_in, 8)],
) )
def test_it_gets_prefader_levels_and_compares_length_of_array(self, index, value): def test_it_gets_strip_prefader_levels_and_compares_length_of_array(
self, index, value
):
assert len(vban.strip[index].levels.prefader) == value assert len(vban.strip[index].levels.prefader) == value
@pytest.mark.skipif( @pytest.mark.skipif(
data.name != "potato", data.name != 'potato',
reason="Only test if logged into Potato version", reason='Only test if logged into Potato version',
) )
@pytest.mark.parametrize( @pytest.mark.parametrize(
"index, j, value", 'index, j, value',
[ [
(data.phys_in, 0, -20.7), (data.phys_in, 0, -20.7),
(data.virt_in, 3, -60), (data.virt_in, 3, -60),
@@ -142,14 +143,14 @@ class TestSetAndGetFloatHigher:
""" strip tests, physical """ """ strip tests, physical """
@pytest.mark.skipif( @pytest.mark.skipif(
data.name != "potato", data.name != 'potato',
reason="Only test if logged into Potato version", reason='Only test if logged into Potato version',
) )
@pytest.mark.parametrize( @pytest.mark.parametrize(
"index, param, value", 'index, param, value',
[ [
(data.phys_in, "gainin", -8.6), (data.phys_in, 'gainin', -8.6),
(data.phys_in, "knee", 0.24), (data.phys_in, 'knee', 0.24),
], ],
) )
def test_it_sets_strip_comp_params(self, index, param, value): def test_it_sets_strip_comp_params(self, index, param, value):
@@ -158,14 +159,14 @@ class TestSetAndGetFloatHigher:
# we can set but not get this value. Not in RT Packet. # we can set but not get this value. Not in RT Packet.
@pytest.mark.skipif( @pytest.mark.skipif(
data.name != "potato", data.name != 'potato',
reason="Only test if logged into Potato version", reason='Only test if logged into Potato version',
) )
@pytest.mark.parametrize( @pytest.mark.parametrize(
"index, param, value", 'index, param, value',
[ [
(data.phys_in, "bpsidechain", 120), (data.phys_in, 'bpsidechain', 120),
(data.phys_in, "hold", 3000), (data.phys_in, 'hold', 3000),
], ],
) )
def test_it_sets_and_gets_strip_gate_params(self, index, param, value): def test_it_sets_and_gets_strip_gate_params(self, index, param, value):
@@ -175,12 +176,13 @@ class TestSetAndGetFloatHigher:
""" strip tests, virtual """ """ strip tests, virtual """
@pytest.mark.skip(reason='Requires RT Packet NBS 1')
@pytest.mark.parametrize( @pytest.mark.parametrize(
"index, param, value", 'index, param, value',
[ [
(data.virt_in, "treble", -1.6), (data.virt_in, 'treble', -1.6),
(data.virt_in, "mid", 5.8), (data.virt_in, 'mid', 5.8),
(data.virt_in, "bass", -8.1), (data.virt_in, 'bass', -8.1),
], ],
) )
def test_it_sets_and_gets_strip_eq_params(self, index, param, value): def test_it_sets_and_gets_strip_eq_params(self, index, param, value):
@@ -190,30 +192,30 @@ class TestSetAndGetFloatHigher:
""" bus tests, physical and virtual """ """ bus tests, physical and virtual """
@pytest.mark.parametrize( @pytest.mark.parametrize(
"index, param, value", 'index, param, value',
[(data.phys_out, "gain", -3.6), (data.virt_out, "gain", 5.8)], [(data.phys_out, 'gain', -3.6), (data.virt_out, 'gain', 5.8)],
) )
def test_it_sets_and_gets_bus_float_params(self, index, param, value): def test_it_sets_and_gets_bus_float_params(self, index, param, value):
setattr(vban.bus[index], param, value) setattr(vban.bus[index], param, value)
assert getattr(vban.bus[index], param) == value assert getattr(vban.bus[index], param) == value
@pytest.mark.parametrize( @pytest.mark.parametrize(
"index,value", 'index,value',
[(data.phys_out, 8), (data.virt_out, 8)], [(data.phys_out, 8), (data.virt_out, 8)],
) )
def test_it_gets_prefader_levels_and_compares_length_of_array(self, index, value): def test_it_gets_bus_levels_and_compares_length_of_array(self, index, value):
assert len(vban.bus[index].levels.all) == value assert len(vban.bus[index].levels.all) == value
@pytest.mark.parametrize("value", ["test0", "test1"]) @pytest.mark.parametrize('value', ['test0', 'test1'])
class TestSetAndGetStringHigher: class TestSetAndGetStringHigher:
__test__ = True __test__ = True
"""strip tests, physical and virtual""" """strip tests, physical and virtual"""
@pytest.mark.parametrize( @pytest.mark.parametrize(
"index, param", 'index, param',
[(data.phys_in, "label"), (data.virt_in, "label")], [(data.phys_in, 'label'), (data.virt_in, 'label')],
) )
def test_it_sets_and_gets_strip_string_params(self, index, param, value): def test_it_sets_and_gets_strip_string_params(self, index, param, value):
setattr(vban.strip[index], param, value) setattr(vban.strip[index], param, value)
@@ -222,8 +224,8 @@ class TestSetAndGetStringHigher:
""" bus tests, physical and virtual """ """ bus tests, physical and virtual """
@pytest.mark.parametrize( @pytest.mark.parametrize(
"index, param", 'index, param',
[(data.phys_out, "label"), (data.virt_out, "label")], [(data.phys_out, 'label'), (data.virt_out, 'label')],
) )
def test_it_sets_and_gets_bus_string_params(self, index, param, value): def test_it_sets_and_gets_bus_string_params(self, index, param, value):
setattr(vban.bus[index], param, value) setattr(vban.bus[index], param, value)

View File

@@ -9,26 +9,26 @@ class TestPublicPacketLower:
"""Tests for a valid rt data packet""" """Tests for a valid rt data packet"""
def test_it_gets_an_rt_data_packet(self): def test_it_gets_an_rt0_data_packet(self):
assert vban.public_packet.voicemeetertype in ( assert vban.public_packets[0].voicemeetertype in (
kind.name for kind in kinds.kinds_all kind.name for kind in kinds.all
) )
@pytest.mark.parametrize("value", [0, 1]) @pytest.mark.parametrize('value', [0, 1])
class TestSetRT: class TestSetRT:
__test__ = True __test__ = True
"""Tests set_rt""" """Tests set_rt"""
@pytest.mark.parametrize( @pytest.mark.parametrize(
"kls,index,param", 'kls,index,param',
[ [
("strip", data.phys_in, "mute"), ('strip', data.phys_in, 'mute'),
("bus", data.virt_out, "mono"), ('bus', data.virt_out, 'mono'),
], ],
) )
def test_it_sends_a_text_request(self, kls, index, param, value): def test_it_sends_a_text_request(self, kls, index, param, value):
vban._set_rt(f"{kls}[{index}].{param}", value) vban._set_rt(f'{kls}[{index}].{param}', value)
target = getattr(vban, kls)[index] target = getattr(vban, kls)[index]
assert getattr(target, param) == bool(value) assert getattr(target, param) == bool(value)

View File

@@ -1,17 +1,11 @@
import abc
import time import time
from abc import abstractmethod
from enum import IntEnum
from typing import Union from typing import Union
from .enums import NBS, BusModes
from .iremote import IRemote from .iremote import IRemote
from .meta import bus_mode_prop, channel_bool_prop, channel_label_prop from .meta import bus_mode_prop, channel_bool_prop, channel_label_prop
BusModes = IntEnum(
'BusModes',
'normal amix bmix repeat composite tvmix upmix21 upmix41 upmix61 centeronly lfeonly rearonly',
start=0,
)
class Bus(IRemote): class Bus(IRemote):
""" """
@@ -20,7 +14,7 @@ class Bus(IRemote):
Defines concrete implementation for bus Defines concrete implementation for bus
""" """
@abstractmethod @abc.abstractmethod
def __str__(self): def __str__(self):
pass pass
@@ -30,14 +24,11 @@ class Bus(IRemote):
@property @property
def gain(self) -> float: def gain(self) -> float:
def fget():
val = self.public_packet.busgain[self.index]
if 0 <= val <= 1200:
return val * 0.01
return (((1 << 16) - 1) - val) * -0.01
val = self.getter('gain') val = self.getter('gain')
return round(val if val else fget(), 1) if val:
return round(val, 2)
else:
return self.public_packets[NBS.zero].busgain[self.index]
@gain.setter @gain.setter
def gain(self, val: float): def gain(self, val: float):
@@ -109,7 +100,7 @@ class BusLevel(IRemote):
) )
return tuple( return tuple(
fget(i) fget(i)
for i in self._remote._get_levels(self.public_packet)[1][ for i in self._remote._get_levels(self.public_packets[NBS.zero])[1][
self.range[0] : self.range[-1] self.range[0] : self.range[-1]
] ]
) )
@@ -157,7 +148,12 @@ def _make_bus_mode_mixin():
def get(self): def get(self):
states = [ states = [
(int.from_bytes(self.public_packet.busstate[self.index], 'little') & val) (
int.from_bytes(
self.public_packets[NBS.zero].busstate[self.index], 'little'
)
& val
)
>> 4 >> 4
for val in self._modes.modevals for val in self._modes.modevals
] ]

20
vban_cmd/enums.py Normal file
View File

@@ -0,0 +1,20 @@
from enum import Enum, IntEnum, unique
@unique
class KindId(Enum):
BASIC = 1
BANANA = 2
POTATO = 3
class NBS(IntEnum):
zero = 0
one = 1
BusModes = IntEnum(
'BusModes',
'normal amix bmix repeat composite tvmix upmix21 upmix41 upmix61 centeronly lfeonly rearonly',
start=0,
)

View File

@@ -1,5 +1,5 @@
import abc
import logging import logging
from abc import abstractmethod
from enum import IntEnum from enum import IntEnum
from functools import cached_property from functools import cached_property
from typing import Iterable from typing import Iterable
@@ -44,7 +44,7 @@ class FactoryBuilder:
def _pinfo(self, name: str) -> None: def _pinfo(self, name: str) -> None:
"""prints progress status for each step""" """prints progress status for each step"""
name = name.split('_')[1] name = name.split('_')[1]
self.logger.info(self._info[int(getattr(self.BuilderProgress, name))]) self.logger.debug(self._info[int(getattr(self.BuilderProgress, name))])
def make_strip(self): def make_strip(self):
self._factory.strip = tuple( self._factory.strip = tuple(
@@ -78,10 +78,10 @@ class FactoryBase(VbanCmd):
def __init__(self, kind_id: str, **kwargs): def __init__(self, kind_id: str, **kwargs):
defaultkwargs = { defaultkwargs = {
'ip': None, 'ip': 'localhost',
'port': 6980, 'port': 6980,
'streamname': 'Command1', 'streamname': 'Command1',
'bps': 0, 'bps': 256000,
'channel': 0, 'channel': 0,
'ratelimit': 0.01, 'ratelimit': 0.01,
'timeout': 5, 'timeout': 5,
@@ -115,7 +115,7 @@ class FactoryBase(VbanCmd):
) )
@property @property
@abstractmethod @abc.abstractmethod
def steps(self): def steps(self):
pass pass

View File

@@ -1,6 +1,6 @@
import abc
import logging import logging
import time import time
from abc import ABCMeta, abstractmethod
from dataclasses import dataclass from dataclasses import dataclass
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@@ -78,7 +78,7 @@ class Modes:
) )
class IRemote(metaclass=ABCMeta): class IRemote(abc.ABC):
""" """
Common interface between base class and extended (higher) classes Common interface between base class and extended (higher) classes
@@ -111,14 +111,14 @@ class IRemote(metaclass=ABCMeta):
return ''.join(cmd) return ''.join(cmd)
@property @property
@abstractmethod @abc.abstractmethod
def identifier(self): def identifier(self):
pass pass
@property @property
def public_packet(self): def public_packets(self):
"""Returns an RT data packet.""" """Returns an RT data packet."""
return self._remote.public_packet return self._remote.public_packets
def apply(self, data): def apply(self, data):
"""Sets all parameters of a dict for the channel.""" """Sets all parameters of a dict for the channel."""

View File

@@ -1,16 +1,9 @@
from dataclasses import dataclass from dataclasses import dataclass
from enum import Enum, unique
from .enums import KindId
from .error import VBANCMDError from .error import VBANCMDError
@unique
class KindId(Enum):
BASIC = 1
BANANA = 2
POTATO = 3
class SingletonType(type): class SingletonType(type):
"""ensure only a single instance of a kind map object""" """ensure only a single instance of a kind map object"""
@@ -22,12 +15,15 @@ class SingletonType(type):
return cls._instances[cls] return cls._instances[cls]
@dataclass @dataclass(frozen=True)
class KindMapClass(metaclass=SingletonType): class KindMapClass(metaclass=SingletonType):
name: str name: str
ins: tuple ins: tuple
outs: tuple outs: tuple
vban: tuple vban: tuple
strip_channels: int
bus_channels: int
cells: int
@property @property
def phys_in(self): def phys_in(self):
@@ -65,28 +61,37 @@ class KindMapClass(metaclass=SingletonType):
return self.name.capitalize() return self.name.capitalize()
@dataclass @dataclass(frozen=True)
class BasicMap(KindMapClass): class BasicMap(KindMapClass):
name: str name: str
ins: tuple = (2, 1) ins: tuple = (2, 1)
outs: tuple = (1, 1) outs: tuple = (1, 1)
vban: tuple = (4, 4, 1, 1) vban: tuple = (4, 4, 1, 1)
strip_channels: int = 0
bus_channels: int = 0
cells: int = 0
@dataclass @dataclass(frozen=True)
class BananaMap(KindMapClass): class BananaMap(KindMapClass):
name: str name: str
ins: tuple = (3, 2) ins: tuple = (3, 2)
outs: tuple = (3, 2) outs: tuple = (3, 2)
vban: tuple = (8, 8, 1, 1) vban: tuple = (8, 8, 1, 1)
strip_channels: int = 0
bus_channels: int = 8
cells: int = 6
@dataclass @dataclass(frozen=True)
class PotatoMap(KindMapClass): class PotatoMap(KindMapClass):
name: str name: str
ins: tuple = (5, 3) ins: tuple = (5, 3)
outs: tuple = (5, 3) outs: tuple = (5, 3)
vban: tuple = (8, 8, 1, 1) vban: tuple = (8, 8, 1, 1)
strip_channels: int = 2
bus_channels: int = 8
cells: int = 6
def kind_factory(kind_id): def kind_factory(kind_id):
@@ -111,4 +116,4 @@ def request_kind_map(kind_id):
return KIND_obj return KIND_obj
kinds_all = list(request_kind_map(kind_id.name.lower()) for kind_id in KindId) all = list(request_kind_map(kind_id.name.lower()) for kind_id in KindId)

View File

@@ -1,6 +1,7 @@
from functools import partial from functools import partial
from .util import cache_bool, cache_string from .enums import NBS
from .util import cache_bool, cache_float, cache_string
def channel_bool_prop(param): def channel_bool_prop(param):
@@ -13,7 +14,7 @@ def channel_bool_prop(param):
return ( return (
not int.from_bytes( not int.from_bytes(
getattr( getattr(
self.public_packet, self.public_packets[NBS.zero],
f'{"strip" if "strip" in type(self).__name__.lower() else "bus"}state', f'{"strip" if "strip" in type(self).__name__.lower() else "bus"}state',
)[self.index], )[self.index],
'little', 'little',
@@ -34,7 +35,7 @@ def channel_label_prop():
@partial(cache_string, param='label') @partial(cache_string, param='label')
def fget(self) -> str: def fget(self) -> str:
return getattr( return getattr(
self.public_packet, self.public_packets[NBS.zero],
f'{"strip" if "strip" in type(self).__name__.lower() else "bus"}labels', f'{"strip" if "strip" in type(self).__name__.lower() else "bus"}labels',
)[self.index] )[self.index]
@@ -52,7 +53,9 @@ def strip_output_prop(param):
cmd = self._cmd(param) cmd = self._cmd(param)
self.logger.debug(f'getter: {cmd}') self.logger.debug(f'getter: {cmd}')
return ( return (
not int.from_bytes(self.public_packet.stripstate[self.index], 'little') not int.from_bytes(
self.public_packets[NBS.zero].stripstate[self.index], 'little'
)
& getattr(self._modes, f'_bus{param.lower()}') & getattr(self._modes, f'_bus{param.lower()}')
== 0 == 0
) )
@@ -71,7 +74,12 @@ def bus_mode_prop(param):
cmd = self._cmd(param) cmd = self._cmd(param)
self.logger.debug(f'getter: {cmd}') self.logger.debug(f'getter: {cmd}')
return [ return [
(int.from_bytes(self.public_packet.busstate[self.index], 'little') & val) (
int.from_bytes(
self.public_packets[NBS.zero].busstate[self.index], 'little'
)
& val
)
>> 4 >> 4
for val in self._modes.modevals for val in self._modes.modevals
] == self.modestates[param] ] == self.modestates[param]
@@ -89,3 +97,61 @@ def action_fn(param, val=1):
self.setter(param, val) self.setter(param, val)
return fdo return fdo
def xy_prop(param):
"""meta function for XY pad parameters"""
@partial(cache_float, param=param)
def fget(self):
cmd = self._cmd(param)
self.logger.debug(f'getter: {cmd}')
if self.public_packets[NBS.one] is None:
return 0.0
positions = self.public_packets[NBS.one].strips[self.index].positions
match param:
case 'pan_x':
return positions.pan_x
case 'pan_y':
return positions.pan_y
case 'color_x':
return positions.color_x
case 'color_y':
return positions.color_y
case 'fx1':
return positions.fx1
case 'fx2':
return positions.fx2
def fset(self, val):
self.setter(param, val)
return property(fget, fset)
def send_prop(param):
"""meta function for send parameters"""
@partial(cache_float, param=param)
def fget(self):
cmd = self._cmd(param)
self.logger.debug(f'getter: {cmd}')
if self.public_packets[NBS.one] is None:
return 0.0
sends = self.public_packets[NBS.one].strips[self.index].sends
match param:
case 'reverb':
return sends.reverb
case 'delay':
return sends.delay
case 'fx1':
return sends.fx1
case 'fx2':
return sends.fx2
def fset(self, val):
self.setter(param, val)
return property(fget, fset)

View File

@@ -1,5 +1,8 @@
import struct
from dataclasses import dataclass from dataclasses import dataclass
from typing import NamedTuple
from .enums import NBS
from .kinds import KindMapClass from .kinds import KindMapClass
from .util import comp from .util import comp
@@ -8,38 +11,76 @@ VBAN_PROTOCOL_SERVICE = 0x60
VBAN_SERVICE_RTPACKETREGISTER = 32 VBAN_SERVICE_RTPACKETREGISTER = 32
VBAN_SERVICE_RTPACKET = 33 VBAN_SERVICE_RTPACKET = 33
VBAN_SERVICE_MASK = 0xE0
MAX_PACKET_SIZE = 1436 MAX_PACKET_SIZE = 1436
HEADER_SIZE = 4 + 1 + 1 + 1 + 1 + 16 HEADER_SIZE = 4 + 1 + 1 + 1 + 1 + 16
VMPARAMSTRIP_SIZE = 174
@dataclass @dataclass
class VbanRtPacket: class VbanRtPacket:
"""Represents the body of a VBAN RT data packet""" """Represents the body of a VBAN RT data packet"""
nbs: NBS
_kind: KindMapClass _kind: KindMapClass
_voicemeeterType: bytes # data[28:29] _voicemeeterType: bytes
_reserved: bytes # data[29:30] _reserved: bytes
_buffersize: bytes # data[30:32] _buffersize: bytes
_voicemeeterVersion: bytes # data[32:36] _voicemeeterVersion: bytes
_optionBits: bytes # data[36:40] _optionBits: bytes
_samplerate: bytes # data[40:44] _samplerate: bytes
_inputLeveldB100: bytes # data[44:112]
_outputLeveldB100: bytes # data[112:240]
_TransportBit: bytes # data[240:244] @dataclass
_stripState: bytes # data[244:276] class VbanRtPacketNBS0(VbanRtPacket):
_busState: bytes # data[276:308] """Represents the body of a VBAN RT data packet with NBS 0"""
_stripGaindB100Layer1: bytes # data[308:324]
_stripGaindB100Layer2: bytes # data[324:340] _inputLeveldB100: bytes
_stripGaindB100Layer3: bytes # data[340:356] _outputLeveldB100: bytes
_stripGaindB100Layer4: bytes # data[356:372] _TransportBit: bytes
_stripGaindB100Layer5: bytes # data[372:388] _stripState: bytes
_stripGaindB100Layer6: bytes # data[388:404] _busState: bytes
_stripGaindB100Layer7: bytes # data[404:420] _stripGaindB100Layer1: bytes
_stripGaindB100Layer8: bytes # data[420:436] _stripGaindB100Layer2: bytes
_busGaindB100: bytes # data[436:452] _stripGaindB100Layer3: bytes
_stripLabelUTF8c60: bytes # data[452:932] _stripGaindB100Layer4: bytes
_busLabelUTF8c60: bytes # data[932:1412] _stripGaindB100Layer5: bytes
_stripGaindB100Layer6: bytes
_stripGaindB100Layer7: bytes
_stripGaindB100Layer8: bytes
_busGaindB100: bytes
_stripLabelUTF8c60: bytes
_busLabelUTF8c60: bytes
@classmethod
def from_bytes(cls, nbs: NBS, kind: KindMapClass, data: bytes):
return cls(
nbs=nbs,
_kind=kind,
_voicemeeterType=data[28:29],
_reserved=data[29:30],
_buffersize=data[30:32],
_voicemeeterVersion=data[32:36],
_optionBits=data[36:40],
_samplerate=data[40:44],
_inputLeveldB100=data[44:112],
_outputLeveldB100=data[112:240],
_TransportBit=data[240:244],
_stripState=data[244:276],
_busState=data[276:308],
_stripGaindB100Layer1=data[308:324],
_stripGaindB100Layer2=data[324:340],
_stripGaindB100Layer3=data[340:356],
_stripGaindB100Layer4=data[356:372],
_stripGaindB100Layer5=data[372:388],
_stripGaindB100Layer6=data[388:404],
_stripGaindB100Layer7=data[404:420],
_stripGaindB100Layer8=data[420:436],
_busGaindB100=data[436:452],
_stripLabelUTF8c60=data[452:932],
_busLabelUTF8c60=data[932:1412],
)
def _generate_levels(self, levelarray) -> tuple: def _generate_levels(self, levelarray) -> tuple:
return tuple( return tuple(
@@ -130,66 +171,33 @@ class VbanRtPacket:
""" """
@property @property
def stripgainlayer1(self) -> tuple: def gainlayers(self) -> tuple:
"""returns tuple of all strip gain layers as tuples"""
return tuple( return tuple(
int.from_bytes(self._stripGaindB100Layer1[i : i + 2], 'little') tuple(
round(
int.from_bytes(
getattr(self, f'_stripGaindB100Layer{layer}')[i : i + 2],
'little',
signed=True,
)
* 0.01,
2,
)
for i in range(0, 16, 2) for i in range(0, 16, 2)
) )
for layer in range(1, 9)
@property
def stripgainlayer2(self) -> tuple:
return tuple(
int.from_bytes(self._stripGaindB100Layer2[i : i + 2], 'little')
for i in range(0, 16, 2)
)
@property
def stripgainlayer3(self) -> tuple:
return tuple(
int.from_bytes(self._stripGaindB100Layer3[i : i + 2], 'little')
for i in range(0, 16, 2)
)
@property
def stripgainlayer4(self) -> tuple:
return tuple(
int.from_bytes(self._stripGaindB100Layer4[i : i + 2], 'little')
for i in range(0, 16, 2)
)
@property
def stripgainlayer5(self) -> tuple:
return tuple(
int.from_bytes(self._stripGaindB100Layer5[i : i + 2], 'little')
for i in range(0, 16, 2)
)
@property
def stripgainlayer6(self) -> tuple:
return tuple(
int.from_bytes(self._stripGaindB100Layer6[i : i + 2], 'little')
for i in range(0, 16, 2)
)
@property
def stripgainlayer7(self) -> tuple:
return tuple(
int.from_bytes(self._stripGaindB100Layer7[i : i + 2], 'little')
for i in range(0, 16, 2)
)
@property
def stripgainlayer8(self) -> tuple:
return tuple(
int.from_bytes(self._stripGaindB100Layer8[i : i + 2], 'little')
for i in range(0, 16, 2)
) )
@property @property
def busgain(self) -> tuple: def busgain(self) -> tuple:
"""returns tuple of bus gains""" """returns tuple of bus gains"""
return tuple( return tuple(
int.from_bytes(self._busGaindB100[i : i + 2], 'little') round(
int.from_bytes(self._busGaindB100[i : i + 2], 'little', signed=True)
* 0.01,
2,
)
for i in range(0, 16, 2) for i in range(0, 16, 2)
) )
@@ -210,93 +218,480 @@ class VbanRtPacket:
) )
@dataclass class Audibility(NamedTuple):
class SubscribeHeader: knob: float
"""Represents the header an RT Packet Service subscription packet""" comp: float
gate: float
denoiser: float
name = 'Register RTP'
timeout = 15 class Positions(NamedTuple):
vban: bytes = 'VBAN'.encode() pan_x: float
format_sr: bytes = (VBAN_PROTOCOL_SERVICE).to_bytes(1, 'little') pan_y: float
format_nbs: bytes = (0).to_bytes(1, 'little') color_x: float
format_nbc: bytes = (VBAN_SERVICE_RTPACKETREGISTER).to_bytes(1, 'little') color_y: float
format_bit: bytes = (timeout & 0x000000FF).to_bytes(1, 'little') # timeout fx1: float
streamname: bytes = name.encode('ascii') + bytes(16 - len(name)) fx2: float
framecounter: bytes = (0).to_bytes(4, 'little')
class EqGains(NamedTuple):
bass: float
mid: float
treble: float
class ParametricEQSettings(NamedTuple):
on: bool
type: int
gain: float
freq: float
q: float
class Sends(NamedTuple):
reverb: float
delay: float
fx1: float
fx2: float
class CompressorSettings(NamedTuple):
gain_in: float
attack_ms: float
release_ms: float
n_knee: float
ratio: float
threshold: float
c_enabled: bool
makeup: bool
gain_out: float
class GateSettings(NamedTuple):
threshold_in: float
damping_max: float
bp_sidechain: bool
attack_ms: float
hold_ms: float
release_ms: float
class DenoiserSettings(NamedTuple):
threshold: float
class PitchSettings(NamedTuple):
enabled: bool
dry_wet: float
value: float
formant_lo: float
formant_med: float
formant_high: float
@dataclass
class VbanVMParamStrip:
"""Represents the VBAN_VMPARAMSTRIP_PACKET structure"""
_mode: bytes
_dblevel: bytes
_audibility: bytes
_pos3D_x: bytes
_pos3D_y: bytes
_posColor_x: bytes
_posColor_y: bytes
_EQgain1: bytes
_EQgain2: bytes
_EQgain3: bytes
# First channel parametric EQ
_PEQ_eqOn: bytes
_PEQ_eqtype: bytes
_PEQ_eqgain: bytes
_PEQ_eqfreq: bytes
_PEQ_eqq: bytes
_audibility_c: bytes
_audibility_g: bytes
_audibility_d: bytes
_posMod_x: bytes
_posMod_y: bytes
_send_reverb: bytes
_send_delay: bytes
_send_fx1: bytes
_send_fx2: bytes
_dblimit: bytes
_nKaraoke: bytes
_COMP_gain_in: bytes
_COMP_attack_ms: bytes
_COMP_release_ms: bytes
_COMP_n_knee: bytes
_COMP_comprate: bytes
_COMP_threshold: bytes
_COMP_c_enabled: bytes
_COMP_c_auto: bytes
_COMP_gain_out: bytes
_GATE_dBThreshold_in: bytes
_GATE_dBDamping_max: bytes
_GATE_BP_Sidechain: bytes
_GATE_attack_ms: bytes
_GATE_hold_ms: bytes
_GATE_release_ms: bytes
_DenoiserThreshold: bytes
_PitchEnabled: bytes
_Pitch_DryWet: bytes
_Pitch_Value: bytes
_Pitch_formant_lo: bytes
_Pitch_formant_med: bytes
_Pitch_formant_high: bytes
@classmethod
def from_bytes(cls, data: bytes):
return cls(
_mode=data[0:4],
_dblevel=data[4:8],
_audibility=data[8:10],
_pos3D_x=data[10:12],
_pos3D_y=data[12:14],
_posColor_x=data[14:16],
_posColor_y=data[16:18],
_EQgain1=data[18:20],
_EQgain2=data[20:22],
_EQgain3=data[22:24],
_PEQ_eqOn=data[24:30],
_PEQ_eqtype=data[30:36],
_PEQ_eqgain=data[36:60],
_PEQ_eqfreq=data[60:84],
_PEQ_eqq=data[84:108],
_audibility_c=data[108:110],
_audibility_g=data[110:112],
_audibility_d=data[112:114],
_posMod_x=data[114:116],
_posMod_y=data[116:118],
_send_reverb=data[118:120],
_send_delay=data[120:122],
_send_fx1=data[122:124],
_send_fx2=data[124:126],
_dblimit=data[126:128],
_nKaraoke=data[128:130],
_COMP_gain_in=data[130:132],
_COMP_attack_ms=data[132:134],
_COMP_release_ms=data[134:136],
_COMP_n_knee=data[136:138],
_COMP_comprate=data[138:140],
_COMP_threshold=data[140:142],
_COMP_c_enabled=data[142:144],
_COMP_c_auto=data[144:146],
_COMP_gain_out=data[146:148],
_GATE_dBThreshold_in=data[148:150],
_GATE_dBDamping_max=data[150:152],
_GATE_BP_Sidechain=data[152:154],
_GATE_attack_ms=data[154:156],
_GATE_hold_ms=data[156:158],
_GATE_release_ms=data[158:160],
_DenoiserThreshold=data[160:162],
_PitchEnabled=data[162:164],
_Pitch_DryWet=data[164:166],
_Pitch_Value=data[166:168],
_Pitch_formant_lo=data[168:170],
_Pitch_formant_med=data[170:172],
_Pitch_formant_high=data[172:174],
)
@property @property
def header(self): def mode(self) -> int:
header = self.vban return int.from_bytes(self._mode, 'little')
header += self.format_sr
header += self.format_nbs @property
header += self.format_nbc def audibility(self) -> Audibility:
header += self.format_bit return Audibility(
header += self.streamname round(int.from_bytes(self._audibility, 'little', signed=True) * 0.01, 2),
header += self.framecounter round(int.from_bytes(self._audibility_c, 'little', signed=True) * 0.01, 2),
assert len(header) == HEADER_SIZE + 4, ( round(int.from_bytes(self._audibility_g, 'little', signed=True) * 0.01, 2),
f'expected header size {HEADER_SIZE} bytes + 4 bytes framecounter ({HEADER_SIZE + 4} bytes total)' round(int.from_bytes(self._audibility_d, 'little', signed=True) * 0.01, 2),
) )
return header
@property
def positions(self) -> Positions:
return Positions(
round(int.from_bytes(self._pos3D_x, 'little', signed=True) * 0.01, 2),
round(int.from_bytes(self._pos3D_y, 'little', signed=True) * 0.01, 2),
round(int.from_bytes(self._posColor_x, 'little', signed=True) * 0.01, 2),
round(int.from_bytes(self._posColor_y, 'little', signed=True) * 0.01, 2),
round(int.from_bytes(self._posMod_x, 'little', signed=True) * 0.01, 2),
round(int.from_bytes(self._posMod_y, 'little', signed=True) * 0.01, 2),
)
@property
def eqgains(self) -> EqGains:
return EqGains(
*[
round(
int.from_bytes(getattr(self, f'_EQgain{i}'), 'little', signed=True)
* 0.01,
2,
)
for i in range(1, 4)
]
)
@property
def parametric_eq(self) -> tuple[ParametricEQSettings, ...]:
return tuple(
ParametricEQSettings(
on=bool(int.from_bytes(self._PEQ_eqOn[i : i + 1], 'little')),
type=int.from_bytes(self._PEQ_eqtype[i : i + 1], 'little'),
freq=struct.unpack('<f', self._PEQ_eqfreq[i * 4 : (i + 1) * 4])[0],
gain=struct.unpack('<f', self._PEQ_eqgain[i * 4 : (i + 1) * 4])[0],
q=struct.unpack('<f', self._PEQ_eqq[i * 4 : (i + 1) * 4])[0],
)
for i in range(6)
)
@property
def sends(self) -> Sends:
return Sends(
round(int.from_bytes(self._send_reverb, 'little', signed=True) * 0.01, 2),
round(int.from_bytes(self._send_delay, 'little', signed=True) * 0.01, 2),
round(int.from_bytes(self._send_fx1, 'little', signed=True) * 0.01, 2),
round(int.from_bytes(self._send_fx2, 'little', signed=True) * 0.01, 2),
)
@property
def karaoke(self) -> int:
return int.from_bytes(self._nKaraoke, 'little')
@property
def compressor(self) -> CompressorSettings:
return CompressorSettings(
gain_in=round(
int.from_bytes(self._COMP_gain_in, 'little', signed=True) * 0.01, 2
),
attack_ms=round(int.from_bytes(self._COMP_attack_ms, 'little') * 0.1, 2),
release_ms=round(int.from_bytes(self._COMP_release_ms, 'little') * 0.1, 2),
n_knee=round(int.from_bytes(self._COMP_n_knee, 'little') * 0.01, 2),
ratio=round(int.from_bytes(self._COMP_comprate, 'little') * 0.01, 2),
threshold=round(
int.from_bytes(self._COMP_threshold, 'little', signed=True) * 0.01, 2
),
c_enabled=bool(int.from_bytes(self._COMP_c_enabled, 'little')),
makeup=bool(int.from_bytes(self._COMP_c_auto, 'little')),
gain_out=round(
int.from_bytes(self._COMP_gain_out, 'little', signed=True) * 0.01, 2
),
)
@property
def gate(self) -> GateSettings:
return GateSettings(
threshold_in=round(
int.from_bytes(self._GATE_dBThreshold_in, 'little', signed=True) * 0.01,
2,
),
damping_max=round(
int.from_bytes(self._GATE_dBDamping_max, 'little', signed=True) * 0.01,
2,
),
bp_sidechain=round(
int.from_bytes(self._GATE_BP_Sidechain, 'little') * 0.1, 2
),
attack_ms=round(int.from_bytes(self._GATE_attack_ms, 'little') * 0.1, 2),
hold_ms=round(int.from_bytes(self._GATE_hold_ms, 'little') * 0.1, 2),
release_ms=round(int.from_bytes(self._GATE_release_ms, 'little') * 0.1, 2),
)
@property
def denoiser(self) -> DenoiserSettings:
return DenoiserSettings(
threshold=round(
int.from_bytes(self._DenoiserThreshold, 'little', signed=True) * 0.01, 2
)
)
@property
def pitch(self) -> PitchSettings:
return PitchSettings(
enabled=bool(int.from_bytes(self._PitchEnabled, 'little')),
dry_wet=round(
int.from_bytes(self._Pitch_DryWet, 'little', signed=True) * 0.01, 2
),
value=round(
int.from_bytes(self._Pitch_Value, 'little', signed=True) * 0.01, 2
),
formant_lo=round(
int.from_bytes(self._Pitch_formant_lo, 'little', signed=True) * 0.01, 2
),
formant_med=round(
int.from_bytes(self._Pitch_formant_med, 'little', signed=True) * 0.01, 2
),
formant_high=round(
int.from_bytes(self._Pitch_formant_high, 'little', signed=True) * 0.01,
2,
),
)
@dataclass
class VbanRtPacketNBS1(VbanRtPacket):
"""Represents the body of a VBAN RT data packet with NBS 1"""
strips: tuple[VbanVMParamStrip, ...]
@classmethod
def from_bytes(
cls,
nbs: NBS,
kind: KindMapClass,
data: bytes,
):
return cls(
nbs=nbs,
_kind=kind,
_voicemeeterType=data[28:29],
_reserved=data[29:30],
_buffersize=data[30:32],
_voicemeeterVersion=data[32:36],
_optionBits=data[36:40],
_samplerate=data[40:44],
strips=tuple(
VbanVMParamStrip.from_bytes(
data[44 + i * VMPARAMSTRIP_SIZE : 44 + (i + 1) * VMPARAMSTRIP_SIZE]
)
for i in range(16)
),
)
@dataclass
class SubscribeHeader:
"""Represents the header of an RT subscription packet"""
nbs: NBS = NBS.zero
name: str = 'Register-RTP'
timeout: int = 15
@property
def vban(self) -> bytes:
return b'VBAN'
@property
def format_sr(self) -> bytes:
return VBAN_PROTOCOL_SERVICE.to_bytes(1, 'little')
@property
def format_nbs(self) -> bytes:
return (self.nbs.value & 0xFF).to_bytes(1, 'little')
@property
def format_nbc(self) -> bytes:
return VBAN_SERVICE_RTPACKETREGISTER.to_bytes(1, 'little')
@property
def format_bit(self) -> bytes:
return (self.timeout & 0xFF).to_bytes(1, 'little')
@property
def streamname(self) -> bytes:
return self.name.encode('ascii') + bytes(16 - len(self.name))
@classmethod
def to_bytes(cls, nbs: NBS, framecounter: int) -> bytes:
header = cls(nbs=nbs)
data = bytearray()
data.extend(header.vban)
data.extend(header.format_sr)
data.extend(header.format_nbs)
data.extend(header.format_nbc)
data.extend(header.format_bit)
data.extend(header.streamname)
data.extend(framecounter.to_bytes(4, 'little'))
return bytes(data)
@dataclass @dataclass
class VbanRtPacketHeader: class VbanRtPacketHeader:
"""Represents the header of a VBAN RT response packet""" """Represents the header of an RT response packet"""
name = 'Voicemeeter-RTP' name: str = 'Voicemeeter-RTP'
vban: bytes = 'VBAN'.encode() format_sr: int = VBAN_PROTOCOL_SERVICE
format_sr: bytes = (VBAN_PROTOCOL_SERVICE).to_bytes(1, 'little') format_nbs: int = 0
format_nbs: bytes = (0).to_bytes(1, 'little') format_nbc: int = VBAN_SERVICE_RTPACKET
format_nbc: bytes = (VBAN_SERVICE_RTPACKET).to_bytes(1, 'little') format_bit: int = 0
format_bit: bytes = (0).to_bytes(1, 'little')
streamname: bytes = name.encode('ascii') + bytes(16 - len(name))
@property @property
def header(self): def vban(self) -> bytes:
header = self.vban return b'VBAN'
header += self.format_sr
header += self.format_nbs @property
header += self.format_nbc def streamname(self) -> bytes:
header += self.format_bit return self.name.encode('ascii') + bytes(16 - len(self.name))
header += self.streamname
assert len(header) == HEADER_SIZE, f'expected header size {HEADER_SIZE} bytes' @classmethod
return header def from_bytes(cls, data: bytes):
if len(data) < HEADER_SIZE:
raise ValueError('Data is too short to be a valid VbanRTPPacketHeader')
name = data[8:24].rstrip(b'\x00').decode('utf-8')
return cls(
name=name,
format_sr=data[4] & VBAN_SERVICE_MASK,
format_nbs=data[5],
format_nbc=data[6],
format_bit=data[7],
)
@dataclass @dataclass
class RequestHeader: class RequestHeader:
"""Represents the header of a REQUEST RT PACKET""" """Represents the header of an RT request packet"""
name: str name: str
bps_index: int bps_index: int
channel: int channel: int
vban: bytes = 'VBAN'.encode() framecounter: int = 0
nbs: bytes = (0).to_bytes(1, 'little')
bit: bytes = (0x10).to_bytes(1, 'little')
framecounter: bytes = (0).to_bytes(4, 'little')
@property @property
def sr(self): def vban(self) -> bytes:
return b'VBAN'
@property
def sr(self) -> bytes:
return (VBAN_PROTOCOL_TXT + self.bps_index).to_bytes(1, 'little') return (VBAN_PROTOCOL_TXT + self.bps_index).to_bytes(1, 'little')
@property @property
def nbc(self): def nbs(self) -> bytes:
return (0).to_bytes(1, 'little')
@property
def nbc(self) -> bytes:
return (self.channel).to_bytes(1, 'little') return (self.channel).to_bytes(1, 'little')
@property @property
def streamname(self): def bit(self) -> bytes:
return self.name.encode() + bytes(16 - len(self.name)) return (0x10).to_bytes(1, 'little')
@property @property
def header(self): def streamname(self) -> bytes:
header = self.vban return self.name.encode() + bytes(16 - len(self.name))
header += self.sr
header += self.nbs @classmethod
header += self.nbc def to_bytes(
header += self.bit cls, name: str, bps_index: int, channel: int, framecounter: int
header += self.streamname ) -> bytes:
header += self.framecounter header = cls(
assert len(header) == HEADER_SIZE + 4, ( name=name, bps_index=bps_index, channel=channel, framecounter=framecounter
f'expected header size {HEADER_SIZE} bytes + 4 bytes framecounter ({HEADER_SIZE + 4} bytes total)'
) )
return header
data = bytearray()
data.extend(header.vban)
data.extend(header.sr)
data.extend(header.nbs)
data.extend(header.nbc)
data.extend(header.bit)
data.extend(header.streamname)
data.extend(header.framecounter.to_bytes(4, 'little'))
return bytes(data)

View File

@@ -1,10 +1,17 @@
import abc
import time import time
from abc import abstractmethod
from typing import Union from typing import Union
from . import kinds
from .enums import NBS
from .iremote import IRemote from .iremote import IRemote
from .kinds import kinds_all from .meta import (
from .meta import channel_bool_prop, channel_label_prop, strip_output_prop channel_bool_prop,
channel_label_prop,
send_prop,
strip_output_prop,
xy_prop,
)
class Strip(IRemote): class Strip(IRemote):
@@ -14,7 +21,7 @@ class Strip(IRemote):
Defines concrete implementation for strip Defines concrete implementation for strip
""" """
@abstractmethod @abc.abstractmethod
def __str__(self): def __str__(self):
pass pass
@@ -34,7 +41,7 @@ class Strip(IRemote):
def gain(self) -> float: def gain(self) -> float:
val = self.getter('gain') val = self.getter('gain')
if val is None: if val is None:
val = self.gainlayer[0].gain val = max(layer.gain for layer in self.gainlayer)
return round(val, 1) return round(val, 1)
@gain.setter @gain.setter
@@ -52,15 +59,16 @@ class Strip(IRemote):
class PhysicalStrip(Strip): class PhysicalStrip(Strip):
@classmethod @classmethod
def make(cls, remote, index): def make(cls, remote, index, is_phys):
EFFECTS_cls = _make_effects_mixins(is_phys)[remote.kind.name]
return type( return type(
f'PhysicalStrip{remote.kind}', f'PhysicalStrip{remote.kind}',
(cls,), (cls, EFFECTS_cls),
{ {
'comp': StripComp(remote, index), 'comp': StripComp(remote, index),
'gate': StripGate(remote, index), 'gate': StripGate(remote, index),
'denoiser': StripDenoiser(remote, index), 'denoiser': StripDenoiser(remote, index),
'eq': StripEQ(remote, index), 'eq': StripEQ.make(remote, index),
}, },
) )
@@ -68,12 +76,14 @@ class PhysicalStrip(Strip):
return f'{type(self).__name__}{self.index}' return f'{type(self).__name__}{self.index}'
@property @property
def device(self): def audibility(self) -> float:
return if self.public_packets[NBS.one] is None:
return 0.0
return self.public_packets[NBS.one].strips[self.index].audibility.knob
@property @audibility.setter
def sr(self): def audibility(self, val: float):
return self.setter('audibility', val)
class StripComp(IRemote): class StripComp(IRemote):
@@ -83,7 +93,9 @@ class StripComp(IRemote):
@property @property
def knob(self) -> float: def knob(self) -> float:
return if self.public_packets[NBS.one] is None:
return 0.0
return self.public_packets[NBS.one].strips[self.index].audibility.comp
@knob.setter @knob.setter
def knob(self, val: float): def knob(self, val: float):
@@ -91,7 +103,9 @@ class StripComp(IRemote):
@property @property
def gainin(self) -> float: def gainin(self) -> float:
return if self.public_packets[NBS.one] is None:
return 0.0
return self.public_packets[NBS.one].strips[self.index].compressor.gain_in
@gainin.setter @gainin.setter
def gainin(self, val: float): def gainin(self, val: float):
@@ -99,7 +113,9 @@ class StripComp(IRemote):
@property @property
def ratio(self) -> float: def ratio(self) -> float:
return if self.public_packets[NBS.one] is None:
return 0.0
return self.public_packets[NBS.one].strips[self.index].compressor.ratio
@ratio.setter @ratio.setter
def ratio(self, val: float): def ratio(self, val: float):
@@ -107,7 +123,9 @@ class StripComp(IRemote):
@property @property
def threshold(self) -> float: def threshold(self) -> float:
return if self.public_packets[NBS.one] is None:
return 0.0
return self.public_packets[NBS.one].strips[self.index].compressor.threshold
@threshold.setter @threshold.setter
def threshold(self, val: float): def threshold(self, val: float):
@@ -115,7 +133,9 @@ class StripComp(IRemote):
@property @property
def attack(self) -> float: def attack(self) -> float:
return if self.public_packets[NBS.one] is None:
return 0.0
return self.public_packets[NBS.one].strips[self.index].compressor.attack_ms
@attack.setter @attack.setter
def attack(self, val: float): def attack(self, val: float):
@@ -123,7 +143,9 @@ class StripComp(IRemote):
@property @property
def release(self) -> float: def release(self) -> float:
return if self.public_packets[NBS.one] is None:
return 0.0
return self.public_packets[NBS.one].strips[self.index].compressor.release_ms
@release.setter @release.setter
def release(self, val: float): def release(self, val: float):
@@ -131,7 +153,9 @@ class StripComp(IRemote):
@property @property
def knee(self) -> float: def knee(self) -> float:
return if self.public_packets[NBS.one] is None:
return 0.0
return self.public_packets[NBS.one].strips[self.index].compressor.n_knee
@knee.setter @knee.setter
def knee(self, val: float): def knee(self, val: float):
@@ -139,7 +163,9 @@ class StripComp(IRemote):
@property @property
def gainout(self) -> float: def gainout(self) -> float:
return if self.public_packets[NBS.one] is None:
return 0.0
return self.public_packets[NBS.one].strips[self.index].compressor.gain_out
@gainout.setter @gainout.setter
def gainout(self, val: float): def gainout(self, val: float):
@@ -147,7 +173,9 @@ class StripComp(IRemote):
@property @property
def makeup(self) -> bool: def makeup(self) -> bool:
return if self.public_packets[NBS.one] is None:
return False
return bool(self.public_packets[NBS.one].strips[self.index].compressor.makeup)
@makeup.setter @makeup.setter
def makeup(self, val: bool): def makeup(self, val: bool):
@@ -161,7 +189,9 @@ class StripGate(IRemote):
@property @property
def knob(self) -> float: def knob(self) -> float:
return if self.public_packets[NBS.one] is None:
return 0.0
return self.public_packets[NBS.one].strips[self.index].audibility.gate
@knob.setter @knob.setter
def knob(self, val: float): def knob(self, val: float):
@@ -169,7 +199,9 @@ class StripGate(IRemote):
@property @property
def threshold(self) -> float: def threshold(self) -> float:
return if self.public_packets[NBS.one] is None:
return 0.0
return self.public_packets[NBS.one].strips[self.index].gate.threshold_in
@threshold.setter @threshold.setter
def threshold(self, val: float): def threshold(self, val: float):
@@ -177,7 +209,9 @@ class StripGate(IRemote):
@property @property
def damping(self) -> float: def damping(self) -> float:
return if self.public_packets[NBS.one] is None:
return 0.0
return self.public_packets[NBS.one].strips[self.index].gate.damping_max
@damping.setter @damping.setter
def damping(self, val: float): def damping(self, val: float):
@@ -185,7 +219,9 @@ class StripGate(IRemote):
@property @property
def bpsidechain(self) -> int: def bpsidechain(self) -> int:
return if self.public_packets[NBS.one] is None:
return 0
return self.public_packets[NBS.one].strips[self.index].gate.bp_sidechain
@bpsidechain.setter @bpsidechain.setter
def bpsidechain(self, val: int): def bpsidechain(self, val: int):
@@ -193,7 +229,9 @@ class StripGate(IRemote):
@property @property
def attack(self) -> float: def attack(self) -> float:
return if self.public_packets[NBS.one] is None:
return 0.0
return self.public_packets[NBS.one].strips[self.index].gate.attack_ms
@attack.setter @attack.setter
def attack(self, val: float): def attack(self, val: float):
@@ -201,7 +239,9 @@ class StripGate(IRemote):
@property @property
def hold(self) -> float: def hold(self) -> float:
return if self.public_packets[NBS.one] is None:
return 0.0
return self.public_packets[NBS.one].strips[self.index].gate.hold_ms
@hold.setter @hold.setter
def hold(self, val: float): def hold(self, val: float):
@@ -209,7 +249,9 @@ class StripGate(IRemote):
@property @property
def release(self) -> float: def release(self) -> float:
return if self.public_packets[NBS.one] is None:
return 0.0
return self.public_packets[NBS.one].strips[self.index].gate.release_ms
@release.setter @release.setter
def release(self, val: float): def release(self, val: float):
@@ -223,7 +265,9 @@ class StripDenoiser(IRemote):
@property @property
def knob(self) -> float: def knob(self) -> float:
return if self.public_packets[NBS.one] is None:
return 0.0
return self.public_packets[NBS.one].strips[self.index].audibility.denoiser
@knob.setter @knob.setter
def knob(self, val: float): def knob(self, val: float):
@@ -231,6 +275,25 @@ class StripDenoiser(IRemote):
class StripEQ(IRemote): class StripEQ(IRemote):
@classmethod
def make(cls, remote, i):
"""
Factory method for Strip EQ.
Returns a StripEQ class.
"""
STRIPEQ_cls = type(
'StripEQ',
(cls,),
{
'channel': tuple(
StripEQCh.make(remote, i, j)
for j in range(remote.kind.strip_channels)
)
},
)
return STRIPEQ_cls(remote, i)
@property @property
def identifier(self) -> str: def identifier(self) -> str:
return f'strip[{self.index}].eq' return f'strip[{self.index}].eq'
@@ -252,7 +315,155 @@ class StripEQ(IRemote):
self.setter('ab', 1 if val else 0) self.setter('ab', 1 if val else 0)
class StripEQCh(IRemote):
@classmethod
def make(cls, remote, i, j):
"""
Factory method for Strip EQ channel.
Returns a StripEQCh class.
"""
StripEQCh_cls = type(
'StripEQCh',
(cls,),
{
'cell': tuple(
StripEQChCell(remote, i, j, k) for k in range(remote.kind.cells)
)
},
)
return StripEQCh_cls(remote, i, j)
def __init__(self, remote, i, j):
super().__init__(remote, i)
self.channel_index = j
@property
def identifier(self) -> str:
return f'Strip[{self.index}].eq.channel[{self.channel_index}]'
class StripEQChCell(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'Strip[{self.index}].eq.channel[{self.channel_index}].cell[{self.cell_index}]'
@property
def on(self) -> bool:
if self.channel_index > 0:
self.logger.warning(
'Only channel 0 is supported over VBAN for Strip EQ cells'
)
if self.public_packets[NBS.one] is None:
return False
return (
self.public_packets[NBS.one]
.strips[self.index]
.parametric_eq[self.cell_index]
.on
)
@on.setter
def on(self, val: bool):
self.setter('on', 1 if val else 0)
@property
def type(self) -> int:
if self.channel_index > 0:
self.logger.warning(
'Only channel 0 is supported over VBAN for Strip EQ cells'
)
if self.public_packets[NBS.one] is None:
return 0
return (
self.public_packets[NBS.one]
.strips[self.index]
.parametric_eq[self.cell_index]
.type
)
@type.setter
def type(self, val: int):
self.setter('type', val)
@property
def f(self) -> float:
if self.channel_index > 0:
self.logger.warning(
'Only channel 0 is supported over VBAN for Strip EQ cells'
)
if self.public_packets[NBS.one] is None:
return 0.0
return (
self.public_packets[NBS.one]
.strips[self.index]
.parametric_eq[self.cell_index]
.freq
)
@f.setter
def f(self, val: float):
self.setter('f', val)
@property
def gain(self) -> float:
if self.channel_index > 0:
self.logger.warning(
'Only channel 0 is supported over VBAN for Strip EQ cells'
)
if self.public_packets[NBS.one] is None:
return 0.0
return (
self.public_packets[NBS.one]
.strips[self.index]
.parametric_eq[self.cell_index]
.gain
)
@gain.setter
def gain(self, val: float):
self.setter('gain', val)
@property
def q(self) -> float:
if self.channel_index > 0:
self.logger.warning(
'Only channel 0 is supported over VBAN for Strip EQ cells'
)
if self.public_packets[NBS.one] is None:
return 0.0
return (
self.public_packets[NBS.one]
.strips[self.index]
.parametric_eq[self.cell_index]
.q
)
@q.setter
def q(self, val: float):
self.setter('q', val)
class VirtualStrip(Strip): class VirtualStrip(Strip):
@classmethod
def make(cls, remote, i, is_phys):
"""
Factory method for VirtualStrip.
Returns a VirtualStrip class.
"""
EFFECTS_cls = _make_effects_mixins(is_phys)[remote.kind.name]
return type(
'VirtualStrip',
(cls, EFFECTS_cls),
{},
)
def __str__(self): def __str__(self):
return f'{type(self).__name__}{self.index}' return f'{type(self).__name__}{self.index}'
@@ -262,12 +473,48 @@ class VirtualStrip(Strip):
@property @property
def k(self) -> int: def k(self) -> int:
return if self.public_packets[NBS.one] is None:
return 0
return self.public_packets[NBS.one].strips[self.index].karaoke
@k.setter @k.setter
def k(self, val: int): def k(self, val: int):
self.setter('karaoke', val) self.setter('karaoke', val)
@property
def bass(self) -> float:
if self.public_packets[NBS.one] is None:
return 0.0
return self.public_packets[NBS.one].strips[self.index].eqgains.bass
@bass.setter
def bass(self, val: float):
self.setter('EQGain1', val)
@property
def mid(self) -> float:
if self.public_packets[NBS.one] is None:
return 0.0
return self.public_packets[NBS.one].strips[self.index].eqgains.mid
@mid.setter
def mid(self, val: float):
self.setter('EQGain2', val)
med = mid
@property
def treble(self) -> float:
if self.public_packets[NBS.one] is None:
return 0.0
return self.public_packets[NBS.one].strips[self.index].eqgains.treble
@treble.setter
def treble(self, val: float):
self.setter('EQGain3', val)
high = treble
def appgain(self, name: str, gain: float): def appgain(self, name: str, gain: float):
self.setter('AppGain', f'("{name}", {gain})') self.setter('AppGain', f'("{name}", {gain})')
@@ -305,7 +552,7 @@ class StripLevel(IRemote):
) )
return tuple( return tuple(
fget(i) fget(i)
for i in self._remote._get_levels(self.public_packet)[0][ for i in self._remote._get_levels(self.public_packets[NBS.zero])[0][
self.range[0] : self.range[-1] self.range[0] : self.range[-1]
] ]
) )
@@ -349,16 +596,11 @@ class GainLayer(IRemote):
@property @property
def gain(self) -> float: def gain(self) -> float:
def fget():
val = getattr(self.public_packet, f'stripgainlayer{self._i + 1}')[
self.index
]
if 0 <= val <= 1200:
return val * 0.01
return (((1 << 16) - 1) - val) * -0.01
val = self.getter(f'GainLayer[{self._i}]') val = self.getter(f'GainLayer[{self._i}]')
return round(val if val else fget(), 1) if val:
return round(val, 2)
else:
return self.public_packets[NBS.zero].gainlayers[self._i][self.index]
@gain.setter @gain.setter
def gain(self, val: float): def gain(self, val: float):
@@ -395,10 +637,64 @@ def _make_channelout_mixin(kind):
_make_channelout_mixins = { _make_channelout_mixins = {
kind.name: _make_channelout_mixin(kind) for kind in kinds_all kind.name: _make_channelout_mixin(kind) for kind in kinds.all
} }
def _make_effects_mixin(kind, is_phys):
"""creates an effects mixin for a kind"""
def _make_xy_cls():
pan = {param: xy_prop(param) for param in ['pan_x', 'pan_y']}
color = {param: xy_prop(param) for param in ['color_x', 'color_y']}
fx = {param: xy_prop(param) for param in ['fx_x', 'fx_y']}
if is_phys:
return type(
'XYPhys',
(),
{
**pan,
**color,
**fx,
},
)
return type(
'XYVirt',
(),
{**pan},
)
def _make_sends_cls():
if is_phys:
return type(
'FX',
(),
{
**{
param: send_prop(param)
for param in ['reverb', 'delay', 'fx1', 'fx2']
},
# **{
# f'post{param}': bool_prop(f'post{param}')
# for param in ['reverb', 'delay', 'fx1', 'fx2']
# },
},
)
return type('FX', (), {})
if kind.name == 'basic':
steps = (_make_xy_cls,)
elif kind.name == 'banana':
steps = (_make_xy_cls,)
elif kind.name == 'potato':
steps = (_make_xy_cls, _make_sends_cls)
return type(f'Effects{kind}', tuple(step() for step in steps), {})
def _make_effects_mixins(is_phys):
return {kind.name: _make_effects_mixin(kind, is_phys) for kind in kinds.all}
def strip_factory(is_phys_strip, remote, i) -> Union[PhysicalStrip, VirtualStrip]: def strip_factory(is_phys_strip, remote, i) -> Union[PhysicalStrip, VirtualStrip]:
""" """
Factory method for strips Factory method for strips
@@ -407,7 +703,11 @@ def strip_factory(is_phys_strip, remote, i) -> Union[PhysicalStrip, VirtualStrip
Returns a physical or virtual strip subclass Returns a physical or virtual strip subclass
""" """
STRIP_cls = PhysicalStrip.make(remote, i) if is_phys_strip else VirtualStrip STRIP_cls = (
PhysicalStrip.make(remote, i, is_phys_strip)
if is_phys_strip
else VirtualStrip.make(remote, i, is_phys_strip)
)
CHANNELOUTMIXIN_cls = _make_channelout_mixins[remote.kind.name] CHANNELOUTMIXIN_cls = _make_channelout_mixins[remote.kind.name]
GAINLAYERMIXIN_cls = _make_gainlayer_mixin(remote, i) GAINLAYERMIXIN_cls = _make_gainlayer_mixin(remote, i)

View File

@@ -29,6 +29,20 @@ def cache_string(func, param):
return wrapper return wrapper
def cache_float(func, param):
"""Check cache for a float prop"""
def wrapper(*args, **kwargs):
self, *rem = args
if self._cmd(param) in self._remote.cache:
return round(self._remote.cache.pop(self._cmd(param)), 2)
if self._remote.sync:
self._remote.clear_dirty()
return func(*args, **kwargs)
return wrapper
def depth(d): def depth(d):
if isinstance(d, dict): if isinstance(d, dict):
return 1 + (max(map(depth, d.values())) if d else 0) return 1 + (max(map(depth, d.values())) if d else 0)
@@ -82,3 +96,11 @@ def deep_merge(dict1, dict2):
yield k, dict1[k] yield k, dict1[k]
else: else:
yield k, dict2[k] yield k, dict2[k]
def bump_framecounter(framecounter: int) -> int:
"""Increment framecounter with rollover at 0xFFFFFFFF."""
if framecounter > 0xFFFFFFFF:
return 0
else:
return framecounter + 1

View File

@@ -1,7 +1,7 @@
from abc import abstractmethod import abc
from . import kinds
from .iremote import IRemote from .iremote import IRemote
from .kinds import kinds_all
class VbanStream(IRemote): class VbanStream(IRemote):
@@ -11,7 +11,7 @@ class VbanStream(IRemote):
Defines concrete implementation for vban stream Defines concrete implementation for vban stream
""" """
@abstractmethod @abc.abstractmethod
def __str__(self): def __str__(self):
pass pass
@@ -194,7 +194,7 @@ def _make_stream_pair(remote, kind):
def _make_stream_pairs(remote): def _make_stream_pairs(remote):
return {kind.name: _make_stream_pair(remote, kind) for kind in kinds_all} return {kind.name: _make_stream_pair(remote, kind) for kind in kinds.all}
class Vban: class Vban:

View File

@@ -1,24 +1,25 @@
import abc
import logging import logging
import socket import socket
import threading import threading
import time import time
from abc import ABCMeta, abstractmethod
from pathlib import Path from pathlib import Path
from queue import Queue from queue import Queue
from typing import Iterable, Union from typing import Iterable, Union
from .enums import NBS
from .error import VBANCMDError from .error import VBANCMDError
from .event import Event from .event import Event
from .packet import RequestHeader from .packet import RequestHeader
from .subject import Subject from .subject import Subject
from .util import deep_merge, script from .util import bump_framecounter, deep_merge, script
from .worker import Producer, Subscriber, Updater from .worker import Producer, Subscriber, Updater
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
class VbanCmd(metaclass=ABCMeta): class VbanCmd(abc.ABC):
"""Base class responsible for communicating with the VBAN RT Packet Service""" """Abstract Base Class for Voicemeeter VBAN Command Interfaces"""
DELAY = 0.001 DELAY = 0.001
# fmt: off # fmt: off
@@ -37,12 +38,9 @@ class VbanCmd(metaclass=ABCMeta):
for attr, val in kwargs.items(): for attr, val in kwargs.items():
setattr(self, attr, val) setattr(self, attr, val)
self.packet_request = RequestHeader( self._framecounter = 0
name=self.streamname,
bps_index=self.BPS_OPTS.index(self.bps),
channel=self.channel,
)
self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
self.subject = self.observer = Subject() self.subject = self.observer = Subject()
self.cache = {} self.cache = {}
self._pdirty = False self._pdirty = False
@@ -51,7 +49,7 @@ class VbanCmd(metaclass=ABCMeta):
self.stop_event = None self.stop_event = None
self.producer = None self.producer = None
@abstractmethod @abc.abstractmethod
def __str__(self): def __str__(self):
"""Ensure subclasses override str magic method""" """Ensure subclasses override str magic method"""
pass pass
@@ -60,7 +58,7 @@ class VbanCmd(metaclass=ABCMeta):
try: try:
import tomllib import tomllib
except ModuleNotFoundError: except ModuleNotFoundError:
import tomli as tomllib import tomli as tomllib # type: ignore[import]
def get_filepath(): def get_filepath():
for pn in ( for pn in (
@@ -124,37 +122,49 @@ class VbanCmd(metaclass=ABCMeta):
def _set_rt(self, cmd: str, val: Union[str, float]): def _set_rt(self, cmd: str, val: Union[str, float]):
"""Sends a string request command over a network.""" """Sends a string request command over a network."""
req_packet = RequestHeader.to_bytes(
name=self.streamname,
bps_index=self.BPS_OPTS.index(self.bps),
channel=self.channel,
framecounter=self._framecounter,
)
self.sock.sendto( self.sock.sendto(
self.packet_request.header + f'{cmd}={val};'.encode(), req_packet + f'{cmd}={val};'.encode(),
(socket.gethostbyname(self.ip), self.port), (socket.gethostbyname(self.ip), self.port),
) )
self.packet_request.framecounter = ( self._framecounter = bump_framecounter(self._framecounter)
int.from_bytes(self.packet_request.framecounter, 'little') + 1
).to_bytes(4, 'little')
self.cache[cmd] = val self.cache[cmd] = val
@script @script
def sendtext(self, script): def sendtext(self, script):
"""Sends a multiple parameter string over a network.""" """Sends a multiple parameter string over a network."""
req_packet = RequestHeader.to_bytes(
name=self.streamname,
bps_index=self.BPS_OPTS.index(self.bps),
channel=self.channel,
framecounter=self._framecounter,
)
self.sock.sendto( self.sock.sendto(
self.packet_request.header + script.encode(), req_packet + script.encode(),
(socket.gethostbyname(self.ip), self.port), (socket.gethostbyname(self.ip), self.port),
) )
self.packet_request.framecounter = ( self._framecounter = bump_framecounter(self._framecounter)
int.from_bytes(self.packet_request.framecounter, 'little') + 1
).to_bytes(4, 'little')
self.logger.debug(f'sendtext: {script}') self.logger.debug(f'sendtext: {script}')
time.sleep(self.DELAY) time.sleep(self.DELAY)
@property @property
def type(self) -> str: def type(self) -> str:
"""Returns the type of Voicemeeter installation.""" """Returns the type of Voicemeeter installation."""
return self.public_packet.voicemeetertype return self.public_packets[NBS.zero].voicemeetertype
@property @property
def version(self) -> str: def version(self) -> str:
"""Returns Voicemeeter's version as a string""" """Returns Voicemeeter's version as a string"""
return '{0}.{1}.{2}.{3}'.format(*self.public_packet.voicemeeterversion) return '{0}.{1}.{2}.{3}'.format(
*self.public_packets[NBS.zero].voicemeeterversion
)
@property @property
def pdirty(self): def pdirty(self):
@@ -167,8 +177,8 @@ class VbanCmd(metaclass=ABCMeta):
return self._ldirty return self._ldirty
@property @property
def public_packet(self): def public_packets(self):
return self._public_packet return self._public_packets
def clear_dirty(self) -> None: def clear_dirty(self) -> None:
while self.pdirty: while self.pdirty:

View File

@@ -2,10 +2,20 @@ import logging
import socket import socket
import threading import threading
import time import time
from typing import Optional
from .enums import NBS
from .error import VBANCMDConnectionError from .error import VBANCMDConnectionError
from .packet import HEADER_SIZE, SubscribeHeader, VbanRtPacket, VbanRtPacketHeader from .packet import (
HEADER_SIZE,
VBAN_PROTOCOL_SERVICE,
VBAN_SERVICE_RTPACKET,
SubscribeHeader,
VbanRtPacket,
VbanRtPacketHeader,
VbanRtPacketNBS0,
VbanRtPacketNBS1,
)
from .util import bump_framecounter
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@@ -18,18 +28,18 @@ class Subscriber(threading.Thread):
self._remote = remote self._remote = remote
self.stop_event = stop_event self.stop_event = stop_event
self.logger = logger.getChild(self.__class__.__name__) self.logger = logger.getChild(self.__class__.__name__)
self.packet = SubscribeHeader() self._framecounter = 0
def run(self): def run(self):
while not self.stopped(): while not self.stopped():
try: try:
for nbs in NBS:
sub_packet = SubscribeHeader().to_bytes(nbs, self._framecounter)
self._remote.sock.sendto( self._remote.sock.sendto(
self.packet.header, sub_packet, (self._remote.ip, self._remote.port)
(socket.gethostbyname(self._remote.ip), self._remote.port),
) )
self.packet.framecounter = ( self._framecounter = bump_framecounter(self._framecounter)
int.from_bytes(self.packet.framecounter, 'little') + 1
).to_bytes(4, 'little')
self.wait_until_stopped(10) self.wait_until_stopped(10)
except socket.gaierror as e: except socket.gaierror as e:
self.logger.exception(f'{type(e).__name__}: {e}') self.logger.exception(f'{type(e).__name__}: {e}')
@@ -58,57 +68,46 @@ class Producer(threading.Thread):
self.queue = queue self.queue = queue
self.stop_event = stop_event self.stop_event = stop_event
self.logger = logger.getChild(self.__class__.__name__) self.logger = logger.getChild(self.__class__.__name__)
self.packet_expected = VbanRtPacketHeader()
self._remote.sock.settimeout(self._remote.timeout) self._remote.sock.settimeout(self._remote.timeout)
self._remote._public_packet = self._get_rt() self._remote._public_packets = [None] * (max(NBS) + 1)
_pp = self._get_rt()
self._remote._public_packets[_pp.nbs] = _pp
( (
self._remote.cache['strip_level'], self._remote.cache['strip_level'],
self._remote.cache['bus_level'], self._remote.cache['bus_level'],
) = self._remote._get_levels(self._remote.public_packet) ) = self._remote._get_levels(self._remote.public_packets[NBS.zero])
def _get_rt(self) -> VbanRtPacket: def _get_rt(self) -> VbanRtPacket:
"""Attempt to fetch data packet until a valid one found""" """Attempt to fetch data packet until a valid one found"""
def fget(): while True:
data = None if resp := self._fetch_rt_packet():
while not data: return resp
data = self._fetch_rt_packet()
return data
return fget() def _fetch_rt_packet(self) -> VbanRtPacket | None:
def _fetch_rt_packet(self) -> Optional[VbanRtPacket]:
try: try:
data, _ = self._remote.sock.recvfrom(2048) data, _ = self._remote.sock.recvfrom(2048)
# do we have packet data? if len(data) < HEADER_SIZE:
if len(data) > HEADER_SIZE: return
# is the packet of type VBAN RT response?
if self.packet_expected.header == data[:HEADER_SIZE]: response_header = VbanRtPacketHeader.from_bytes(data[:HEADER_SIZE])
return VbanRtPacket( if (
_kind=self._remote.kind, response_header.format_sr != VBAN_PROTOCOL_SERVICE
_voicemeeterType=data[28:29], or response_header.format_nbc != VBAN_SERVICE_RTPACKET
_reserved=data[29:30], ):
_buffersize=data[30:32], return
_voicemeeterVersion=data[32:36],
_optionBits=data[36:40], match response_header.format_nbs:
_samplerate=data[40:44], case NBS.zero:
_inputLeveldB100=data[44:112], return VbanRtPacketNBS0.from_bytes(
_outputLeveldB100=data[112:240], nbs=NBS.zero, kind=self._remote.kind, data=data
_TransportBit=data[240:244],
_stripState=data[244:276],
_busState=data[276:308],
_stripGaindB100Layer1=data[308:324],
_stripGaindB100Layer2=data[324:340],
_stripGaindB100Layer3=data[340:356],
_stripGaindB100Layer4=data[356:372],
_stripGaindB100Layer5=data[372:388],
_stripGaindB100Layer6=data[388:404],
_stripGaindB100Layer7=data[404:420],
_stripGaindB100Layer8=data[420:436],
_busGaindB100=data[436:452],
_stripLabelUTF8c60=data[452:932],
_busLabelUTF8c60=data[932:1412],
) )
case NBS.one:
return VbanRtPacketNBS1.from_bytes(
nbs=NBS.one, kind=self._remote.kind, data=data
)
return None
except TimeoutError as e: except TimeoutError as e:
self.logger.exception(f'{type(e).__name__}: {e}') self.logger.exception(f'{type(e).__name__}: {e}')
raise VBANCMDConnectionError( raise VBANCMDConnectionError(
@@ -120,14 +119,20 @@ class Producer(threading.Thread):
def run(self): def run(self):
while not self.stopped(): while not self.stopped():
pdirty = ldirty = False
_pp = self._get_rt() _pp = self._get_rt()
pdirty = _pp.pdirty(self._remote.public_packet) match _pp.nbs:
case NBS.zero:
ldirty = _pp.ldirty( ldirty = _pp.ldirty(
self._remote.cache['strip_level'], self._remote.cache['bus_level'] self._remote.cache['strip_level'],
self._remote.cache['bus_level'],
) )
pdirty = _pp.pdirty(self._remote.public_packets[NBS.zero])
case NBS.one:
pdirty = True
if pdirty or ldirty: if pdirty or ldirty:
self._remote._public_packet = _pp self._remote._public_packets[_pp.nbs] = _pp
self._remote._pdirty = pdirty self._remote._pdirty = pdirty
self._remote._ldirty = ldirty self._remote._ldirty = ldirty
@@ -166,15 +171,15 @@ class Updater(threading.Thread):
self._remote.subject.notify(event) self._remote.subject.notify(event)
elif event == 'ldirty' and self._remote.ldirty: elif event == 'ldirty' and self._remote.ldirty:
self._remote._strip_comp, self._remote._bus_comp = ( self._remote._strip_comp, self._remote._bus_comp = (
self._remote._public_packet._strip_comp, self._remote._public_packets[NBS.zero]._strip_comp,
self._remote._public_packet._bus_comp, self._remote._public_packets[NBS.zero]._bus_comp,
) )
( (
self._remote.cache['strip_level'], self._remote.cache['strip_level'],
self._remote.cache['bus_level'], self._remote.cache['bus_level'],
) = ( ) = (
self._remote._public_packet.inputlevels, self._remote._public_packets[NBS.zero].inputlevels,
self._remote._public_packet.outputlevels, self._remote._public_packets[NBS.zero].outputlevels,
) )
self._remote.subject.notify(event) self._remote.subject.notify(event)
self.logger.debug(f'terminating {self.name} thread') self.logger.debug(f'terminating {self.name} thread')