mirror of
https://github.com/onyx-and-iris/xair-api-python.git
synced 2026-04-20 06:23:31 +00:00
Compare commits
9 Commits
fd4a228086
...
v2.4.2
| Author | SHA1 | Date | |
|---|---|---|---|
| deb298537f | |||
| f963997f35 | |||
| 39f3a9dd98 | |||
|
|
6cccfd0f56 | ||
| 05df111e69 | |||
| 2b91863337 | |||
| cf4a1d295f | |||
| b5b5633577 | |||
| 7b6e70028b |
53
.github/workflows/publish.yml
vendored
Normal file
53
.github/workflows/publish.yml
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
name: Publish to PyPI
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
push:
|
||||
tags:
|
||||
- 'v*.*.*'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.11'
|
||||
|
||||
- name: Install Poetry
|
||||
run: |
|
||||
pip install poetry==2.3.1
|
||||
poetry --version
|
||||
|
||||
- name: Build package
|
||||
run: |
|
||||
poetry install --only-root
|
||||
poetry build
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: dist
|
||||
path: ./dist
|
||||
|
||||
pypi-publish:
|
||||
needs: build
|
||||
name: Upload release to PyPI
|
||||
runs-on: ubuntu-latest
|
||||
environment:
|
||||
name: pypi
|
||||
url: https://pypi.org/p/xair-api
|
||||
permissions:
|
||||
id-token: write
|
||||
steps:
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: dist
|
||||
path: ./dist
|
||||
|
||||
- name: Publish package distributions to PyPI
|
||||
uses: pypa/gh-action-pypi-publish@release/v1
|
||||
with:
|
||||
packages-dir: ./dist
|
||||
19
.github/workflows/ruff.yml
vendored
Normal file
19
.github/workflows/ruff.yml
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
name: Ruff
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
|
||||
pull_request:
|
||||
branches: [main]
|
||||
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
ruff:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: astral-sh/ruff-action@v3
|
||||
with:
|
||||
args: 'format --check --diff'
|
||||
4
.gitignore
vendored
4
.gitignore
vendored
@@ -130,6 +130,8 @@ dmypy.json
|
||||
|
||||
# config, quick test
|
||||
config.toml
|
||||
quick.py
|
||||
test-*.py
|
||||
tools/*
|
||||
!tools/README.md
|
||||
|
||||
.vscode/
|
||||
13
README.md
13
README.md
@@ -1,5 +1,6 @@
|
||||
[](https://badge.fury.io/py/xair-api)
|
||||
[](https://github.com/onyx-and-iris/xair-api-python/blob/dev/LICENSE)
|
||||
[](https://python-poetry.org/)
|
||||
[](https://github.com/astral-sh/ruff)
|
||||

|
||||
|
||||
@@ -338,14 +339,14 @@ print(mixer.query('/ch/01/mix/on'))
|
||||
|
||||
### `Tests`
|
||||
|
||||
Unplug any expensive equipment before running tests.
|
||||
Save your current settings to a snapshot first.
|
||||
Install [poetry](https://python-poetry.org/docs/#installation) and then:
|
||||
|
||||
First make sure you installed the [development dependencies](https://github.com/onyx-and-iris/xair-api-python#installation)
|
||||
```powershell
|
||||
poetry poe test-xair
|
||||
poetry poe test-x32
|
||||
```
|
||||
|
||||
To run all tests:
|
||||
|
||||
`pytest -v`.
|
||||
Unplug any expensive equipment and save your current settings to a snapshot first.
|
||||
|
||||
## License
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ password = "mystrongpass"
|
||||
|
||||
## Use
|
||||
|
||||
Change the xair ip argument from `mixer.local` to the ip of your xair mixer. Run the code and switch between scenes in OBS.
|
||||
Change the xair ip argument from `mixer.local` to the ip of your xair mixer. Run the code and switch between scenes in OBS. Closing OBS will end the script.
|
||||
|
||||
## Notes
|
||||
|
||||
|
||||
@@ -1,13 +1,48 @@
|
||||
import obsws_python as obs
|
||||
import threading
|
||||
from logging import config
|
||||
|
||||
import obsws_python as obsws
|
||||
|
||||
import xair_api
|
||||
|
||||
config.dictConfig(
|
||||
{
|
||||
'version': 1,
|
||||
'formatters': {
|
||||
'standard': {
|
||||
'format': '%(asctime)s,%(msecs)d %(name)s %(levelname)s %(message)s'
|
||||
}
|
||||
},
|
||||
'handlers': {
|
||||
'stream': {
|
||||
'level': 'DEBUG',
|
||||
'class': 'logging.StreamHandler',
|
||||
'formatter': 'standard',
|
||||
}
|
||||
},
|
||||
'loggers': {
|
||||
'xair_api.xair': {
|
||||
'handlers': ['stream'],
|
||||
'level': 'DEBUG',
|
||||
'propagate': False,
|
||||
}
|
||||
},
|
||||
'root': {'handlers': ['stream'], 'level': 'WARNING'},
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
class Observer:
|
||||
def __init__(self, mixer):
|
||||
def __init__(self, mixer, stop_event):
|
||||
self._mixer = mixer
|
||||
self._client = obs.EventClient()
|
||||
self._client.callback.register(self.on_current_program_scene_changed)
|
||||
self._stop_event = stop_event
|
||||
self._client = obsws.EventClient()
|
||||
self._client.callback.register(
|
||||
(
|
||||
self.on_current_program_scene_changed,
|
||||
self.on_exit_started,
|
||||
)
|
||||
)
|
||||
|
||||
def __enter__(self):
|
||||
return self
|
||||
@@ -32,12 +67,16 @@ class Observer:
|
||||
self._mixer.config.mute_group[0].on = True
|
||||
print(f'Mute Group 1 is {self._mixer.config.mute_group[0].on}')
|
||||
|
||||
def on_exit_started(self, _):
|
||||
self._stop_event.set()
|
||||
|
||||
|
||||
def main():
|
||||
with xair_api.connect('MR18', ip='mixer.local') as mixer:
|
||||
with Observer(mixer):
|
||||
while _ := input('Press <Enter> to exit\n'):
|
||||
pass
|
||||
stop_event = threading.Event()
|
||||
|
||||
with Observer(mixer, stop_event):
|
||||
stop_event.wait()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
27
poetry.lock
generated
27
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]]
|
||||
name = "cachetools"
|
||||
@@ -55,7 +55,7 @@ description = "Backport of PEP 654 (exception groups)"
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
groups = ["dev"]
|
||||
markers = "python_version < \"3.11\""
|
||||
markers = "python_version == \"3.10\""
|
||||
files = [
|
||||
{file = "exceptiongroup-1.2.2-py3-none-any.whl", hash = "sha256:3111b9d131c238bec2f8f516e123e14ba243563fb135d3fe885990585aa7795b"},
|
||||
{file = "exceptiongroup-1.2.2.tar.gz", hash = "sha256:47c2edf7c6738fafb49fd34290706d1a1a2f4d1c6df275526b62cbb4aa5393cc"},
|
||||
@@ -66,21 +66,16 @@ test = ["pytest (>=6)"]
|
||||
|
||||
[[package]]
|
||||
name = "filelock"
|
||||
version = "3.16.1"
|
||||
version = "3.20.1"
|
||||
description = "A platform independent file lock."
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
python-versions = ">=3.10"
|
||||
groups = ["dev"]
|
||||
files = [
|
||||
{file = "filelock-3.16.1-py3-none-any.whl", hash = "sha256:2082e5703d51fbf98ea75855d9d5527e33d8ff23099bec374a134febee6946b0"},
|
||||
{file = "filelock-3.16.1.tar.gz", hash = "sha256:c249fbfcd5db47e5e2d6d62198e565475ee65e4831e2561c8e313fa7eb961435"},
|
||||
{file = "filelock-3.20.1-py3-none-any.whl", hash = "sha256:15d9e9a67306188a44baa72f569d2bfd803076269365fdea0934385da4dc361a"},
|
||||
{file = "filelock-3.20.1.tar.gz", hash = "sha256:b8360948b351b80f420878d8516519a2204b07aefcdcfd24912a5d33127f188c"},
|
||||
]
|
||||
|
||||
[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]]
|
||||
name = "iniconfig"
|
||||
version = "2.0.0"
|
||||
@@ -255,7 +250,7 @@ description = "A lil' TOML parser"
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
groups = ["main", "dev"]
|
||||
markers = "python_version < \"3.11\""
|
||||
markers = "python_version == \"3.10\""
|
||||
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_11_0_arm64.whl", hash = "sha256:023aa114dd824ade0100497eb2318602af309e5a55595f76b626d6d9f3b7b0a6"},
|
||||
@@ -326,7 +321,7 @@ description = "Backported and Experimental Type Hints for Python 3.8+"
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
groups = ["dev"]
|
||||
markers = "python_version < \"3.11\""
|
||||
markers = "python_version == \"3.10\""
|
||||
files = [
|
||||
{file = "typing_extensions-4.12.2-py3-none-any.whl", hash = "sha256:04e5ca0351e0f3f85c6853954072df659d0d13fac324d0072316b67d7794700d"},
|
||||
{file = "typing_extensions-4.12.2.tar.gz", hash = "sha256:1a7ead55c7e559dd4dee8856e3a88b41225abfe1ce8df57b7c13915fe121ffb8"},
|
||||
@@ -351,7 +346,7 @@ platformdirs = ">=3.9.1,<5"
|
||||
|
||||
[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)"]
|
||||
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 == \"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]]
|
||||
name = "virtualenv-pyenv"
|
||||
@@ -371,5 +366,5 @@ virtualenv = "*"
|
||||
|
||||
[metadata]
|
||||
lock-version = "2.1"
|
||||
python-versions = "<4.0,>=3.10"
|
||||
content-hash = "6cd4c5329b1df022fdec343a52a0fda804c33234b208aab94025e6798ea6820d"
|
||||
python-versions = ">=3.10"
|
||||
content-hash = "dbba803b0ac29e3120c3f302260b600a8ef58bfac91c41a58f242804f17b89ba"
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
[project]
|
||||
name = "xair-api"
|
||||
version = "2.4.1"
|
||||
version = "2.4.2"
|
||||
description = "Remote control Behringer X-Air | Midas MR mixers through OSC"
|
||||
authors = [
|
||||
{name = "Onyx and Iris",email = "code@onyxandiris.online"}
|
||||
]
|
||||
authors = [{ name = "Onyx and Iris", email = "code@onyxandiris.online" }]
|
||||
license = { text = "MIT" }
|
||||
readme = "README.md"
|
||||
requires-python = "<4.0,>=3.10"
|
||||
requires-python = ">=3.10"
|
||||
dependencies = [
|
||||
"python-osc (>=1.9.3,<2.0.0)",
|
||||
"tomli (>=2.0.1,<3.0) ; python_version < '3.11'"
|
||||
"tomli (>=2.0.1,<3.0) ; python_version < '3.11'",
|
||||
]
|
||||
|
||||
[tool.poetry.requires-plugins]
|
||||
poethepoet = "^0.32.1"
|
||||
poethepoet = "^0.35.0"
|
||||
|
||||
[tool.poetry.group.dev.dependencies]
|
||||
pytest = "^8.3.4"
|
||||
@@ -31,29 +29,33 @@ build-backend = "poetry.core.masonry.api"
|
||||
obs.script = "scripts:ex_obs"
|
||||
sends.script = "scripts:ex_sends"
|
||||
headamp.script = "scripts:ex_headamp"
|
||||
xair.script = "scripts:test_xair"
|
||||
x32.script = "scripts:test_x32"
|
||||
all.script = "scripts:test_all"
|
||||
test-xair.script = "scripts:test_xair"
|
||||
test-x32.script = "scripts:test_x32"
|
||||
test-all.script = "scripts:test_all"
|
||||
|
||||
[tool.tox]
|
||||
legacy_tox_ini = """
|
||||
[tox]
|
||||
envlist = py310,py311,py312
|
||||
envlist = py310,py311,py312,py313
|
||||
|
||||
[testenv]
|
||||
passenv =
|
||||
TEST_MODULE
|
||||
setenv = VIRTUALENV_DISCOVERY=pyenv
|
||||
allowlist_externals = poetry
|
||||
commands_pre =
|
||||
poetry install --no-interaction --no-root
|
||||
commands =
|
||||
poetry install -v
|
||||
poetry run pytest tests/
|
||||
poetry run pytest tests/{env:TEST_MODULE}
|
||||
|
||||
[testenv:obs]
|
||||
setenv = VIRTUALENV_DISCOVERY=pyenv
|
||||
allowlist_externals = poetry
|
||||
deps = obsws-python
|
||||
commands_pre =
|
||||
poetry install --no-interaction --no-root --without dev
|
||||
commands =
|
||||
poetry install -v --without dev
|
||||
poetry run python examples/xair_obs/
|
||||
poetry run python examples/xair_obs
|
||||
"""
|
||||
|
||||
[tool.ruff]
|
||||
@@ -133,7 +135,4 @@ docstring-code-line-length = "dynamic"
|
||||
max-complexity = 10
|
||||
|
||||
[tool.ruff.lint.per-file-ignores]
|
||||
"__init__.py" = [
|
||||
"E402",
|
||||
"F401",
|
||||
]
|
||||
"__init__.py" = ["E402", "F401"]
|
||||
|
||||
20
scripts.py
20
scripts.py
@@ -1,31 +1,35 @@
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def ex_obs():
|
||||
subprocess.run(["tox", "r", "-e", "obs"])
|
||||
subprocess.run(['tox', 'r', '-e', 'obs'])
|
||||
|
||||
|
||||
def ex_sends():
|
||||
path = Path.cwd() / "examples" / "sends" / "."
|
||||
path = Path.cwd() / 'examples' / 'sends' / '.'
|
||||
subprocess.run([sys.executable, str(path)])
|
||||
|
||||
|
||||
def ex_headamp():
|
||||
path = Path.cwd() / "examples" / "headamp" / "."
|
||||
path = Path.cwd() / 'examples' / 'headamp' / '.'
|
||||
subprocess.run([sys.executable, str(path)])
|
||||
|
||||
|
||||
def test_xair():
|
||||
path = Path.cwd() / "tests" / "xair"
|
||||
subprocess.run(["pytest", "-v", str(path)])
|
||||
subprocess.run(['tox'], env=os.environ.copy() | {'TEST_MODULE': 'xair'})
|
||||
|
||||
|
||||
def test_x32():
|
||||
path = Path.cwd() / "tests" / "x32"
|
||||
subprocess.run(["pytest", "-v", str(path)])
|
||||
path = Path.cwd() / 'tools' / 'x32.exe'
|
||||
proc = subprocess.Popen([str(path), '-i', 'x32.local'])
|
||||
subprocess.run(['tox'], env=os.environ.copy() | {'TEST_MODULE': 'x32'})
|
||||
proc.terminate()
|
||||
|
||||
|
||||
def test_all():
|
||||
subprocess.run(["tox"])
|
||||
steps = [test_xair, test_x32]
|
||||
for step in steps:
|
||||
step()
|
||||
|
||||
3
tools/README.md
Normal file
3
tools/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# X32 Tests
|
||||
|
||||
Download the [x32 Emulator](https://sites.google.com/site/patrickmaillot/x32#h.p_rE4IH0Luimc0) and place it in this directory in order to run the x32 tests.
|
||||
@@ -525,7 +525,8 @@ class EQ:
|
||||
|
||||
@property
|
||||
def quality(self) -> float:
|
||||
retval = util.log_get(0.3, 10, self.getter('q')[0])
|
||||
raw_value = self.getter('q')[0]
|
||||
retval = util.log_get(0.3, 10, 1.0 - raw_value)
|
||||
return round(retval, 1)
|
||||
|
||||
@quality.setter
|
||||
@@ -534,7 +535,7 @@ class EQ:
|
||||
self.logger.warning(
|
||||
f'quality got {val}, expected value in range 0.3 to 10.0'
|
||||
)
|
||||
self.setter('q', util.log_set(0.3, 10, val))
|
||||
self.setter('q', 1.0 - util.log_set(0.3, 10, val))
|
||||
|
||||
|
||||
class GEQ:
|
||||
|
||||
Reference in New Issue
Block a user