mirror of
https://github.com/onyx-and-iris/vban-cmd-python.git
synced 2026-03-18 07:49:10 +00:00
Compare commits
26 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ba85373f94 | |||
| 22cc980fc2 | |||
|
|
2986d451ad | ||
| 96f0008654 | |||
|
|
6ddead68d0 | ||
| 2794b14cf1 | |||
| c46ca8a8c8 | |||
| f8b56b4a30 | |||
| 09259269d7 | |||
| 242401e294 | |||
| 98ec9b715f | |||
| 5f7b62a0e0 | |||
| d1bcbfed6f | |||
| ab80bbf226 | |||
| ad58852a77 | |||
| 5363584940 | |||
| 9f43ee18d3 | |||
| 3cde874a3c | |||
| 3d01321be3 | |||
| 2dd52a7258 | |||
| 28cbef5ef6 | |||
| 5b3b35fca3 | |||
| 7b3149a1e1 | |||
| 230d9f0eb3 | |||
| c9a505df0a | |||
| 3e3bec6d50 |
@ -548,7 +548,7 @@ You may pass the following optional keyword arguments:
|
|||||||
- `channel`: int=0, channel on which to send the UDP requests.
|
- `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
|
||||||
- `script_ratelimit`: float=0.05, default to 20 script requests per second. This affects vban.sendtext() specifically.
|
- `script_ratelimit`: float | None=None, ratelimit for vban.sendtext() specifically.
|
||||||
- `timeout`: int=5, timeout for socket operations.
|
- `timeout`: int=5, timeout for socket operations.
|
||||||
- `disable_rt_listeners`: boolean=False, set `True` if you don't wish to receive RT packets.
|
- `disable_rt_listeners`: boolean=False, set `True` if you don't wish to receive RT packets.
|
||||||
- You can still send Matrix string requests ending with `?` and receive a response.
|
- You can still send Matrix string requests ending with `?` and receive a response.
|
||||||
|
|||||||
@ -103,7 +103,7 @@ class App(tk.Tk):
|
|||||||
def main():
|
def main():
|
||||||
KIND_ID = 'banana'
|
KIND_ID = 'banana'
|
||||||
conn = {
|
conn = {
|
||||||
'ip': os.environ.get('VBANCMD_IP', 'localhost'),
|
'host': os.environ.get('VBANCMD_HOST', 'localhost'),
|
||||||
'port': int(os.environ.get('VBANCMD_PORT', 6980)),
|
'port': int(os.environ.get('VBANCMD_PORT', 6980)),
|
||||||
'streamname': os.environ.get('VBANCMD_STREAMNAME', 'Command1'),
|
'streamname': os.environ.get('VBANCMD_STREAMNAME', 'Command1'),
|
||||||
}
|
}
|
||||||
|
|||||||
@ -94,7 +94,7 @@ class Observer:
|
|||||||
def main():
|
def main():
|
||||||
KIND_ID = 'potato'
|
KIND_ID = 'potato'
|
||||||
conn = {
|
conn = {
|
||||||
'ip': os.environ.get('VBANCMD_IP', 'localhost'),
|
'host': os.environ.get('VBANCMD_HOST', 'localhost'),
|
||||||
'port': int(os.environ.get('VBANCMD_PORT', 6980)),
|
'port': int(os.environ.get('VBANCMD_PORT', 6980)),
|
||||||
'streamname': os.environ.get('VBANCMD_STREAMNAME', 'Command1'),
|
'streamname': os.environ.get('VBANCMD_STREAMNAME', 'Command1'),
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,7 +25,7 @@ class App:
|
|||||||
def main():
|
def main():
|
||||||
KIND_ID = 'banana'
|
KIND_ID = 'banana'
|
||||||
conn = {
|
conn = {
|
||||||
'ip': os.environ.get('VBANCMD_IP', 'localhost'),
|
'host': os.environ.get('VBANCMD_HOST', 'localhost'),
|
||||||
'port': int(os.environ.get('VBANCMD_PORT', 6980)),
|
'port': int(os.environ.get('VBANCMD_PORT', 6980)),
|
||||||
'streamname': os.environ.get('VBANCMD_STREAMNAME', 'Command1'),
|
'streamname': os.environ.get('VBANCMD_STREAMNAME', 'Command1'),
|
||||||
}
|
}
|
||||||
|
|||||||
42
poetry.lock
generated
42
poetry.lock
generated
@ -1,4 +1,4 @@
|
|||||||
# This file is automatically @generated by Poetry 2.0.1 and should not be changed by hand.
|
# This file is automatically @generated by Poetry 2.2.1 and should not be changed by hand.
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cachetools"
|
name = "cachetools"
|
||||||
@ -55,7 +55,7 @@ description = "Backport of PEP 654 (exception groups)"
|
|||||||
optional = false
|
optional = false
|
||||||
python-versions = ">=3.7"
|
python-versions = ">=3.7"
|
||||||
groups = ["dev"]
|
groups = ["dev"]
|
||||||
markers = "python_version < \"3.11\""
|
markers = "python_version == \"3.10\""
|
||||||
files = [
|
files = [
|
||||||
{file = "exceptiongroup-1.2.2-py3-none-any.whl", hash = "sha256:3111b9d131c238bec2f8f516e123e14ba243563fb135d3fe885990585aa7795b"},
|
{file = "exceptiongroup-1.2.2-py3-none-any.whl", hash = "sha256:3111b9d131c238bec2f8f516e123e14ba243563fb135d3fe885990585aa7795b"},
|
||||||
{file = "exceptiongroup-1.2.2.tar.gz", hash = "sha256:47c2edf7c6738fafb49fd34290706d1a1a2f4d1c6df275526b62cbb4aa5393cc"},
|
{file = "exceptiongroup-1.2.2.tar.gz", hash = "sha256:47c2edf7c6738fafb49fd34290706d1a1a2f4d1c6df275526b62cbb4aa5393cc"},
|
||||||
@ -66,21 +66,16 @@ test = ["pytest (>=6)"]
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "filelock"
|
name = "filelock"
|
||||||
version = "3.16.1"
|
version = "3.20.3"
|
||||||
description = "A platform independent file lock."
|
description = "A platform independent file lock."
|
||||||
optional = false
|
optional = false
|
||||||
python-versions = ">=3.8"
|
python-versions = ">=3.10"
|
||||||
groups = ["dev"]
|
groups = ["dev"]
|
||||||
files = [
|
files = [
|
||||||
{file = "filelock-3.16.1-py3-none-any.whl", hash = "sha256:2082e5703d51fbf98ea75855d9d5527e33d8ff23099bec374a134febee6946b0"},
|
{file = "filelock-3.20.3-py3-none-any.whl", hash = "sha256:4b0dda527ee31078689fc205ec4f1c1bf7d56cf88b6dc9426c4f230e46c2dce1"},
|
||||||
{file = "filelock-3.16.1.tar.gz", hash = "sha256:c249fbfcd5db47e5e2d6d62198e565475ee65e4831e2561c8e313fa7eb961435"},
|
{file = "filelock-3.20.3.tar.gz", hash = "sha256:18c57ee915c7ec61cff0ecf7f0f869936c7c30191bb0cf406f1341778d0834e1"},
|
||||||
]
|
]
|
||||||
|
|
||||||
[package.extras]
|
|
||||||
docs = ["furo (>=2024.8.6)", "sphinx (>=8.0.2)", "sphinx-autodoc-typehints (>=2.4.1)"]
|
|
||||||
testing = ["covdefaults (>=2.3)", "coverage (>=7.6.1)", "diff-cover (>=9.2)", "pytest (>=8.3.3)", "pytest-asyncio (>=0.24)", "pytest-cov (>=5)", "pytest-mock (>=3.14)", "pytest-timeout (>=2.3.1)", "virtualenv (>=20.26.4)"]
|
|
||||||
typing = ["typing-extensions (>=4.12.2)"]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iniconfig"
|
name = "iniconfig"
|
||||||
version = "2.0.0"
|
version = "2.0.0"
|
||||||
@ -243,7 +238,7 @@ description = "A lil' TOML parser"
|
|||||||
optional = false
|
optional = false
|
||||||
python-versions = ">=3.8"
|
python-versions = ">=3.8"
|
||||||
groups = ["main", "dev"]
|
groups = ["main", "dev"]
|
||||||
markers = "python_version < \"3.11\""
|
markers = "python_version == \"3.10\""
|
||||||
files = [
|
files = [
|
||||||
{file = "tomli-2.2.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:678e4fa69e4575eb77d103de3df8a895e1591b48e740211bd1067378c69e8249"},
|
{file = "tomli-2.2.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:678e4fa69e4575eb77d103de3df8a895e1591b48e740211bd1067378c69e8249"},
|
||||||
{file = "tomli-2.2.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:023aa114dd824ade0100497eb2318602af309e5a55595f76b626d6d9f3b7b0a6"},
|
{file = "tomli-2.2.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:023aa114dd824ade0100497eb2318602af309e5a55595f76b626d6d9f3b7b0a6"},
|
||||||
@ -309,37 +304,38 @@ test = ["devpi-process (>=1.0.2)", "pytest (>=8.3.3)", "pytest-mock (>=3.14)"]
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "typing-extensions"
|
name = "typing-extensions"
|
||||||
version = "4.12.2"
|
version = "4.15.0"
|
||||||
description = "Backported and Experimental Type Hints for Python 3.8+"
|
description = "Backported and Experimental Type Hints for Python 3.9+"
|
||||||
optional = false
|
optional = false
|
||||||
python-versions = ">=3.8"
|
python-versions = ">=3.9"
|
||||||
groups = ["dev"]
|
groups = ["dev"]
|
||||||
markers = "python_version < \"3.11\""
|
markers = "python_version == \"3.10\""
|
||||||
files = [
|
files = [
|
||||||
{file = "typing_extensions-4.12.2-py3-none-any.whl", hash = "sha256:04e5ca0351e0f3f85c6853954072df659d0d13fac324d0072316b67d7794700d"},
|
{file = "typing_extensions-4.15.0-py3-none-any.whl", hash = "sha256:f0fa19c6845758ab08074a0cfa8b7aecb71c999ca73d62883bc25cc018c4e548"},
|
||||||
{file = "typing_extensions-4.12.2.tar.gz", hash = "sha256:1a7ead55c7e559dd4dee8856e3a88b41225abfe1ce8df57b7c13915fe121ffb8"},
|
{file = "typing_extensions-4.15.0.tar.gz", hash = "sha256:0cea48d173cc12fa28ecabc3b837ea3cf6f38c6d1136f85cbaaf598984861466"},
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "virtualenv"
|
name = "virtualenv"
|
||||||
version = "20.29.0"
|
version = "20.36.1"
|
||||||
description = "Virtual Python Environment builder"
|
description = "Virtual Python Environment builder"
|
||||||
optional = false
|
optional = false
|
||||||
python-versions = ">=3.8"
|
python-versions = ">=3.8"
|
||||||
groups = ["dev"]
|
groups = ["dev"]
|
||||||
files = [
|
files = [
|
||||||
{file = "virtualenv-20.29.0-py3-none-any.whl", hash = "sha256:c12311863497992dc4b8644f8ea82d3b35bb7ef8ee82e6630d76d0197c39baf9"},
|
{file = "virtualenv-20.36.1-py3-none-any.whl", hash = "sha256:575a8d6b124ef88f6f51d56d656132389f961062a9177016a50e4f507bbcc19f"},
|
||||||
{file = "virtualenv-20.29.0.tar.gz", hash = "sha256:6345e1ff19d4b1296954cee076baaf58ff2a12a84a338c62b02eda39f20aa982"},
|
{file = "virtualenv-20.36.1.tar.gz", hash = "sha256:8befb5c81842c641f8ee658481e42641c68b5eab3521d8e092d18320902466ba"},
|
||||||
]
|
]
|
||||||
|
|
||||||
[package.dependencies]
|
[package.dependencies]
|
||||||
distlib = ">=0.3.7,<1"
|
distlib = ">=0.3.7,<1"
|
||||||
filelock = ">=3.12.2,<4"
|
filelock = {version = ">=3.20.1,<4", markers = "python_version >= \"3.10\""}
|
||||||
platformdirs = ">=3.9.1,<5"
|
platformdirs = ">=3.9.1,<5"
|
||||||
|
typing-extensions = {version = ">=4.13.2", markers = "python_version < \"3.11\""}
|
||||||
|
|
||||||
[package.extras]
|
[package.extras]
|
||||||
docs = ["furo (>=2023.7.26)", "proselint (>=0.13)", "sphinx (>=7.1.2,!=7.3)", "sphinx-argparse (>=0.4)", "sphinxcontrib-towncrier (>=0.2.1a0)", "towncrier (>=23.6)"]
|
docs = ["furo (>=2023.7.26)", "proselint (>=0.13)", "sphinx (>=7.1.2,!=7.3)", "sphinx-argparse (>=0.4)", "sphinxcontrib-towncrier (>=0.2.1a0)", "towncrier (>=23.6)"]
|
||||||
test = ["covdefaults (>=2.3)", "coverage (>=7.2.7)", "coverage-enable-subprocess (>=1)", "flaky (>=3.7)", "packaging (>=23.1)", "pytest (>=7.4)", "pytest-env (>=0.8.2)", "pytest-freezer (>=0.4.8)", "pytest-mock (>=3.11.1)", "pytest-randomly (>=3.12)", "pytest-timeout (>=2.1)", "setuptools (>=68)", "time-machine (>=2.10)"]
|
test = ["covdefaults (>=2.3)", "coverage (>=7.2.7)", "coverage-enable-subprocess (>=1)", "flaky (>=3.7)", "packaging (>=23.1)", "pytest (>=7.4)", "pytest-env (>=0.8.2)", "pytest-freezer (>=0.4.8) ; platform_python_implementation == \"PyPy\" or platform_python_implementation == \"GraalVM\" or platform_python_implementation == \"CPython\" and sys_platform == \"win32\" and python_version >= \"3.13\"", "pytest-mock (>=3.11.1)", "pytest-randomly (>=3.12)", "pytest-timeout (>=2.1)", "setuptools (>=68)", "time-machine (>=2.10) ; platform_python_implementation == \"CPython\""]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "virtualenv-pyenv"
|
name = "virtualenv-pyenv"
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "vban-cmd"
|
name = "vban-cmd"
|
||||||
version = "2.9.2"
|
version = "2.10.3"
|
||||||
description = "Python interface for the VBAN RT Packet Service (Sendtext)"
|
description = "Python interface for the VBAN RT Packet Service (Sendtext)"
|
||||||
authors = [{ name = "Onyx and Iris", email = "code@onyxandiris.online" }]
|
authors = [{ name = "Onyx and Iris", email = "code@onyxandiris.online" }]
|
||||||
license = { text = "MIT" }
|
license = { text = "MIT" }
|
||||||
|
|||||||
@ -11,7 +11,7 @@ from vban_cmd.kinds import request_kind_map as kindmap
|
|||||||
KIND_ID = os.environ.get('KIND', 'potato')
|
KIND_ID = os.environ.get('KIND', 'potato')
|
||||||
|
|
||||||
opts = {
|
opts = {
|
||||||
'ip': os.getenv('VBANCMD_IP', 'localhost'),
|
'host': os.getenv('VBANCMD_HOST', 'localhost'),
|
||||||
'streamname': os.getenv('VBANCMD_STREAMNAME', 'Command1'),
|
'streamname': os.getenv('VBANCMD_STREAMNAME', 'Command1'),
|
||||||
'port': int(os.getenv('VBANCMD_PORT', 6980)),
|
'port': int(os.getenv('VBANCMD_PORT', 6980)),
|
||||||
}
|
}
|
||||||
|
|||||||
68
uv.lock
generated
68
uv.lock
generated
@ -1,68 +0,0 @@
|
|||||||
version = 1
|
|
||||||
revision = 3
|
|
||||||
requires-python = ">=3.10"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "tomli"
|
|
||||||
version = "2.4.0"
|
|
||||||
source = { registry = "https://pypi.org/simple" }
|
|
||||||
sdist = { url = "https://files.pythonhosted.org/packages/82/30/31573e9457673ab10aa432461bee537ce6cef177667deca369efb79df071/tomli-2.4.0.tar.gz", hash = "sha256:aa89c3f6c277dd275d8e243ad24f3b5e701491a860d5121f2cdd399fbb31fc9c", size = 17477, upload-time = "2026-01-11T11:22:38.165Z" }
|
|
||||||
wheels = [
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/3c/d9/3dc2289e1f3b32eb19b9785b6a006b28ee99acb37d1d47f78d4c10e28bf8/tomli-2.4.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:b5ef256a3fd497d4973c11bf142e9ed78b150d36f5773f1ca6088c230ffc5867", size = 153663, upload-time = "2026-01-11T11:21:45.27Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/51/32/ef9f6845e6b9ca392cd3f64f9ec185cc6f09f0a2df3db08cbe8809d1d435/tomli-2.4.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:5572e41282d5268eb09a697c89a7bee84fae66511f87533a6f88bd2f7b652da9", size = 148469, upload-time = "2026-01-11T11:21:46.873Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/d6/c2/506e44cce89a8b1b1e047d64bd495c22c9f71f21e05f380f1a950dd9c217/tomli-2.4.0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:551e321c6ba03b55676970b47cb1b73f14a0a4dce6a3e1a9458fd6d921d72e95", size = 236039, upload-time = "2026-01-11T11:21:48.503Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/b3/40/e1b65986dbc861b7e986e8ec394598187fa8aee85b1650b01dd925ca0be8/tomli-2.4.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:5e3f639a7a8f10069d0e15408c0b96a2a828cfdec6fca05296ebcdcc28ca7c76", size = 243007, upload-time = "2026-01-11T11:21:49.456Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/9c/6f/6e39ce66b58a5b7ae572a0f4352ff40c71e8573633deda43f6a379d56b3e/tomli-2.4.0-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:1b168f2731796b045128c45982d3a4874057626da0e2ef1fdd722848b741361d", size = 240875, upload-time = "2026-01-11T11:21:50.755Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/aa/ad/cb089cb190487caa80204d503c7fd0f4d443f90b95cf4ef5cf5aa0f439b0/tomli-2.4.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:133e93646ec4300d651839d382d63edff11d8978be23da4cc106f5a18b7d0576", size = 246271, upload-time = "2026-01-11T11:21:51.81Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/0b/63/69125220e47fd7a3a27fd0de0c6398c89432fec41bc739823bcc66506af6/tomli-2.4.0-cp311-cp311-win32.whl", hash = "sha256:b6c78bdf37764092d369722d9946cb65b8767bfa4110f902a1b2542d8d173c8a", size = 96770, upload-time = "2026-01-11T11:21:52.647Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/1e/0d/a22bb6c83f83386b0008425a6cd1fa1c14b5f3dd4bad05e98cf3dbbf4a64/tomli-2.4.0-cp311-cp311-win_amd64.whl", hash = "sha256:d3d1654e11d724760cdb37a3d7691f0be9db5fbdaef59c9f532aabf87006dbaa", size = 107626, upload-time = "2026-01-11T11:21:53.459Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/2f/6d/77be674a3485e75cacbf2ddba2b146911477bd887dda9d8c9dfb2f15e871/tomli-2.4.0-cp311-cp311-win_arm64.whl", hash = "sha256:cae9c19ed12d4e8f3ebf46d1a75090e4c0dc16271c5bce1c833ac168f08fb614", size = 94842, upload-time = "2026-01-11T11:21:54.831Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/3c/43/7389a1869f2f26dba52404e1ef13b4784b6b37dac93bac53457e3ff24ca3/tomli-2.4.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:920b1de295e72887bafa3ad9f7a792f811847d57ea6b1215154030cf131f16b1", size = 154894, upload-time = "2026-01-11T11:21:56.07Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/e9/05/2f9bf110b5294132b2edf13fe6ca6ae456204f3d749f623307cbb7a946f2/tomli-2.4.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:7d6d9a4aee98fac3eab4952ad1d73aee87359452d1c086b5ceb43ed02ddb16b8", size = 149053, upload-time = "2026-01-11T11:21:57.467Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/e8/41/1eda3ca1abc6f6154a8db4d714a4d35c4ad90adc0bcf700657291593fbf3/tomli-2.4.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:36b9d05b51e65b254ea6c2585b59d2c4cb91c8a3d91d0ed0f17591a29aaea54a", size = 243481, upload-time = "2026-01-11T11:21:58.661Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/d2/6d/02ff5ab6c8868b41e7d4b987ce2b5f6a51d3335a70aa144edd999e055a01/tomli-2.4.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:1c8a885b370751837c029ef9bc014f27d80840e48bac415f3412e6593bbc18c1", size = 251720, upload-time = "2026-01-11T11:22:00.178Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/7b/57/0405c59a909c45d5b6f146107c6d997825aa87568b042042f7a9c0afed34/tomli-2.4.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:8768715ffc41f0008abe25d808c20c3d990f42b6e2e58305d5da280ae7d1fa3b", size = 247014, upload-time = "2026-01-11T11:22:01.238Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/2c/0e/2e37568edd944b4165735687cbaf2fe3648129e440c26d02223672ee0630/tomli-2.4.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:7b438885858efd5be02a9a133caf5812b8776ee0c969fea02c45e8e3f296ba51", size = 251820, upload-time = "2026-01-11T11:22:02.727Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/5a/1c/ee3b707fdac82aeeb92d1a113f803cf6d0f37bdca0849cb489553e1f417a/tomli-2.4.0-cp312-cp312-win32.whl", hash = "sha256:0408e3de5ec77cc7f81960c362543cbbd91ef883e3138e81b729fc3eea5b9729", size = 97712, upload-time = "2026-01-11T11:22:03.777Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/69/13/c07a9177d0b3bab7913299b9278845fc6eaaca14a02667c6be0b0a2270c8/tomli-2.4.0-cp312-cp312-win_amd64.whl", hash = "sha256:685306e2cc7da35be4ee914fd34ab801a6acacb061b6a7abca922aaf9ad368da", size = 108296, upload-time = "2026-01-11T11:22:04.86Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/18/27/e267a60bbeeee343bcc279bb9e8fbed0cbe224bc7b2a3dc2975f22809a09/tomli-2.4.0-cp312-cp312-win_arm64.whl", hash = "sha256:5aa48d7c2356055feef06a43611fc401a07337d5b006be13a30f6c58f869e3c3", size = 94553, upload-time = "2026-01-11T11:22:05.854Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/34/91/7f65f9809f2936e1f4ce6268ae1903074563603b2a2bd969ebbda802744f/tomli-2.4.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:84d081fbc252d1b6a982e1870660e7330fb8f90f676f6e78b052ad4e64714bf0", size = 154915, upload-time = "2026-01-11T11:22:06.703Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/20/aa/64dd73a5a849c2e8f216b755599c511badde80e91e9bc2271baa7b2cdbb1/tomli-2.4.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:9a08144fa4cba33db5255f9b74f0b89888622109bd2776148f2597447f92a94e", size = 149038, upload-time = "2026-01-11T11:22:07.56Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/9e/8a/6d38870bd3d52c8d1505ce054469a73f73a0fe62c0eaf5dddf61447e32fa/tomli-2.4.0-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:c73add4bb52a206fd0c0723432db123c0c75c280cbd67174dd9d2db228ebb1b4", size = 242245, upload-time = "2026-01-11T11:22:08.344Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/59/bb/8002fadefb64ab2669e5b977df3f5e444febea60e717e755b38bb7c41029/tomli-2.4.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:1fb2945cbe303b1419e2706e711b7113da57b7db31ee378d08712d678a34e51e", size = 250335, upload-time = "2026-01-11T11:22:09.951Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/a5/3d/4cdb6f791682b2ea916af2de96121b3cb1284d7c203d97d92d6003e91c8d/tomli-2.4.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:bbb1b10aa643d973366dc2cb1ad94f99c1726a02343d43cbc011edbfac579e7c", size = 245962, upload-time = "2026-01-11T11:22:11.27Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/f2/4a/5f25789f9a460bd858ba9756ff52d0830d825b458e13f754952dd15fb7bb/tomli-2.4.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:4cbcb367d44a1f0c2be408758b43e1ffb5308abe0ea222897d6bfc8e8281ef2f", size = 250396, upload-time = "2026-01-11T11:22:12.325Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/aa/2f/b73a36fea58dfa08e8b3a268750e6853a6aac2a349241a905ebd86f3047a/tomli-2.4.0-cp313-cp313-win32.whl", hash = "sha256:7d49c66a7d5e56ac959cb6fc583aff0651094ec071ba9ad43df785abc2320d86", size = 97530, upload-time = "2026-01-11T11:22:13.865Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/3b/af/ca18c134b5d75de7e8dc551c5234eaba2e8e951f6b30139599b53de9c187/tomli-2.4.0-cp313-cp313-win_amd64.whl", hash = "sha256:3cf226acb51d8f1c394c1b310e0e0e61fecdd7adcb78d01e294ac297dd2e7f87", size = 108227, upload-time = "2026-01-11T11:22:15.224Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/22/c3/b386b832f209fee8073c8138ec50f27b4460db2fdae9ffe022df89a57f9b/tomli-2.4.0-cp313-cp313-win_arm64.whl", hash = "sha256:d20b797a5c1ad80c516e41bc1fb0443ddb5006e9aaa7bda2d71978346aeb9132", size = 94748, upload-time = "2026-01-11T11:22:16.009Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/f3/c4/84047a97eb1004418bc10bdbcfebda209fca6338002eba2dc27cc6d13563/tomli-2.4.0-cp314-cp314-macosx_10_15_x86_64.whl", hash = "sha256:26ab906a1eb794cd4e103691daa23d95c6919cc2fa9160000ac02370cc9dd3f6", size = 154725, upload-time = "2026-01-11T11:22:17.269Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/a8/5d/d39038e646060b9d76274078cddf146ced86dc2b9e8bbf737ad5983609a0/tomli-2.4.0-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:20cedb4ee43278bc4f2fee6cb50daec836959aadaf948db5172e776dd3d993fc", size = 148901, upload-time = "2026-01-11T11:22:18.287Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/73/e5/383be1724cb30f4ce44983d249645684a48c435e1cd4f8b5cded8a816d3c/tomli-2.4.0-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:39b0b5d1b6dd03684b3fb276407ebed7090bbec989fa55838c98560c01113b66", size = 243375, upload-time = "2026-01-11T11:22:19.154Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/31/f0/bea80c17971c8d16d3cc109dc3585b0f2ce1036b5f4a8a183789023574f2/tomli-2.4.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:a26d7ff68dfdb9f87a016ecfd1e1c2bacbe3108f4e0f8bcd2228ef9a766c787d", size = 250639, upload-time = "2026-01-11T11:22:20.168Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/2c/8f/2853c36abbb7608e3f945d8a74e32ed3a74ee3a1f468f1ffc7d1cb3abba6/tomli-2.4.0-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:20ffd184fb1df76a66e34bd1b36b4a4641bd2b82954befa32fe8163e79f1a702", size = 246897, upload-time = "2026-01-11T11:22:21.544Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/49/f0/6c05e3196ed5337b9fe7ea003e95fd3819a840b7a0f2bf5a408ef1dad8ed/tomli-2.4.0-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:75c2f8bbddf170e8effc98f5e9084a8751f8174ea6ccf4fca5398436e0320bc8", size = 254697, upload-time = "2026-01-11T11:22:23.058Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/f3/f5/2922ef29c9f2951883525def7429967fc4d8208494e5ab524234f06b688b/tomli-2.4.0-cp314-cp314-win32.whl", hash = "sha256:31d556d079d72db7c584c0627ff3a24c5d3fb4f730221d3444f3efb1b2514776", size = 98567, upload-time = "2026-01-11T11:22:24.033Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/7b/31/22b52e2e06dd2a5fdbc3ee73226d763b184ff21fc24e20316a44ccc4d96b/tomli-2.4.0-cp314-cp314-win_amd64.whl", hash = "sha256:43e685b9b2341681907759cf3a04e14d7104b3580f808cfde1dfdb60ada85475", size = 108556, upload-time = "2026-01-11T11:22:25.378Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/48/3d/5058dff3255a3d01b705413f64f4306a141a8fd7a251e5a495e3f192a998/tomli-2.4.0-cp314-cp314-win_arm64.whl", hash = "sha256:3d895d56bd3f82ddd6faaff993c275efc2ff38e52322ea264122d72729dca2b2", size = 96014, upload-time = "2026-01-11T11:22:26.138Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/b8/4e/75dab8586e268424202d3a1997ef6014919c941b50642a1682df43204c22/tomli-2.4.0-cp314-cp314t-macosx_10_15_x86_64.whl", hash = "sha256:5b5807f3999fb66776dbce568cc9a828544244a8eb84b84b9bafc080c99597b9", size = 163339, upload-time = "2026-01-11T11:22:27.143Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/06/e3/b904d9ab1016829a776d97f163f183a48be6a4deb87304d1e0116a349519/tomli-2.4.0-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:c084ad935abe686bd9c898e62a02a19abfc9760b5a79bc29644463eaf2840cb0", size = 159490, upload-time = "2026-01-11T11:22:28.399Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/e3/5a/fc3622c8b1ad823e8ea98a35e3c632ee316d48f66f80f9708ceb4f2a0322/tomli-2.4.0-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:0f2e3955efea4d1cfbcb87bc321e00dc08d2bcb737fd1d5e398af111d86db5df", size = 269398, upload-time = "2026-01-11T11:22:29.345Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/fd/33/62bd6152c8bdd4c305ad9faca48f51d3acb2df1f8791b1477d46ff86e7f8/tomli-2.4.0-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:0e0fe8a0b8312acf3a88077a0802565cb09ee34107813bba1c7cd591fa6cfc8d", size = 276515, upload-time = "2026-01-11T11:22:30.327Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/4b/ff/ae53619499f5235ee4211e62a8d7982ba9e439a0fb4f2f351a93d67c1dd2/tomli-2.4.0-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:413540dce94673591859c4c6f794dfeaa845e98bf35d72ed59636f869ef9f86f", size = 273806, upload-time = "2026-01-11T11:22:32.56Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/47/71/cbca7787fa68d4d0a9f7072821980b39fbb1b6faeb5f5cf02f4a5559fa28/tomli-2.4.0-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:0dc56fef0e2c1c470aeac5b6ca8cc7b640bb93e92d9803ddaf9ea03e198f5b0b", size = 281340, upload-time = "2026-01-11T11:22:33.505Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/f5/00/d595c120963ad42474cf6ee7771ad0d0e8a49d0f01e29576ee9195d9ecdf/tomli-2.4.0-cp314-cp314t-win32.whl", hash = "sha256:d878f2a6707cc9d53a1be1414bbb419e629c3d6e67f69230217bb663e76b5087", size = 108106, upload-time = "2026-01-11T11:22:34.451Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/de/69/9aa0c6a505c2f80e519b43764f8b4ba93b5a0bbd2d9a9de6e2b24271b9a5/tomli-2.4.0-cp314-cp314t-win_amd64.whl", hash = "sha256:2add28aacc7425117ff6364fe9e06a183bb0251b03f986df0e78e974047571fd", size = 120504, upload-time = "2026-01-11T11:22:35.764Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/b3/9f/f1668c281c58cfae01482f7114a4b88d345e4c140386241a1a24dcc9e7bc/tomli-2.4.0-cp314-cp314t-win_arm64.whl", hash = "sha256:2b1e3b80e1d5e52e40e9b924ec43d81570f0e7d09d11081b797bc4692765a3d4", size = 99561, upload-time = "2026-01-11T11:22:36.624Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/23/d1/136eb2cb77520a31e1f64cbae9d33ec6df0d78bdf4160398e86eec8a8754/tomli-2.4.0-py3-none-any.whl", hash = "sha256:1f776e7d669ebceb01dee46484485f43a4048746235e683bcdffacdf1fb4785a", size = 14477, upload-time = "2026-01-11T11:22:37.446Z" },
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "vban-cmd"
|
|
||||||
version = "2.9.1"
|
|
||||||
source = { editable = "." }
|
|
||||||
dependencies = [
|
|
||||||
{ name = "tomli", marker = "python_full_version < '3.11'" },
|
|
||||||
]
|
|
||||||
|
|
||||||
[package.metadata]
|
|
||||||
requires-dist = [{ name = "tomli", marker = "python_full_version < '3.11'", specifier = ">=2.0.1,<3.0" }]
|
|
||||||
@ -1,6 +1,18 @@
|
|||||||
|
from .packet.enums import ServiceTypes, SubProtocols
|
||||||
|
|
||||||
|
|
||||||
class VBANCMDError(Exception):
|
class VBANCMDError(Exception):
|
||||||
"""Base VBANCMD Exception class."""
|
"""Base VBANCMD Exception class."""
|
||||||
|
|
||||||
|
|
||||||
class VBANCMDConnectionError(VBANCMDError):
|
class VBANCMDConnectionError(VBANCMDError):
|
||||||
"""Exception raised when connection/timeout errors occur"""
|
"""Exception raised when connection/timeout errors occur"""
|
||||||
|
|
||||||
|
|
||||||
|
class VBANCMDPacketError(VBANCMDError):
|
||||||
|
"""Exception raised when packet parsing errors occur"""
|
||||||
|
|
||||||
|
def __init__(self, message: str, protocol: SubProtocols, type_: ServiceTypes):
|
||||||
|
super().__init__(message)
|
||||||
|
self.protocol = protocol
|
||||||
|
self.type = type_
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
import abc
|
|
||||||
import logging
|
import logging
|
||||||
from enum import IntEnum
|
from enum import IntEnum
|
||||||
from functools import cached_property
|
from functools import cached_property
|
||||||
@ -89,7 +88,7 @@ class FactoryBase(VbanCmd):
|
|||||||
'streamname': 'Command1',
|
'streamname': 'Command1',
|
||||||
'bps': 256000,
|
'bps': 256000,
|
||||||
'channel': 0,
|
'channel': 0,
|
||||||
'script_ratelimit': 0.05, # 20 commands per second, to avoid overloading Voicemeeter
|
'script_ratelimit': None, # if None or 0, no rate limit applied to script commands
|
||||||
'timeout': 5, # timeout on socket operations, in seconds
|
'timeout': 5, # timeout on socket operations, in seconds
|
||||||
'disable_rt_listeners': False,
|
'disable_rt_listeners': False,
|
||||||
'sync': False,
|
'sync': False,
|
||||||
@ -122,11 +121,6 @@ class FactoryBase(VbanCmd):
|
|||||||
+ f"({self.kind}, ip='{self.ip}', port={self.port}, streamname='{self.streamname}')"
|
+ f"({self.kind}, ip='{self.ip}', port={self.port}, streamname='{self.streamname}')"
|
||||||
)
|
)
|
||||||
|
|
||||||
@property
|
|
||||||
@abc.abstractmethod
|
|
||||||
def steps(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def configs(self):
|
def configs(self):
|
||||||
self._configs = configs(self.kind.name)
|
self._configs = configs(self.kind.name)
|
||||||
|
|||||||
@ -1,82 +1,9 @@
|
|||||||
import abc
|
import abc
|
||||||
import logging
|
import logging
|
||||||
from dataclasses import dataclass
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
|
||||||
class Modes:
|
|
||||||
"""Channel Modes"""
|
|
||||||
|
|
||||||
_mute: hex = 0x00000001
|
|
||||||
_solo: hex = 0x00000002
|
|
||||||
_mono: hex = 0x00000004
|
|
||||||
_mc: hex = 0x00000008
|
|
||||||
|
|
||||||
_amix: hex = 0x00000010
|
|
||||||
_repeat: hex = 0x00000020
|
|
||||||
_bmix: hex = 0x00000030
|
|
||||||
_composite: hex = 0x00000040
|
|
||||||
_tvmix: hex = 0x00000050
|
|
||||||
_upmix21: hex = 0x00000060
|
|
||||||
_upmix41: hex = 0x00000070
|
|
||||||
_upmix61: hex = 0x00000080
|
|
||||||
_centeronly: hex = 0x00000090
|
|
||||||
_lfeonly: hex = 0x000000A0
|
|
||||||
_rearonly: hex = 0x000000B0
|
|
||||||
|
|
||||||
_mask: hex = 0x000000F0
|
|
||||||
|
|
||||||
_on: hex = 0x00000100 # eq.on
|
|
||||||
_cross: hex = 0x00000200
|
|
||||||
_ab: hex = 0x00000800 # eq.ab
|
|
||||||
|
|
||||||
_busa: hex = 0x00001000
|
|
||||||
_busa1: hex = 0x00001000
|
|
||||||
_busa2: hex = 0x00002000
|
|
||||||
_busa3: hex = 0x00004000
|
|
||||||
_busa4: hex = 0x00008000
|
|
||||||
_busa5: hex = 0x00080000
|
|
||||||
|
|
||||||
_busb: hex = 0x00010000
|
|
||||||
_busb1: hex = 0x00010000
|
|
||||||
_busb2: hex = 0x00020000
|
|
||||||
_busb3: hex = 0x00040000
|
|
||||||
|
|
||||||
_pan0: hex = 0x00000000
|
|
||||||
_pancolor: hex = 0x00100000
|
|
||||||
_panmod: hex = 0x00200000
|
|
||||||
_panmask: hex = 0x00F00000
|
|
||||||
|
|
||||||
_postfx_r: hex = 0x01000000
|
|
||||||
_postfx_d: hex = 0x02000000
|
|
||||||
_postfx1: hex = 0x04000000
|
|
||||||
_postfx2: hex = 0x08000000
|
|
||||||
|
|
||||||
_sel: hex = 0x10000000
|
|
||||||
_monitor: hex = 0x20000000
|
|
||||||
|
|
||||||
@property
|
|
||||||
def modevals(self):
|
|
||||||
return (
|
|
||||||
val
|
|
||||||
for val in [
|
|
||||||
self._amix,
|
|
||||||
self._repeat,
|
|
||||||
self._bmix,
|
|
||||||
self._composite,
|
|
||||||
self._tvmix,
|
|
||||||
self._upmix21,
|
|
||||||
self._upmix41,
|
|
||||||
self._upmix61,
|
|
||||||
self._centeronly,
|
|
||||||
self._lfeonly,
|
|
||||||
self._rearonly,
|
|
||||||
]
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class IRemote(abc.ABC):
|
class IRemote(abc.ABC):
|
||||||
"""
|
"""
|
||||||
Common interface between base class and extended (higher) classes
|
Common interface between base class and extended (higher) classes
|
||||||
@ -88,7 +15,6 @@ class IRemote(abc.ABC):
|
|||||||
self._remote = remote
|
self._remote = remote
|
||||||
self.index = index
|
self.index = index
|
||||||
self.logger = logger.getChild(self.__class__.__name__)
|
self.logger = logger.getChild(self.__class__.__name__)
|
||||||
self._modes = Modes()
|
|
||||||
|
|
||||||
def getter(self, param):
|
def getter(self, param):
|
||||||
cmd = self._cmd(param)
|
cmd = self._cmd(param)
|
||||||
@ -122,26 +48,18 @@ class IRemote(abc.ABC):
|
|||||||
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."""
|
||||||
|
|
||||||
script = ''
|
|
||||||
|
|
||||||
def fget(attr, val):
|
def fget(attr, val):
|
||||||
if attr == 'mode':
|
if attr == 'mode':
|
||||||
return (f'mode.{val}', 1)
|
return (getattr(self, attr), val, 1)
|
||||||
elif attr == 'knob':
|
return (self, attr, val)
|
||||||
return ('', val)
|
|
||||||
return (attr, val)
|
|
||||||
|
|
||||||
for attr, val in data.items():
|
for attr, val in data.items():
|
||||||
if not isinstance(val, dict):
|
if not isinstance(val, dict):
|
||||||
if attr in dir(self): # avoid calling getattr (with hasattr)
|
if attr in dir(self): # avoid calling getattr (with hasattr)
|
||||||
attr, val = fget(attr, val)
|
target, attr, val = fget(attr, val)
|
||||||
if isinstance(val, bool):
|
setattr(target, attr, val)
|
||||||
val = 1 if val else 0
|
else:
|
||||||
|
self.logger.error(f'invalid attribute {attr} for {self}')
|
||||||
self._remote.cache[self._cmd(attr)] = val
|
|
||||||
script += f'{self._cmd(attr)}={val};'
|
|
||||||
else:
|
else:
|
||||||
target = getattr(self, attr)
|
target = getattr(self, attr)
|
||||||
target.apply(val)
|
target.apply(val)
|
||||||
|
|
||||||
self._remote.sendtext(script)
|
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
from .enums import NBS, BusModes
|
from .enums import NBS, BusModes
|
||||||
|
from .packet.enums import ChannelModes
|
||||||
from .util import cache_bool, cache_float, cache_int, cache_string
|
from .util import cache_bool, cache_float, cache_int, cache_string
|
||||||
|
|
||||||
|
|
||||||
@ -27,7 +28,7 @@ def channel_bool_prop(param):
|
|||||||
elif param.lower() == 'mc':
|
elif param.lower() == 'mc':
|
||||||
return channel_state.mc
|
return channel_state.mc
|
||||||
else:
|
else:
|
||||||
return channel_state.get_mode(getattr(self._modes, f'_{param.lower()}'))
|
return channel_state.get_mode(getattr(ChannelModes, param.upper()).value)
|
||||||
|
|
||||||
def fset(self, val):
|
def fset(self, val):
|
||||||
self.setter(param, 1 if val else 0)
|
self.setter(param, 1 if val else 0)
|
||||||
@ -55,7 +56,9 @@ def channel_int_prop(param):
|
|||||||
bit_9 = (channel_state._state >> 9) & 1
|
bit_9 = (channel_state._state >> 9) & 1
|
||||||
return (bit_9 << 1) | bit_2
|
return (bit_9 << 1) | bit_2
|
||||||
else:
|
else:
|
||||||
return channel_state.get_mode_int(getattr(self._modes, f'_{param.lower()}'))
|
return channel_state.get_mode_int(
|
||||||
|
getattr(ChannelModes, param.upper()).value
|
||||||
|
)
|
||||||
|
|
||||||
def fset(self, val):
|
def fset(self, val):
|
||||||
self.setter(param, val)
|
self.setter(param, val)
|
||||||
@ -89,7 +92,7 @@ def strip_output_prop(param):
|
|||||||
|
|
||||||
strip_state = self.public_packets[NBS.zero].states.strip[self.index]
|
strip_state = self.public_packets[NBS.zero].states.strip[self.index]
|
||||||
|
|
||||||
return strip_state.get_mode(getattr(self._modes, f'_bus{param.lower()}'))
|
return strip_state.get_mode(getattr(ChannelModes, f'BUS{param.upper()}').value)
|
||||||
|
|
||||||
def fset(self, val):
|
def fset(self, val):
|
||||||
self.setter(param, 1 if val else 0)
|
self.setter(param, 1 if val else 0)
|
||||||
|
|||||||
83
vban_cmd/packet/enums.py
Normal file
83
vban_cmd/packet/enums.py
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
from enum import Flag
|
||||||
|
|
||||||
|
|
||||||
|
class SubProtocols(Flag):
|
||||||
|
"""Sub Protocols - Bit flags that can be combined"""
|
||||||
|
|
||||||
|
AUDIO = 0x00
|
||||||
|
SERIAL = 0x20
|
||||||
|
TEXT = 0x40
|
||||||
|
SERVICE = 0x60
|
||||||
|
MASK = 0xE0
|
||||||
|
|
||||||
|
|
||||||
|
class ServiceTypes(Flag):
|
||||||
|
"""Service Types - Bit flags that can be combined"""
|
||||||
|
|
||||||
|
PING = 0
|
||||||
|
PONG = 0
|
||||||
|
CHATUTF8 = 1
|
||||||
|
RTPACKETREGISTER = 32
|
||||||
|
RTPACKET = 33
|
||||||
|
REQUESTREPLY = 0x02 # A Matrix reply
|
||||||
|
FNCT_REPLY = 0x80 # An RTPacket reply
|
||||||
|
|
||||||
|
|
||||||
|
class StreamTypes(Flag):
|
||||||
|
"""Stream Types - Bit flags that can be combined"""
|
||||||
|
|
||||||
|
ASCII = 0x00
|
||||||
|
UTF8 = 0x10
|
||||||
|
WCHAR = 0x20
|
||||||
|
|
||||||
|
|
||||||
|
class ChannelModes(Flag):
|
||||||
|
"""Channel Modes - Bit flags that can be combined"""
|
||||||
|
|
||||||
|
MUTE = 0x00000001
|
||||||
|
SOLO = 0x00000002
|
||||||
|
MONO = 0x00000004
|
||||||
|
MC = 0x00000008
|
||||||
|
|
||||||
|
AMIX = 0x00000010
|
||||||
|
REPEAT = 0x00000020
|
||||||
|
BMIX = 0x00000030
|
||||||
|
COMPOSITE = 0x00000040
|
||||||
|
TVMIX = 0x00000050
|
||||||
|
UPMIX21 = 0x00000060
|
||||||
|
UPMIX41 = 0x00000070
|
||||||
|
UPMIX61 = 0x00000080
|
||||||
|
CENTERONLY = 0x00000090
|
||||||
|
LFEONLY = 0x000000A0
|
||||||
|
REARONLY = 0x000000B0
|
||||||
|
|
||||||
|
MASK = 0x000000F0
|
||||||
|
|
||||||
|
ON = 0x00000100 # eq.on
|
||||||
|
CROSS = 0x00000200
|
||||||
|
AB = 0x00000800 # eq.ab
|
||||||
|
|
||||||
|
BUSA = 0x00001000
|
||||||
|
BUSA1 = 0x00001000
|
||||||
|
BUSA2 = 0x00002000
|
||||||
|
BUSA3 = 0x00004000
|
||||||
|
BUSA4 = 0x00008000
|
||||||
|
BUSA5 = 0x00080000
|
||||||
|
|
||||||
|
BUSB = 0x00010000
|
||||||
|
BUSB1 = 0x00010000
|
||||||
|
BUSB2 = 0x00020000
|
||||||
|
BUSB3 = 0x00040000
|
||||||
|
|
||||||
|
PAN0 = 0x00000000
|
||||||
|
PANCOLOR = 0x00100000
|
||||||
|
PANMOD = 0x00200000
|
||||||
|
PANMASK = 0x00F00000
|
||||||
|
|
||||||
|
POSTFX_R = 0x01000000
|
||||||
|
POSTFX_D = 0x02000000
|
||||||
|
POSTFX1 = 0x04000000
|
||||||
|
POSTFX2 = 0x08000000
|
||||||
|
|
||||||
|
SEL = 0x10000000
|
||||||
|
MONITOR = 0x20000000
|
||||||
@ -1,29 +1,124 @@
|
|||||||
|
import struct
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
|
|
||||||
from vban_cmd.enums import NBS
|
from vban_cmd.enums import NBS
|
||||||
|
from vban_cmd.error import VBANCMDPacketError
|
||||||
from vban_cmd.kinds import KindMapClass
|
from vban_cmd.kinds import KindMapClass
|
||||||
|
|
||||||
VBAN_PROTOCOL_TXT = 0x40
|
from .enums import ServiceTypes, StreamTypes, SubProtocols
|
||||||
VBAN_PROTOCOL_SERVICE = 0x60
|
|
||||||
|
|
||||||
VBAN_SERVICE_RTPACKETREGISTER = 32
|
|
||||||
VBAN_SERVICE_RTPACKET = 33
|
|
||||||
VBAN_SERVICE_PING = 0
|
|
||||||
VBAN_SERVICE_PONG = 0 # PONG uses same service type as PING
|
|
||||||
VBAN_SERVICE_MASK = 0xE0
|
|
||||||
VBAN_PROTOCOL_MASK = 0xE0
|
|
||||||
VBAN_SERVICE_REQUESTREPLY = 0x02
|
|
||||||
VBAN_SERVICE_FNCT_REPLY = 0x02
|
|
||||||
|
|
||||||
PINGPONG_PACKET_SIZE = 704 # Size of the PING/PONG header + payload in bytes
|
PINGPONG_PACKET_SIZE = 704 # Size of the PING/PONG header + payload in bytes
|
||||||
|
|
||||||
MAX_PACKET_SIZE = 1436
|
MAX_PACKET_SIZE = 1436
|
||||||
HEADER_SIZE = 4 + 1 + 1 + 1 + 1 + 16
|
HEADER_SIZE = 4 + 1 + 1 + 1 + 1 + 16
|
||||||
|
|
||||||
|
STREAMNAME_MAX_LENGTH = 16
|
||||||
|
# fmt: off
|
||||||
|
BPS_OPTS = [
|
||||||
|
0, 110, 150, 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 31250,
|
||||||
|
38400, 57600, 115200, 128000, 230400, 250000, 256000, 460800, 921600,
|
||||||
|
1000000, 1500000, 2000000, 3000000,
|
||||||
|
]
|
||||||
|
# fmt: on
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class VbanPacket:
|
class VbanPingHeader:
|
||||||
"""Represents the header of an incoming VBAN data packet"""
|
"""Represents the header of a PING packet"""
|
||||||
|
|
||||||
|
name: str = 'PING0'
|
||||||
|
format_sr: int = SubProtocols.SERVICE.value
|
||||||
|
format_nbs: int = 0
|
||||||
|
format_nbc: int = ServiceTypes.PING.value
|
||||||
|
format_bit: int = 0
|
||||||
|
framecounter: int = 0
|
||||||
|
|
||||||
|
@property
|
||||||
|
def vban(self) -> bytes:
|
||||||
|
return b'VBAN'
|
||||||
|
|
||||||
|
@property
|
||||||
|
def streamname(self) -> bytes:
|
||||||
|
return self.name.encode('ascii')[:STREAMNAME_MAX_LENGTH].ljust(
|
||||||
|
STREAMNAME_MAX_LENGTH, b'\x00'
|
||||||
|
)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def to_bytes(cls, framecounter: int = 0) -> bytes:
|
||||||
|
"""Creates the PING header bytes only."""
|
||||||
|
header = cls(framecounter=framecounter)
|
||||||
|
|
||||||
|
return struct.pack(
|
||||||
|
'<4s4B16sI',
|
||||||
|
header.vban,
|
||||||
|
header.format_sr,
|
||||||
|
header.format_nbs,
|
||||||
|
header.format_nbc,
|
||||||
|
header.format_bit,
|
||||||
|
header.streamname,
|
||||||
|
header.framecounter,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class VbanPongHeader:
|
||||||
|
"""Represents the header of a PONG response packet"""
|
||||||
|
|
||||||
|
name: str = 'PING0'
|
||||||
|
format_sr: int = SubProtocols.SERVICE.value
|
||||||
|
format_nbs: int = 0
|
||||||
|
format_nbc: int = ServiceTypes.PONG.value
|
||||||
|
format_bit: int = 0
|
||||||
|
framecounter: int = 0
|
||||||
|
|
||||||
|
@property
|
||||||
|
def vban(self) -> bytes:
|
||||||
|
return b'VBAN'
|
||||||
|
|
||||||
|
@property
|
||||||
|
def streamname(self) -> bytes:
|
||||||
|
return self.name.encode('ascii')[:STREAMNAME_MAX_LENGTH].ljust(
|
||||||
|
STREAMNAME_MAX_LENGTH, b'\x00'
|
||||||
|
)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_bytes(cls, data: bytes):
|
||||||
|
"""Parse a PONG response packet from bytes."""
|
||||||
|
parsed = _parse_vban_service_header(data)
|
||||||
|
|
||||||
|
# PONG responses use the same service type as PING (0x00)
|
||||||
|
# and are identified by having payload data
|
||||||
|
if parsed['format_nbc'] != ServiceTypes.PONG.value:
|
||||||
|
raise VBANCMDPacketError(
|
||||||
|
f'Not a PONG response packet: {parsed["format_nbc"]:02x}',
|
||||||
|
protocol=SubProtocols(parsed['format_sr'] & SubProtocols.MASK.value),
|
||||||
|
type_=ServiceTypes(parsed['format_nbc']),
|
||||||
|
)
|
||||||
|
|
||||||
|
return cls(**parsed)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def is_pong_response(cls, data: bytes) -> bool:
|
||||||
|
"""Check if packet is a PONG response by analyzing the actual response format."""
|
||||||
|
try:
|
||||||
|
parsed = _parse_vban_service_header(data)
|
||||||
|
|
||||||
|
# Validate this is a service protocol packet with PING/PONG service type
|
||||||
|
if parsed['format_nbc'] != ServiceTypes.PONG.value:
|
||||||
|
return False
|
||||||
|
|
||||||
|
if parsed['name'] not in ['PING0', 'VBAN Service']:
|
||||||
|
return False
|
||||||
|
|
||||||
|
# PONG should have payload data (same size as PING)
|
||||||
|
return len(data) >= PINGPONG_PACKET_SIZE
|
||||||
|
|
||||||
|
except (ValueError, Exception):
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class VbanRTPacket:
|
||||||
|
"""Represents the header of an incoming RTPacket"""
|
||||||
|
|
||||||
nbs: NBS
|
nbs: NBS
|
||||||
_kind: KindMapClass
|
_kind: KindMapClass
|
||||||
@ -53,10 +148,10 @@ class VbanPacket:
|
|||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class VbanSubscribeHeader:
|
class VbanRTSubscribeHeader:
|
||||||
"""Represents the header of a subscription packet"""
|
"""Represents the header of an RT subscription packet"""
|
||||||
|
|
||||||
nbs: NBS = NBS.zero
|
_nbs: NBS = NBS.zero
|
||||||
name: str = 'Register-RTP'
|
name: str = 'Register-RTP'
|
||||||
timeout: int = 15
|
timeout: int = 15
|
||||||
|
|
||||||
@ -65,38 +160,106 @@ class VbanSubscribeHeader:
|
|||||||
return b'VBAN'
|
return b'VBAN'
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def format_sr(self) -> bytes:
|
def sr(self) -> int:
|
||||||
return VBAN_PROTOCOL_SERVICE.to_bytes(1, 'little')
|
return SubProtocols.SERVICE.value
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def format_nbs(self) -> bytes:
|
def nbs(self) -> int:
|
||||||
return (self.nbs.value & 0xFF).to_bytes(1, 'little')
|
return self._nbs.value & 0xFF
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def format_nbc(self) -> bytes:
|
def nbc(self) -> int:
|
||||||
return VBAN_SERVICE_RTPACKETREGISTER.to_bytes(1, 'little')
|
return ServiceTypes.RTPACKETREGISTER.value
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def format_bit(self) -> bytes:
|
def bit(self) -> int:
|
||||||
return (self.timeout & 0xFF).to_bytes(1, 'little')
|
return self.timeout & 0xFF
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def streamname(self) -> bytes:
|
def streamname(self) -> bytes:
|
||||||
return self.name.encode('ascii') + bytes(16 - len(self.name))
|
return self.name.encode()[:STREAMNAME_MAX_LENGTH].ljust(
|
||||||
|
STREAMNAME_MAX_LENGTH, b'\x00'
|
||||||
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def to_bytes(cls, nbs: NBS, framecounter: int) -> bytes:
|
def to_bytes(cls, nbs: NBS, framecounter: int) -> bytes:
|
||||||
header = cls(nbs=nbs)
|
header = cls(_nbs=nbs)
|
||||||
|
|
||||||
data = bytearray()
|
return struct.pack(
|
||||||
data.extend(header.vban)
|
'<4s4B16sI',
|
||||||
data.extend(header.format_sr)
|
header.vban,
|
||||||
data.extend(header.format_nbs)
|
header.sr,
|
||||||
data.extend(header.format_nbc)
|
header.nbs,
|
||||||
data.extend(header.format_bit)
|
header.nbc,
|
||||||
data.extend(header.streamname)
|
header.bit,
|
||||||
data.extend(framecounter.to_bytes(4, 'little'))
|
header.streamname,
|
||||||
return bytes(data)
|
framecounter,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class VbanRTRequestHeader:
|
||||||
|
"""Represents the header of an RT request packet"""
|
||||||
|
|
||||||
|
name: str
|
||||||
|
bps: int
|
||||||
|
channel: int
|
||||||
|
framecounter: int = 0
|
||||||
|
|
||||||
|
def __post_init__(self):
|
||||||
|
if self.bps not in BPS_OPTS:
|
||||||
|
raise ValueError(
|
||||||
|
f'Invalid bps value: {self.bps}. Must be one of {BPS_OPTS}'
|
||||||
|
)
|
||||||
|
self.bps_index = BPS_OPTS.index(self.bps)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def vban(self) -> bytes:
|
||||||
|
return b'VBAN'
|
||||||
|
|
||||||
|
@property
|
||||||
|
def sr(self) -> int:
|
||||||
|
return self.bps_index | SubProtocols.TEXT.value
|
||||||
|
|
||||||
|
@property
|
||||||
|
def nbs(self) -> int:
|
||||||
|
return 0
|
||||||
|
|
||||||
|
@property
|
||||||
|
def nbc(self) -> int:
|
||||||
|
return self.channel
|
||||||
|
|
||||||
|
@property
|
||||||
|
def bit(self) -> int:
|
||||||
|
return StreamTypes.UTF8.value
|
||||||
|
|
||||||
|
@property
|
||||||
|
def streamname(self) -> bytes:
|
||||||
|
return self.name.encode()[:STREAMNAME_MAX_LENGTH].ljust(
|
||||||
|
STREAMNAME_MAX_LENGTH, b'\x00'
|
||||||
|
)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def to_bytes(cls, name: str, bps: int, channel: int, framecounter: int) -> bytes:
|
||||||
|
header = cls(name=name, bps=bps, channel=channel, framecounter=framecounter)
|
||||||
|
|
||||||
|
return struct.pack(
|
||||||
|
'<4s4B16sI',
|
||||||
|
header.vban,
|
||||||
|
header.sr,
|
||||||
|
header.nbs,
|
||||||
|
header.nbc,
|
||||||
|
header.bit,
|
||||||
|
header.streamname,
|
||||||
|
header.framecounter,
|
||||||
|
)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def encode_with_payload(
|
||||||
|
cls, name: str, bps: int, channel: int, framecounter: int, payload: str
|
||||||
|
) -> bytes:
|
||||||
|
"""Creates the complete packet with header and payload."""
|
||||||
|
return cls.to_bytes(name, bps, channel, framecounter) + payload.encode()
|
||||||
|
|
||||||
|
|
||||||
def _parse_vban_service_header(data: bytes) -> dict:
|
def _parse_vban_service_header(data: bytes) -> dict:
|
||||||
@ -113,9 +276,12 @@ def _parse_vban_service_header(data: bytes) -> dict:
|
|||||||
format_bit = data[7]
|
format_bit = data[7]
|
||||||
|
|
||||||
# Verify this is a service protocol packet
|
# Verify this is a service protocol packet
|
||||||
protocol = format_sr & VBAN_PROTOCOL_MASK
|
protocol = format_sr & SubProtocols.MASK.value
|
||||||
if protocol != VBAN_PROTOCOL_SERVICE:
|
if protocol != SubProtocols.SERVICE.value:
|
||||||
raise ValueError(f'Not a service protocol packet: {protocol:02x}')
|
raise VBANCMDPacketError(
|
||||||
|
f'Invalid protocol in service header: {protocol:02x}',
|
||||||
|
protocol=SubProtocols(protocol),
|
||||||
|
)
|
||||||
|
|
||||||
# Extract stream name and frame counter
|
# Extract stream name and frame counter
|
||||||
name = data[8:24].rstrip(b'\x00').decode('utf-8', errors='ignore')
|
name = data[8:24].rstrip(b'\x00').decode('utf-8', errors='ignore')
|
||||||
@ -132,13 +298,13 @@ def _parse_vban_service_header(data: bytes) -> dict:
|
|||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class VbanResponseHeader:
|
class VbanRTResponseHeader:
|
||||||
"""Represents the header of a response packet"""
|
"""Represents the header of an RT response packet"""
|
||||||
|
|
||||||
name: str = 'Voicemeeter-RTP'
|
name: str = 'Voicemeeter-RTP'
|
||||||
format_sr: int = VBAN_PROTOCOL_SERVICE
|
format_sr: int = SubProtocols.SERVICE.value
|
||||||
format_nbs: int = 0
|
format_nbs: int = 0
|
||||||
format_nbc: int = VBAN_SERVICE_RTPACKET
|
format_nbc: int = ServiceTypes.RTPACKET.value
|
||||||
format_bit: int = 0
|
format_bit: int = 0
|
||||||
framecounter: int = 0
|
framecounter: int = 0
|
||||||
|
|
||||||
@ -148,7 +314,9 @@ class VbanResponseHeader:
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def streamname(self) -> bytes:
|
def streamname(self) -> bytes:
|
||||||
return self.name.encode('ascii') + bytes(16 - len(self.name))
|
return self.name.encode()[:STREAMNAME_MAX_LENGTH].ljust(
|
||||||
|
STREAMNAME_MAX_LENGTH, b'\x00'
|
||||||
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_bytes(cls, data: bytes):
|
def from_bytes(cls, data: bytes):
|
||||||
@ -156,9 +324,11 @@ class VbanResponseHeader:
|
|||||||
parsed = _parse_vban_service_header(data)
|
parsed = _parse_vban_service_header(data)
|
||||||
|
|
||||||
# Validate this is an RTPacket response
|
# Validate this is an RTPacket response
|
||||||
if parsed['format_nbc'] != VBAN_SERVICE_RTPACKET:
|
if parsed['format_nbc'] != ServiceTypes.RTPACKET.value:
|
||||||
raise ValueError(
|
raise VBANCMDPacketError(
|
||||||
f'Not an RTPacket response packet: {parsed["format_nbc"]:02x}'
|
f'Not an RTPacket response packet: {parsed["format_nbc"]:02x}',
|
||||||
|
protocol=SubProtocols(parsed['format_sr'] & SubProtocols.MASK.value),
|
||||||
|
type_=ServiceTypes(parsed['format_nbc']),
|
||||||
)
|
)
|
||||||
|
|
||||||
return cls(**parsed)
|
return cls(**parsed)
|
||||||
@ -169,9 +339,9 @@ class VbanMatrixResponseHeader:
|
|||||||
"""Represents the header of a matrix response packet"""
|
"""Represents the header of a matrix response packet"""
|
||||||
|
|
||||||
name: str = 'Request Reply'
|
name: str = 'Request Reply'
|
||||||
format_sr: int = VBAN_PROTOCOL_SERVICE
|
format_sr: int = SubProtocols.SERVICE.value
|
||||||
format_nbs: int = VBAN_SERVICE_FNCT_REPLY
|
format_nbs: int = ServiceTypes.FNCT_REPLY.value
|
||||||
format_nbc: int = VBAN_SERVICE_REQUESTREPLY
|
format_nbc: int = ServiceTypes.REQUESTREPLY.value
|
||||||
format_bit: int = 0
|
format_bit: int = 0
|
||||||
framecounter: int = 0
|
framecounter: int = 0
|
||||||
|
|
||||||
@ -181,16 +351,29 @@ class VbanMatrixResponseHeader:
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def streamname(self) -> bytes:
|
def streamname(self) -> bytes:
|
||||||
return self.name.encode('ascii')[:16].ljust(16, b'\x00')
|
return self.name.encode()[:STREAMNAME_MAX_LENGTH].ljust(
|
||||||
|
STREAMNAME_MAX_LENGTH, b'\x00'
|
||||||
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_bytes(cls, data: bytes):
|
def from_bytes(cls, data: bytes):
|
||||||
"""Parse a matrix response packet from bytes."""
|
"""Parse a matrix response packet from bytes."""
|
||||||
parsed = _parse_vban_service_header(data)
|
parsed = _parse_vban_service_header(data)
|
||||||
|
|
||||||
# Validate this is a service reply packet
|
# Validate this is a service reply packet (dual encoding scheme)
|
||||||
if parsed['format_nbs'] != VBAN_SERVICE_FNCT_REPLY:
|
if parsed['format_nbs'] != ServiceTypes.FNCT_REPLY.value:
|
||||||
raise ValueError(f'Not a service reply packet: {parsed["format_nbs"]:02x}')
|
raise VBANCMDPacketError(
|
||||||
|
f'Not a service reply packet: {parsed["format_nbs"]:02x}',
|
||||||
|
protocol=SubProtocols(parsed['format_sr'] & SubProtocols.MASK.value),
|
||||||
|
type_=ServiceTypes(parsed['format_nbs']),
|
||||||
|
)
|
||||||
|
|
||||||
|
if parsed['format_nbc'] != ServiceTypes.REQUESTREPLY.value:
|
||||||
|
raise VBANCMDPacketError(
|
||||||
|
f'Not a request reply packet: {parsed["format_nbc"]:02x}',
|
||||||
|
protocol=SubProtocols(parsed['format_sr'] & SubProtocols.MASK.value),
|
||||||
|
type_=ServiceTypes(parsed['format_nbc']),
|
||||||
|
)
|
||||||
|
|
||||||
return cls(**parsed)
|
return cls(**parsed)
|
||||||
|
|
||||||
@ -209,148 +392,3 @@ class VbanMatrixResponseHeader:
|
|||||||
header = cls.from_bytes(data)
|
header = cls.from_bytes(data)
|
||||||
payload = cls.extract_payload(data)
|
payload = cls.extract_payload(data)
|
||||||
return header, payload
|
return header, payload
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
|
||||||
class VbanPingHeader:
|
|
||||||
"""Represents the header of a PING packet"""
|
|
||||||
|
|
||||||
name: str = 'PING0'
|
|
||||||
format_sr: int = VBAN_PROTOCOL_SERVICE
|
|
||||||
format_nbs: int = 0
|
|
||||||
format_nbc: int = VBAN_SERVICE_PING
|
|
||||||
format_bit: int = 0
|
|
||||||
framecounter: int = 0
|
|
||||||
|
|
||||||
@property
|
|
||||||
def vban(self) -> bytes:
|
|
||||||
return b'VBAN'
|
|
||||||
|
|
||||||
@property
|
|
||||||
def streamname(self) -> bytes:
|
|
||||||
return self.name.encode('ascii')[:16].ljust(16, b'\x00')
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def to_bytes(cls, framecounter: int = 0) -> bytes:
|
|
||||||
"""Creates the PING header bytes only."""
|
|
||||||
header = cls(framecounter=framecounter)
|
|
||||||
|
|
||||||
data = bytearray()
|
|
||||||
data.extend(header.vban)
|
|
||||||
data.extend(header.format_sr.to_bytes(1, 'little'))
|
|
||||||
data.extend(header.format_nbs.to_bytes(1, 'little'))
|
|
||||||
data.extend(header.format_nbc.to_bytes(1, 'little'))
|
|
||||||
data.extend(header.format_bit.to_bytes(1, 'little'))
|
|
||||||
data.extend(header.streamname)
|
|
||||||
data.extend(header.framecounter.to_bytes(4, 'little'))
|
|
||||||
return bytes(data)
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
|
||||||
class VbanPongHeader:
|
|
||||||
"""Represents the header of a PONG response packet"""
|
|
||||||
|
|
||||||
name: str = 'PING0'
|
|
||||||
format_sr: int = VBAN_PROTOCOL_SERVICE
|
|
||||||
format_nbs: int = 0
|
|
||||||
format_nbc: int = VBAN_SERVICE_PONG
|
|
||||||
format_bit: int = 0
|
|
||||||
framecounter: int = 0
|
|
||||||
|
|
||||||
@property
|
|
||||||
def vban(self) -> bytes:
|
|
||||||
return b'VBAN'
|
|
||||||
|
|
||||||
@property
|
|
||||||
def streamname(self) -> bytes:
|
|
||||||
return self.name.encode('ascii')[:16].ljust(16, b'\x00')
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def from_bytes(cls, data: bytes):
|
|
||||||
"""Parse a PONG response packet from bytes."""
|
|
||||||
parsed = _parse_vban_service_header(data)
|
|
||||||
|
|
||||||
# PONG responses use the same service type as PING (0x00)
|
|
||||||
# and are identified by having payload data
|
|
||||||
if parsed['format_nbc'] != VBAN_SERVICE_PONG:
|
|
||||||
raise ValueError(f'Not a PONG response packet: {parsed["format_nbc"]:02x}')
|
|
||||||
|
|
||||||
return cls(**parsed)
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def is_pong_response(cls, data: bytes) -> bool:
|
|
||||||
"""Check if packet is a PONG response by analyzing the actual response format."""
|
|
||||||
try:
|
|
||||||
parsed = _parse_vban_service_header(data)
|
|
||||||
|
|
||||||
# Validate this is a service protocol packet with PING/PONG service type
|
|
||||||
if parsed['format_nbc'] != VBAN_SERVICE_PONG:
|
|
||||||
return False
|
|
||||||
|
|
||||||
if parsed['name'] not in ['PING0', 'VBAN Service']:
|
|
||||||
return False
|
|
||||||
|
|
||||||
# PONG should have payload data (same size as PING)
|
|
||||||
return len(data) >= PINGPONG_PACKET_SIZE
|
|
||||||
|
|
||||||
except (ValueError, Exception):
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
|
||||||
class VbanRequestHeader:
|
|
||||||
"""Represents the header of a request packet"""
|
|
||||||
|
|
||||||
name: str
|
|
||||||
bps_index: int
|
|
||||||
channel: int
|
|
||||||
framecounter: int = 0
|
|
||||||
|
|
||||||
@property
|
|
||||||
def vban(self) -> bytes:
|
|
||||||
return b'VBAN'
|
|
||||||
|
|
||||||
@property
|
|
||||||
def sr(self) -> bytes:
|
|
||||||
return (VBAN_PROTOCOL_TXT + self.bps_index).to_bytes(1, 'little')
|
|
||||||
|
|
||||||
@property
|
|
||||||
def nbs(self) -> bytes:
|
|
||||||
return (0).to_bytes(1, 'little')
|
|
||||||
|
|
||||||
@property
|
|
||||||
def nbc(self) -> bytes:
|
|
||||||
return (self.channel).to_bytes(1, 'little')
|
|
||||||
|
|
||||||
@property
|
|
||||||
def bit(self) -> bytes:
|
|
||||||
return (0x10).to_bytes(1, 'little')
|
|
||||||
|
|
||||||
@property
|
|
||||||
def streamname(self) -> bytes:
|
|
||||||
return self.name.encode()[:16].ljust(16, b'\x00')
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def to_bytes(
|
|
||||||
cls, name: str, bps_index: int, channel: int, framecounter: int
|
|
||||||
) -> bytes:
|
|
||||||
header = cls(
|
|
||||||
name=name, bps_index=bps_index, channel=channel, framecounter=framecounter
|
|
||||||
)
|
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def encode_with_payload(
|
|
||||||
cls, name: str, bps_index: int, channel: int, framecounter: int, payload: str
|
|
||||||
) -> bytes:
|
|
||||||
"""Creates the complete packet with header and payload."""
|
|
||||||
return cls.to_bytes(name, bps_index, channel, framecounter) + payload.encode()
|
|
||||||
|
|||||||
@ -1,11 +1,14 @@
|
|||||||
|
import struct
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
|
from functools import cached_property
|
||||||
from typing import NamedTuple
|
from typing import NamedTuple
|
||||||
|
|
||||||
from vban_cmd.enums import NBS
|
from vban_cmd.enums import NBS
|
||||||
from vban_cmd.kinds import KindMapClass
|
from vban_cmd.kinds import KindMapClass
|
||||||
from vban_cmd.util import comp
|
from vban_cmd.util import comp
|
||||||
|
|
||||||
from .headers import VbanPacket
|
from .enums import ChannelModes
|
||||||
|
from .headers import VbanRTPacket
|
||||||
|
|
||||||
|
|
||||||
class Levels(NamedTuple):
|
class Levels(NamedTuple):
|
||||||
@ -20,6 +23,13 @@ class ChannelState:
|
|||||||
# Convert 4-byte state to integer once for efficient lookups
|
# Convert 4-byte state to integer once for efficient lookups
|
||||||
self._state = int.from_bytes(state_bytes, 'little')
|
self._state = int.from_bytes(state_bytes, 'little')
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_int(cls, state_int: int):
|
||||||
|
"""Create ChannelState directly from integer for efficiency"""
|
||||||
|
instance = cls.__new__(cls)
|
||||||
|
instance._state = state_int
|
||||||
|
return instance
|
||||||
|
|
||||||
def get_mode(self, mode_value: int) -> bool:
|
def get_mode(self, mode_value: int) -> bool:
|
||||||
"""Get boolean state for a specific mode"""
|
"""Get boolean state for a specific mode"""
|
||||||
return (self._state & mode_value) != 0
|
return (self._state & mode_value) != 0
|
||||||
@ -31,57 +41,57 @@ class ChannelState:
|
|||||||
# Common boolean modes
|
# Common boolean modes
|
||||||
@property
|
@property
|
||||||
def mute(self) -> bool:
|
def mute(self) -> bool:
|
||||||
return (self._state & 0x00000001) != 0
|
return (self._state & ChannelModes.MUTE.value) != 0
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def solo(self) -> bool:
|
def solo(self) -> bool:
|
||||||
return (self._state & 0x00000002) != 0
|
return (self._state & ChannelModes.SOLO.value) != 0
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def mono(self) -> bool:
|
def mono(self) -> bool:
|
||||||
return (self._state & 0x00000004) != 0
|
return (self._state & ChannelModes.MONO.value) != 0
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def mc(self) -> bool:
|
def mc(self) -> bool:
|
||||||
return (self._state & 0x00000008) != 0
|
return (self._state & ChannelModes.MC.value) != 0
|
||||||
|
|
||||||
# EQ modes
|
# EQ modes
|
||||||
@property
|
@property
|
||||||
def eq_on(self) -> bool:
|
def eq_on(self) -> bool:
|
||||||
return (self._state & 0x00000100) != 0
|
return (self._state & ChannelModes.ON.value) != 0
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def eq_ab(self) -> bool:
|
def eq_ab(self) -> bool:
|
||||||
return (self._state & 0x00000800) != 0
|
return (self._state & ChannelModes.AB.value) != 0
|
||||||
|
|
||||||
# Bus assignments (strip to bus routing)
|
# Bus assignments (strip to bus routing)
|
||||||
@property
|
@property
|
||||||
def busa1(self) -> bool:
|
def busa1(self) -> bool:
|
||||||
return (self._state & 0x00001000) != 0
|
return (self._state & ChannelModes.BUSA1.value) != 0
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def busa2(self) -> bool:
|
def busa2(self) -> bool:
|
||||||
return (self._state & 0x00002000) != 0
|
return (self._state & ChannelModes.BUSA2.value) != 0
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def busa3(self) -> bool:
|
def busa3(self) -> bool:
|
||||||
return (self._state & 0x00004000) != 0
|
return (self._state & ChannelModes.BUSA3.value) != 0
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def busa4(self) -> bool:
|
def busa4(self) -> bool:
|
||||||
return (self._state & 0x00008000) != 0
|
return (self._state & ChannelModes.BUSA4.value) != 0
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def busb1(self) -> bool:
|
def busb1(self) -> bool:
|
||||||
return (self._state & 0x00010000) != 0
|
return (self._state & ChannelModes.BUSB1.value) != 0
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def busb2(self) -> bool:
|
def busb2(self) -> bool:
|
||||||
return (self._state & 0x00020000) != 0
|
return (self._state & ChannelModes.BUSB2.value) != 0
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def busb3(self) -> bool:
|
def busb3(self) -> bool:
|
||||||
return (self._state & 0x00040000) != 0
|
return (self._state & ChannelModes.BUSB3.value) != 0
|
||||||
|
|
||||||
|
|
||||||
class States(NamedTuple):
|
class States(NamedTuple):
|
||||||
@ -95,8 +105,8 @@ class Labels(NamedTuple):
|
|||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class VbanPacketNBS0(VbanPacket):
|
class VbanRTPacketNBS0(VbanRTPacket):
|
||||||
"""Represents the body of a VBAN data packet with ident:0"""
|
"""Represents the body of a VBAN RTPacket with ident:0"""
|
||||||
|
|
||||||
_inputLeveldB100: bytes
|
_inputLeveldB100: bytes
|
||||||
_outputLeveldB100: bytes
|
_outputLeveldB100: bytes
|
||||||
@ -146,32 +156,17 @@ class VbanPacketNBS0(VbanPacket):
|
|||||||
|
|
||||||
def pdirty(self, other) -> bool:
|
def pdirty(self, other) -> bool:
|
||||||
"""True iff any defined parameter has changed"""
|
"""True iff any defined parameter has changed"""
|
||||||
|
|
||||||
self_gains = (
|
|
||||||
self._stripGaindB100Layer1
|
|
||||||
+ self._stripGaindB100Layer2
|
|
||||||
+ self._stripGaindB100Layer3
|
|
||||||
+ self._stripGaindB100Layer4
|
|
||||||
+ self._stripGaindB100Layer5
|
|
||||||
+ self._stripGaindB100Layer6
|
|
||||||
+ self._stripGaindB100Layer7
|
|
||||||
+ self._stripGaindB100Layer8
|
|
||||||
)
|
|
||||||
other_gains = (
|
|
||||||
other._stripGaindB100Layer1
|
|
||||||
+ other._stripGaindB100Layer2
|
|
||||||
+ other._stripGaindB100Layer3
|
|
||||||
+ other._stripGaindB100Layer4
|
|
||||||
+ other._stripGaindB100Layer5
|
|
||||||
+ other._stripGaindB100Layer6
|
|
||||||
+ other._stripGaindB100Layer7
|
|
||||||
+ other._stripGaindB100Layer8
|
|
||||||
)
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
self._stripState != other._stripState
|
self._stripState != other._stripState
|
||||||
or self._busState != other._busState
|
or self._busState != other._busState
|
||||||
or self_gains != other_gains
|
or self._stripGaindB100Layer1 != other._stripGaindB100Layer1
|
||||||
|
or self._stripGaindB100Layer2 != other._stripGaindB100Layer2
|
||||||
|
or self._stripGaindB100Layer3 != other._stripGaindB100Layer3
|
||||||
|
or self._stripGaindB100Layer4 != other._stripGaindB100Layer4
|
||||||
|
or self._stripGaindB100Layer5 != other._stripGaindB100Layer5
|
||||||
|
or self._stripGaindB100Layer6 != other._stripGaindB100Layer6
|
||||||
|
or self._stripGaindB100Layer7 != other._stripGaindB100Layer7
|
||||||
|
or self._stripGaindB100Layer8 != other._stripGaindB100Layer8
|
||||||
or self._busGaindB100 != other._busGaindB100
|
or self._busGaindB100 != other._busGaindB100
|
||||||
or self._stripLabelUTF8c60 != other._stripLabelUTF8c60
|
or self._stripLabelUTF8c60 != other._stripLabelUTF8c60
|
||||||
or self._busLabelUTF8c60 != other._busLabelUTF8c60
|
or self._busLabelUTF8c60 != other._busLabelUTF8c60
|
||||||
@ -185,77 +180,54 @@ class VbanPacketNBS0(VbanPacket):
|
|||||||
)
|
)
|
||||||
return any(self._strip_comp) or any(self._bus_comp)
|
return any(self._strip_comp) or any(self._bus_comp)
|
||||||
|
|
||||||
@property
|
@cached_property
|
||||||
def strip_levels(self) -> tuple[float, ...]:
|
def strip_levels(self) -> tuple[float, ...]:
|
||||||
"""Returns strip levels in dB"""
|
"""Returns strip levels in dB"""
|
||||||
return tuple(
|
strip_raw = struct.unpack('<34h', self._inputLeveldB100)
|
||||||
round(
|
return tuple(round(val * 0.01, 1) for val in strip_raw)[
|
||||||
int.from_bytes(self._inputLeveldB100[i : i + 2], 'little', signed=True)
|
: self._kind.num_strip_levels
|
||||||
* 0.01,
|
]
|
||||||
1,
|
|
||||||
)
|
|
||||||
for i in range(0, len(self._inputLeveldB100), 2)
|
|
||||||
)[: self._kind.num_strip_levels]
|
|
||||||
|
|
||||||
@property
|
@cached_property
|
||||||
def bus_levels(self) -> tuple[float, ...]:
|
def bus_levels(self) -> tuple[float, ...]:
|
||||||
"""Returns bus levels in dB"""
|
"""Returns bus levels in dB"""
|
||||||
return tuple(
|
bus_raw = struct.unpack('<64h', self._outputLeveldB100)
|
||||||
round(
|
return tuple(round(val * 0.01, 1) for val in bus_raw)[
|
||||||
int.from_bytes(self._outputLeveldB100[i : i + 2], 'little', signed=True)
|
: self._kind.num_bus_levels
|
||||||
* 0.01,
|
]
|
||||||
1,
|
|
||||||
)
|
|
||||||
for i in range(0, len(self._outputLeveldB100), 2)
|
|
||||||
)[: self._kind.num_bus_levels]
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def levels(self) -> Levels:
|
def levels(self) -> Levels:
|
||||||
"""Returns strip and bus levels as a namedtuple"""
|
"""Returns strip and bus levels as a namedtuple"""
|
||||||
return Levels(strip=self.strip_levels, bus=self.bus_levels)
|
return Levels(strip=self.strip_levels, bus=self.bus_levels)
|
||||||
|
|
||||||
@property
|
@cached_property
|
||||||
def states(self) -> States:
|
def states(self) -> States:
|
||||||
"""returns States object with processed strip and bus channel states"""
|
"""returns States object with processed strip and bus channel states"""
|
||||||
|
strip_states = struct.unpack('<8I', self._stripState)
|
||||||
|
bus_states = struct.unpack('<8I', self._busState)
|
||||||
return States(
|
return States(
|
||||||
strip=tuple(
|
strip=tuple(ChannelState.from_int(state) for state in strip_states),
|
||||||
ChannelState(self._stripState[i : i + 4]) for i in range(0, 32, 4)
|
bus=tuple(ChannelState.from_int(state) for state in bus_states),
|
||||||
),
|
|
||||||
bus=tuple(ChannelState(self._busState[i : i + 4]) for i in range(0, 32, 4)),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
@property
|
@cached_property
|
||||||
def gainlayers(self) -> tuple:
|
def gainlayers(self) -> tuple:
|
||||||
"""returns tuple of all strip gain layers as tuples"""
|
"""returns tuple of all strip gain layers as tuples"""
|
||||||
return tuple(
|
layer_data = []
|
||||||
tuple(
|
for layer in range(1, 9):
|
||||||
round(
|
layer_bytes = getattr(self, f'_stripGaindB100Layer{layer}')
|
||||||
int.from_bytes(
|
layer_raw = struct.unpack('<8h', layer_bytes)
|
||||||
getattr(self, f'_stripGaindB100Layer{layer}')[i : i + 2],
|
layer_data.append(tuple(round(val * 0.01, 2) for val in layer_raw))
|
||||||
'little',
|
return tuple(layer_data)
|
||||||
signed=True,
|
|
||||||
)
|
|
||||||
* 0.01,
|
|
||||||
2,
|
|
||||||
)
|
|
||||||
for i in range(0, 16, 2)
|
|
||||||
)
|
|
||||||
for layer in range(1, 9)
|
|
||||||
)
|
|
||||||
|
|
||||||
@property
|
@cached_property
|
||||||
def busgain(self) -> tuple:
|
def busgain(self) -> tuple:
|
||||||
"""returns tuple of bus gains"""
|
"""returns tuple of bus gains"""
|
||||||
return tuple(
|
bus_gain_raw = struct.unpack('<8h', self._busGaindB100)
|
||||||
round(
|
return tuple(round(val * 0.01, 2) for val in bus_gain_raw)
|
||||||
int.from_bytes(self._busGaindB100[i : i + 2], 'little', signed=True)
|
|
||||||
* 0.01,
|
|
||||||
2,
|
|
||||||
)
|
|
||||||
for i in range(0, 16, 2)
|
|
||||||
)
|
|
||||||
|
|
||||||
@property
|
@cached_property
|
||||||
def labels(self) -> Labels:
|
def labels(self) -> Labels:
|
||||||
"""returns Labels namedtuple of strip and bus labels"""
|
"""returns Labels namedtuple of strip and bus labels"""
|
||||||
|
|
||||||
|
|||||||
@ -1,11 +1,12 @@
|
|||||||
import struct
|
import struct
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
|
from functools import cached_property
|
||||||
from typing import NamedTuple
|
from typing import NamedTuple
|
||||||
|
|
||||||
from vban_cmd.enums import NBS
|
from vban_cmd.enums import NBS
|
||||||
from vban_cmd.kinds import KindMapClass
|
from vban_cmd.kinds import KindMapClass
|
||||||
|
|
||||||
from .headers import VbanPacket
|
from .headers import VbanRTPacket
|
||||||
|
|
||||||
VMPARAMSTRIP_SIZE = 174
|
VMPARAMSTRIP_SIZE = 174
|
||||||
|
|
||||||
@ -193,11 +194,15 @@ class VbanVMParamStrip:
|
|||||||
_Pitch_formant_high=data[172:174],
|
_Pitch_formant_high=data[172:174],
|
||||||
)
|
)
|
||||||
|
|
||||||
@property
|
@cached_property
|
||||||
def mode(self) -> int:
|
def mode(self) -> int:
|
||||||
return int.from_bytes(self._mode, 'little')
|
return int.from_bytes(self._mode, 'little')
|
||||||
|
|
||||||
@property
|
@cached_property
|
||||||
|
def karaoke(self) -> int:
|
||||||
|
return int.from_bytes(self._nKaraoke, 'little')
|
||||||
|
|
||||||
|
@cached_property
|
||||||
def audibility(self) -> Audibility:
|
def audibility(self) -> Audibility:
|
||||||
return Audibility(
|
return Audibility(
|
||||||
round(int.from_bytes(self._audibility, 'little', signed=True) * 0.01, 2),
|
round(int.from_bytes(self._audibility, 'little', signed=True) * 0.01, 2),
|
||||||
@ -206,7 +211,7 @@ class VbanVMParamStrip:
|
|||||||
round(int.from_bytes(self._audibility_d, 'little', signed=True) * 0.01, 2),
|
round(int.from_bytes(self._audibility_d, 'little', signed=True) * 0.01, 2),
|
||||||
)
|
)
|
||||||
|
|
||||||
@property
|
@cached_property
|
||||||
def positions(self) -> Positions:
|
def positions(self) -> Positions:
|
||||||
return Positions(
|
return Positions(
|
||||||
round(int.from_bytes(self._pos3D_x, 'little', signed=True) * 0.01, 2),
|
round(int.from_bytes(self._pos3D_x, 'little', signed=True) * 0.01, 2),
|
||||||
@ -217,7 +222,7 @@ class VbanVMParamStrip:
|
|||||||
round(int.from_bytes(self._posMod_y, 'little', signed=True) * 0.01, 2),
|
round(int.from_bytes(self._posMod_y, 'little', signed=True) * 0.01, 2),
|
||||||
)
|
)
|
||||||
|
|
||||||
@property
|
@cached_property
|
||||||
def eqgains(self) -> EqGains:
|
def eqgains(self) -> EqGains:
|
||||||
return EqGains(
|
return EqGains(
|
||||||
*[
|
*[
|
||||||
@ -230,7 +235,7 @@ class VbanVMParamStrip:
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
@property
|
@cached_property
|
||||||
def parametric_eq(self) -> tuple[ParametricEQSettings, ...]:
|
def parametric_eq(self) -> tuple[ParametricEQSettings, ...]:
|
||||||
return tuple(
|
return tuple(
|
||||||
ParametricEQSettings(
|
ParametricEQSettings(
|
||||||
@ -243,7 +248,7 @@ class VbanVMParamStrip:
|
|||||||
for i in range(6)
|
for i in range(6)
|
||||||
)
|
)
|
||||||
|
|
||||||
@property
|
@cached_property
|
||||||
def sends(self) -> Sends:
|
def sends(self) -> Sends:
|
||||||
return Sends(
|
return Sends(
|
||||||
round(int.from_bytes(self._send_reverb, 'little', signed=True) * 0.01, 2),
|
round(int.from_bytes(self._send_reverb, 'little', signed=True) * 0.01, 2),
|
||||||
@ -252,11 +257,7 @@ class VbanVMParamStrip:
|
|||||||
round(int.from_bytes(self._send_fx2, 'little', signed=True) * 0.01, 2),
|
round(int.from_bytes(self._send_fx2, 'little', signed=True) * 0.01, 2),
|
||||||
)
|
)
|
||||||
|
|
||||||
@property
|
@cached_property
|
||||||
def karaoke(self) -> int:
|
|
||||||
return int.from_bytes(self._nKaraoke, 'little')
|
|
||||||
|
|
||||||
@property
|
|
||||||
def compressor(self) -> CompressorSettings:
|
def compressor(self) -> CompressorSettings:
|
||||||
return CompressorSettings(
|
return CompressorSettings(
|
||||||
gain_in=round(
|
gain_in=round(
|
||||||
@ -276,7 +277,7 @@ class VbanVMParamStrip:
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
@property
|
@cached_property
|
||||||
def gate(self) -> GateSettings:
|
def gate(self) -> GateSettings:
|
||||||
return GateSettings(
|
return GateSettings(
|
||||||
threshold_in=round(
|
threshold_in=round(
|
||||||
@ -295,7 +296,7 @@ class VbanVMParamStrip:
|
|||||||
release_ms=round(int.from_bytes(self._GATE_release_ms, 'little') * 0.1, 2),
|
release_ms=round(int.from_bytes(self._GATE_release_ms, 'little') * 0.1, 2),
|
||||||
)
|
)
|
||||||
|
|
||||||
@property
|
@cached_property
|
||||||
def denoiser(self) -> DenoiserSettings:
|
def denoiser(self) -> DenoiserSettings:
|
||||||
return DenoiserSettings(
|
return DenoiserSettings(
|
||||||
threshold=round(
|
threshold=round(
|
||||||
@ -303,7 +304,7 @@ class VbanVMParamStrip:
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@property
|
@cached_property
|
||||||
def pitch(self) -> PitchSettings:
|
def pitch(self) -> PitchSettings:
|
||||||
return PitchSettings(
|
return PitchSettings(
|
||||||
enabled=bool(int.from_bytes(self._PitchEnabled, 'little')),
|
enabled=bool(int.from_bytes(self._PitchEnabled, 'little')),
|
||||||
@ -327,8 +328,8 @@ class VbanVMParamStrip:
|
|||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class VbanPacketNBS1(VbanPacket):
|
class VbanRTPacketNBS1(VbanRTPacket):
|
||||||
"""Represents the body of a VBAN data packet with ident:1"""
|
"""Represents the body of a VBAN RTPacket with ident:1"""
|
||||||
|
|
||||||
strips: tuple[VbanVMParamStrip, ...]
|
strips: tuple[VbanVMParamStrip, ...]
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
import struct
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
|
|
||||||
@ -65,30 +66,31 @@ class VbanPing0Payload:
|
|||||||
"""Convert payload to bytes"""
|
"""Convert payload to bytes"""
|
||||||
payload = cls()
|
payload = cls()
|
||||||
|
|
||||||
data = bytearray()
|
return struct.pack(
|
||||||
data.extend(payload.bit_type.to_bytes(4, 'little'))
|
'<7I4s8s8s8s8s64s32s2H64s64s64s64s128s128s',
|
||||||
data.extend(payload.bit_feature.to_bytes(4, 'little'))
|
payload.bit_type,
|
||||||
data.extend(payload.bit_feature_ex.to_bytes(4, 'little'))
|
payload.bit_feature,
|
||||||
data.extend(payload.preferred_rate.to_bytes(4, 'little'))
|
payload.bit_feature_ex,
|
||||||
data.extend(payload.min_rate.to_bytes(4, 'little'))
|
payload.preferred_rate,
|
||||||
data.extend(payload.max_rate.to_bytes(4, 'little'))
|
payload.min_rate,
|
||||||
data.extend(payload.color_rgb.to_bytes(4, 'little'))
|
payload.max_rate,
|
||||||
data.extend(payload.version)
|
payload.color_rgb,
|
||||||
data.extend(payload.gps_position)
|
payload.version,
|
||||||
data.extend(payload.user_position)
|
payload.gps_position,
|
||||||
data.extend(payload.lang_code)
|
payload.user_position,
|
||||||
data.extend(payload.reserved)
|
payload.lang_code,
|
||||||
data.extend(payload.reserved_ex)
|
payload.reserved,
|
||||||
data.extend(payload.distant_ip)
|
payload.reserved_ex,
|
||||||
data.extend(payload.distant_port.to_bytes(2, 'little'))
|
payload.distant_ip,
|
||||||
data.extend(payload.distant_reserved.to_bytes(2, 'little'))
|
payload.distant_port,
|
||||||
data.extend(payload.device_name)
|
payload.distant_reserved,
|
||||||
data.extend(payload.manufacturer_name)
|
payload.device_name,
|
||||||
data.extend(payload.application_name)
|
payload.manufacturer_name,
|
||||||
data.extend(payload.host_name)
|
payload.application_name,
|
||||||
data.extend(payload.user_name)
|
payload.host_name,
|
||||||
data.extend(payload.user_comment)
|
payload.user_name,
|
||||||
return bytes(data)
|
payload.user_comment,
|
||||||
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create_packet(cls, framecounter: int) -> bytes:
|
def create_packet(cls, framecounter: int) -> bytes:
|
||||||
|
|||||||
@ -1,13 +1,16 @@
|
|||||||
|
import socket
|
||||||
import time
|
import time
|
||||||
from typing import Iterator
|
from typing import Iterator
|
||||||
|
|
||||||
|
from .error import VBANCMDConnectionError
|
||||||
|
|
||||||
def ratelimit(func):
|
|
||||||
"""ratelimit decorator for {VbanCmd}.sendtext, to prevent flooding the network with script requests."""
|
def script_ratelimit(func):
|
||||||
|
"""script_ratelimit decorator for {VbanCmd}.sendtext, to prevent flooding the network with script requests."""
|
||||||
|
|
||||||
def wrapper(*args, **kwargs):
|
def wrapper(*args, **kwargs):
|
||||||
self, *rem = args
|
self, *rem = args
|
||||||
if self.script_ratelimit > 0:
|
if self.script_ratelimit:
|
||||||
now = time.time()
|
now = time.time()
|
||||||
elapsed = now - self._last_script_request_time
|
elapsed = now - self._last_script_request_time
|
||||||
if elapsed < self.script_ratelimit:
|
if elapsed < self.script_ratelimit:
|
||||||
@ -18,6 +21,43 @@ def ratelimit(func):
|
|||||||
return wrapper
|
return wrapper
|
||||||
|
|
||||||
|
|
||||||
|
def pong_timeout(func):
|
||||||
|
"""pong_timeout decorator for {VbanCmd}._handle_pong, to handle timeout logic and socket management."""
|
||||||
|
|
||||||
|
def wrapper(self, timeout: float = None):
|
||||||
|
if timeout is None:
|
||||||
|
timeout = min(self.timeout, 3.0)
|
||||||
|
|
||||||
|
original_timeout = self.sock.gettimeout()
|
||||||
|
self.sock.settimeout(0.5)
|
||||||
|
|
||||||
|
try:
|
||||||
|
start_time = time.time()
|
||||||
|
response_count = 0
|
||||||
|
|
||||||
|
while time.time() - start_time < timeout:
|
||||||
|
try:
|
||||||
|
response_count += 1
|
||||||
|
|
||||||
|
if func(self):
|
||||||
|
return
|
||||||
|
|
||||||
|
except socket.timeout:
|
||||||
|
continue
|
||||||
|
|
||||||
|
self.logger.debug(
|
||||||
|
f'PING timeout after {timeout}s, received {response_count} non-PONG packets'
|
||||||
|
)
|
||||||
|
raise VBANCMDConnectionError(
|
||||||
|
f'PING timeout: No response from {self.host}:{self.port} after {timeout}s'
|
||||||
|
)
|
||||||
|
|
||||||
|
finally:
|
||||||
|
self.sock.settimeout(original_timeout)
|
||||||
|
|
||||||
|
return wrapper
|
||||||
|
|
||||||
|
|
||||||
def cache_bool(func, param):
|
def cache_bool(func, param):
|
||||||
"""Check cache for a bool prop"""
|
"""Check cache for a bool prop"""
|
||||||
|
|
||||||
@ -84,16 +124,11 @@ def comp(t0: tuple, t1: tuple) -> Iterator[bool]:
|
|||||||
"""
|
"""
|
||||||
Generator function, accepts two tuples of dB values.
|
Generator function, accepts two tuples of dB values.
|
||||||
|
|
||||||
Evaluates equality of each member in both tuples.
|
Returns True when levels are equal (no change), False when different.
|
||||||
Only ignores changes when levels are very quiet (below -72 dB).
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
for a, b in zip(t0, t1):
|
for a, b in zip(t0, t1):
|
||||||
# If both values are very quiet (below -72dB), ignore small changes
|
yield a == b
|
||||||
if a <= -72.0 and b <= -72.0:
|
|
||||||
yield a == b # Both quiet, check if they're equal
|
|
||||||
else:
|
|
||||||
yield a != b # At least one has significant level, detect changes
|
|
||||||
|
|
||||||
|
|
||||||
def deep_merge(dict1, dict2):
|
def deep_merge(dict1, dict2):
|
||||||
|
|||||||
@ -13,11 +13,11 @@ from .event import Event
|
|||||||
from .packet.headers import (
|
from .packet.headers import (
|
||||||
VbanMatrixResponseHeader,
|
VbanMatrixResponseHeader,
|
||||||
VbanPongHeader,
|
VbanPongHeader,
|
||||||
VbanRequestHeader,
|
VbanRTRequestHeader,
|
||||||
)
|
)
|
||||||
from .packet.ping0 import VbanPing0Payload, VbanServerType
|
from .packet.ping0 import VbanPing0Payload, VbanServerType
|
||||||
from .subject import Subject
|
from .subject import Subject
|
||||||
from .util import bump_framecounter, deep_merge, ratelimit
|
from .util import bump_framecounter, deep_merge, pong_timeout, script_ratelimit
|
||||||
from .worker import Producer, Subscriber, Updater
|
from .worker import Producer, Subscriber, Updater
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@ -27,13 +27,6 @@ class VbanCmd(abc.ABC):
|
|||||||
"""Abstract Base Class for Voicemeeter VBAN Command Interfaces"""
|
"""Abstract Base Class for Voicemeeter VBAN Command Interfaces"""
|
||||||
|
|
||||||
DELAY = 0.001
|
DELAY = 0.001
|
||||||
# fmt: off
|
|
||||||
BPS_OPTS = [
|
|
||||||
0, 110, 150, 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 31250,
|
|
||||||
38400, 57600, 115200, 128000, 230400, 250000, 256000, 460800, 921600,
|
|
||||||
1000000, 1500000, 2000000, 3000000,
|
|
||||||
]
|
|
||||||
# fmt: on
|
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
self.logger = logger.getChild(self.__class__.__name__)
|
self.logger = logger.getChild(self.__class__.__name__)
|
||||||
@ -43,6 +36,13 @@ class VbanCmd(abc.ABC):
|
|||||||
for attr, val in kwargs.items():
|
for attr, val in kwargs.items():
|
||||||
setattr(self, attr, val)
|
setattr(self, attr, val)
|
||||||
|
|
||||||
|
try:
|
||||||
|
self._host_ip = socket.gethostbyname(self.host)
|
||||||
|
except socket.gaierror as e:
|
||||||
|
raise VBANCMDConnectionError(
|
||||||
|
f'Unable to resolve hostname {self.host}'
|
||||||
|
) from e
|
||||||
|
|
||||||
self._framecounter = 0
|
self._framecounter = 0
|
||||||
self._framecounter_lock = threading.Lock()
|
self._framecounter_lock = threading.Lock()
|
||||||
self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||||
@ -56,10 +56,10 @@ class VbanCmd(abc.ABC):
|
|||||||
self.producer = None
|
self.producer = None
|
||||||
self._last_script_request_time = 0
|
self._last_script_request_time = 0
|
||||||
|
|
||||||
|
@property
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def __str__(self):
|
def steps(self):
|
||||||
"""Ensure subclasses override str magic method"""
|
"""Steps required to build the interface for this Voicemeeter kind"""
|
||||||
pass
|
|
||||||
|
|
||||||
def _conn_from_toml(self) -> dict:
|
def _conn_from_toml(self) -> dict:
|
||||||
try:
|
try:
|
||||||
@ -97,6 +97,7 @@ class VbanCmd(abc.ABC):
|
|||||||
If the server is detected as Matrix, RT listeners will be disabled for compatibility.
|
If the server is detected as Matrix, RT listeners will be disabled for compatibility.
|
||||||
"""
|
"""
|
||||||
self._ping()
|
self._ping()
|
||||||
|
self._handle_pong()
|
||||||
|
|
||||||
if not self.disable_rt_listeners:
|
if not self.disable_rt_listeners:
|
||||||
self.event.info()
|
self.event.info()
|
||||||
@ -138,72 +139,44 @@ class VbanCmd(abc.ABC):
|
|||||||
self._framecounter = bump_framecounter(self._framecounter)
|
self._framecounter = bump_framecounter(self._framecounter)
|
||||||
return current
|
return current
|
||||||
|
|
||||||
def _ping(self, timeout: float = None) -> None:
|
def _ping(self):
|
||||||
"""Send a PING packet and wait for PONG response to verify connectivity."""
|
"""Initiates the PING/PONG handshake with the VBAN server."""
|
||||||
if timeout is None:
|
|
||||||
timeout = min(self.timeout, 3.0)
|
|
||||||
|
|
||||||
ping_packet = VbanPing0Payload.create_packet(self._get_next_framecounter())
|
|
||||||
|
|
||||||
original_timeout = self.sock.gettimeout()
|
|
||||||
self.sock.settimeout(0.5)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.sock.sendto(ping_packet, (socket.gethostbyname(self.host), self.port))
|
self.sock.sendto(
|
||||||
|
VbanPing0Payload.create_packet(self._get_next_framecounter()),
|
||||||
|
(self._host_ip, self.port),
|
||||||
|
)
|
||||||
self.logger.debug(f'PING sent to {self.host}:{self.port}')
|
self.logger.debug(f'PING sent to {self.host}:{self.port}')
|
||||||
|
|
||||||
start_time = time.time()
|
|
||||||
response_count = 0
|
|
||||||
while time.time() - start_time < timeout:
|
|
||||||
try:
|
|
||||||
data, addr = self.sock.recvfrom(2048)
|
|
||||||
response_count += 1
|
|
||||||
|
|
||||||
self.logger.debug(
|
|
||||||
f'Received packet #{response_count} from {addr}: {len(data)} bytes'
|
|
||||||
)
|
|
||||||
self.logger.debug(
|
|
||||||
f'Response header: {data[: min(32, len(data))].hex()}'
|
|
||||||
)
|
|
||||||
|
|
||||||
if VbanPongHeader.is_pong_response(data):
|
|
||||||
self.logger.debug(
|
|
||||||
f'PONG received from {addr}, connectivity confirmed'
|
|
||||||
)
|
|
||||||
|
|
||||||
server_type = VbanPing0Payload.detect_server_type(data)
|
|
||||||
self._handle_server_type(server_type)
|
|
||||||
|
|
||||||
return # Exit after successful PONG response
|
|
||||||
else:
|
|
||||||
if len(data) >= 8:
|
|
||||||
if data[:4] == b'VBAN':
|
|
||||||
protocol = data[4] & 0xE0
|
|
||||||
nbc = data[6]
|
|
||||||
self.logger.debug(
|
|
||||||
f'Non-PONG VBAN packet: protocol=0x{protocol:02x}, nbc=0x{nbc:02x}'
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
self.logger.debug('Non-VBAN packet received')
|
|
||||||
|
|
||||||
except socket.timeout:
|
|
||||||
continue
|
|
||||||
|
|
||||||
self.logger.debug(
|
|
||||||
f'PING timeout after {timeout}s, received {response_count} non-PONG packets'
|
|
||||||
)
|
|
||||||
raise VBANCMDConnectionError(
|
|
||||||
f'PING timeout: No response from {self.host}:{self.port} after {timeout}s'
|
|
||||||
)
|
|
||||||
|
|
||||||
except socket.gaierror as e:
|
|
||||||
raise VBANCMDConnectionError(
|
|
||||||
f'Unable to resolve hostname {self.host}'
|
|
||||||
) from e
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise VBANCMDConnectionError(f'PING failed: {e}') from e
|
raise VBANCMDConnectionError(f'PING failed: {e}') from e
|
||||||
finally:
|
|
||||||
self.sock.settimeout(original_timeout)
|
@pong_timeout
|
||||||
|
def _handle_pong(self) -> bool:
|
||||||
|
"""Handles incoming packets during the PING/PONG handshake, looking for a valid PONG response to confirm connectivity and detect server type.
|
||||||
|
|
||||||
|
Returns True if a valid PONG is received, False otherwise."""
|
||||||
|
data, addr = self.sock.recvfrom(2048)
|
||||||
|
|
||||||
|
if VbanPongHeader.is_pong_response(data):
|
||||||
|
self.logger.debug(f'PONG received from {addr}, connectivity confirmed')
|
||||||
|
|
||||||
|
server_type = VbanPing0Payload.detect_server_type(data)
|
||||||
|
self._handle_server_type(server_type)
|
||||||
|
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
if len(data) >= 8:
|
||||||
|
if data[:4] == b'VBAN':
|
||||||
|
protocol = data[4] & 0xE0
|
||||||
|
nbc = data[6]
|
||||||
|
self.logger.debug(
|
||||||
|
f'Non-PONG VBAN packet: protocol=0x{protocol:02x}, nbc=0x{nbc:02x}'
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
self.logger.debug('Non-VBAN packet received')
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
def _handle_server_type(self, server_type: VbanServerType) -> None:
|
def _handle_server_type(self, server_type: VbanServerType) -> None:
|
||||||
"""Handle the detected server type by adjusting settings accordingly."""
|
"""Handle the detected server type by adjusting settings accordingly."""
|
||||||
@ -225,14 +198,14 @@ class VbanCmd(abc.ABC):
|
|||||||
def _send_request(self, payload: str) -> None:
|
def _send_request(self, payload: str) -> None:
|
||||||
"""Sends a request packet over the network and bumps the framecounter."""
|
"""Sends a request packet over the network and bumps the framecounter."""
|
||||||
self.sock.sendto(
|
self.sock.sendto(
|
||||||
VbanRequestHeader.encode_with_payload(
|
VbanRTRequestHeader.encode_with_payload(
|
||||||
name=self.streamname,
|
name=self.streamname,
|
||||||
bps_index=self.BPS_OPTS.index(self.bps),
|
bps=self.bps,
|
||||||
channel=self.channel,
|
channel=self.channel,
|
||||||
framecounter=self._get_next_framecounter(),
|
framecounter=self._get_next_framecounter(),
|
||||||
payload=payload,
|
payload=payload,
|
||||||
),
|
),
|
||||||
(socket.gethostbyname(self.host), self.port),
|
(self._host_ip, self.port),
|
||||||
)
|
)
|
||||||
|
|
||||||
def _set_rt(self, cmd: str, val: Union[str, float]):
|
def _set_rt(self, cmd: str, val: Union[str, float]):
|
||||||
@ -240,7 +213,7 @@ class VbanCmd(abc.ABC):
|
|||||||
self._send_request(f'{cmd}={val};')
|
self._send_request(f'{cmd}={val};')
|
||||||
self.cache[cmd] = val
|
self.cache[cmd] = val
|
||||||
|
|
||||||
@ratelimit
|
@script_ratelimit
|
||||||
def sendtext(self, script) -> str | None:
|
def sendtext(self, script) -> str | None:
|
||||||
"""Sends a multiple parameter string over a network."""
|
"""Sends a multiple parameter string over a network."""
|
||||||
self._send_request(script)
|
self._send_request(script)
|
||||||
@ -249,7 +222,7 @@ class VbanCmd(abc.ABC):
|
|||||||
if self.disable_rt_listeners and script.endswith(('?', '?;')):
|
if self.disable_rt_listeners and script.endswith(('?', '?;')):
|
||||||
try:
|
try:
|
||||||
data, _ = self.sock.recvfrom(2048)
|
data, _ = self.sock.recvfrom(2048)
|
||||||
payload = VbanMatrixResponseHeader.extract_payload(data)
|
return VbanMatrixResponseHeader.extract_payload(data)
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
self.logger.warning(f'Error extracting matrix response: {e}')
|
self.logger.warning(f'Error extracting matrix response: {e}')
|
||||||
except TimeoutError as e:
|
except TimeoutError as e:
|
||||||
@ -257,7 +230,6 @@ class VbanCmd(abc.ABC):
|
|||||||
raise VBANCMDConnectionError(
|
raise VBANCMDConnectionError(
|
||||||
f'Timeout waiting for response from {self.host}:{self.port}'
|
f'Timeout waiting for response from {self.host}:{self.port}'
|
||||||
) from e
|
) from e
|
||||||
return payload
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def type(self) -> str:
|
def type(self) -> str:
|
||||||
@ -312,7 +284,6 @@ class VbanCmd(abc.ABC):
|
|||||||
|
|
||||||
for key, di in data.items():
|
for key, di in data.items():
|
||||||
target(key).apply(di)
|
target(key).apply(di)
|
||||||
time.sleep(self.DELAY)
|
|
||||||
|
|
||||||
def apply_config(self, name):
|
def apply_config(self, name):
|
||||||
"""applies a config from memory"""
|
"""applies a config from memory"""
|
||||||
|
|||||||
@ -3,15 +3,16 @@ import threading
|
|||||||
import time
|
import time
|
||||||
|
|
||||||
from .enums import NBS
|
from .enums import NBS
|
||||||
from .error import VBANCMDConnectionError
|
from .error import VBANCMDConnectionError, VBANCMDPacketError
|
||||||
|
from .packet.enums import SubProtocols
|
||||||
from .packet.headers import (
|
from .packet.headers import (
|
||||||
HEADER_SIZE,
|
HEADER_SIZE,
|
||||||
VbanPacket,
|
VbanRTPacket,
|
||||||
VbanResponseHeader,
|
VbanRTResponseHeader,
|
||||||
VbanSubscribeHeader,
|
VbanRTSubscribeHeader,
|
||||||
)
|
)
|
||||||
from .packet.nbs0 import VbanPacketNBS0
|
from .packet.nbs0 import VbanRTPacketNBS0
|
||||||
from .packet.nbs1 import VbanPacketNBS1
|
from .packet.nbs1 import VbanRTPacketNBS1
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -28,11 +29,11 @@ class Subscriber(threading.Thread):
|
|||||||
def run(self):
|
def run(self):
|
||||||
while not self.stopped():
|
while not self.stopped():
|
||||||
for nbs in NBS:
|
for nbs in NBS:
|
||||||
sub_packet = VbanSubscribeHeader().to_bytes(
|
sub_packet = VbanRTSubscribeHeader().to_bytes(
|
||||||
nbs, self._remote._get_next_framecounter()
|
nbs, self._remote._get_next_framecounter()
|
||||||
)
|
)
|
||||||
self._remote.sock.sendto(
|
self._remote.sock.sendto(
|
||||||
sub_packet, (self._remote.host, self._remote.port)
|
sub_packet, (self._remote._host_ip, self._remote.port)
|
||||||
)
|
)
|
||||||
|
|
||||||
self.wait_until_stopped(10)
|
self.wait_until_stopped(10)
|
||||||
@ -66,7 +67,7 @@ class Producer(threading.Thread):
|
|||||||
self._remote.cache['bus_level'],
|
self._remote.cache['bus_level'],
|
||||||
) = self._remote.public_packets[NBS.zero].levels
|
) = self._remote.public_packets[NBS.zero].levels
|
||||||
|
|
||||||
def _get_rt(self) -> VbanPacket:
|
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"""
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
@ -80,19 +81,24 @@ class Producer(threading.Thread):
|
|||||||
) from e
|
) from e
|
||||||
|
|
||||||
try:
|
try:
|
||||||
header = VbanResponseHeader.from_bytes(data[:HEADER_SIZE])
|
header = VbanRTResponseHeader.from_bytes(data[:HEADER_SIZE])
|
||||||
except ValueError as e:
|
except VBANCMDPacketError as e:
|
||||||
self.logger.debug(f'Error parsing response packet: {e}')
|
match e.protocol:
|
||||||
|
case SubProtocols.SERVICE:
|
||||||
|
# Silently ignore periodic SERVICE packets unrelated to vban-cmd
|
||||||
|
pass
|
||||||
|
case _:
|
||||||
|
self.logger.debug(f'Error parsing response packet: {e}')
|
||||||
continue
|
continue
|
||||||
|
|
||||||
match header.format_nbs:
|
match header.format_nbs:
|
||||||
case NBS.zero:
|
case NBS.zero:
|
||||||
return VbanPacketNBS0.from_bytes(
|
return VbanRTPacketNBS0.from_bytes(
|
||||||
nbs=NBS.zero, kind=self._remote.kind, data=data
|
nbs=NBS.zero, kind=self._remote.kind, data=data
|
||||||
)
|
)
|
||||||
|
|
||||||
case NBS.one:
|
case NBS.one:
|
||||||
return VbanPacketNBS1.from_bytes(
|
return VbanRTPacketNBS1.from_bytes(
|
||||||
nbs=NBS.one, kind=self._remote.kind, data=data
|
nbs=NBS.one, kind=self._remote.kind, data=data
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user