mirror of
https://github.com/onyx-and-iris/xair-api-python.git
synced 2024-11-15 17:40:57 +00:00
delay kwarg added.
delay added to README delay for test suites reduced to 0.008 main stereo added to adapter tests
This commit is contained in:
parent
7015383b98
commit
0b20ac953f
13
README.md
13
README.md
@ -55,7 +55,7 @@ if __name__ == "__main__":
|
|||||||
main()
|
main()
|
||||||
```
|
```
|
||||||
|
|
||||||
## API
|
#### `xair_api.connect(kind_id, ip=ip, delay=delay)`
|
||||||
|
|
||||||
Currently the following devices are supported:
|
Currently the following devices are supported:
|
||||||
|
|
||||||
@ -64,7 +64,16 @@ Currently the following devices are supported:
|
|||||||
- `XR16`
|
- `XR16`
|
||||||
- `XR12`
|
- `XR12`
|
||||||
|
|
||||||
The `X32` is partially supported. This document covers specifically the `XAir` series, however.
|
The `X32` is partially supported. However, this document covers specifically the `XAir` series.
|
||||||
|
|
||||||
|
The following keyword arguments may be passed:
|
||||||
|
|
||||||
|
- `ip`: ip address of the mixer
|
||||||
|
- `port`: mixer port, defaults to 10023 for x32 and 10024 for xair
|
||||||
|
- `delay`: a delay between each command, defaults to 20ms.
|
||||||
|
- a note about delay, stability may rely on network connection. For wired connections the delay can be safely reduced.
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
### XAirRemote class (higher level)
|
### XAirRemote class (higher level)
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ from xair_api import kinds
|
|||||||
kind_id = "X32"
|
kind_id = "X32"
|
||||||
ip = "x32.local"
|
ip = "x32.local"
|
||||||
|
|
||||||
tests = xair_api.connect(kind_id, ip=ip)
|
tests = xair_api.connect(kind_id, ip=ip, delay=0.008)
|
||||||
|
|
||||||
kind = kinds.get(kind_id)
|
kind = kinds.get(kind_id)
|
||||||
|
|
||||||
|
@ -47,20 +47,20 @@ class TestSetAndGetBusConfigHigher:
|
|||||||
""" AUXIN TESTS """
|
""" AUXIN TESTS """
|
||||||
|
|
||||||
|
|
||||||
class TestSetAndGetAuxInConfigHigher:
|
class TestSetAndGetAuxInPreampHigher:
|
||||||
"""Config"""
|
"""Preamp"""
|
||||||
|
|
||||||
__test__ = True
|
__test__ = True
|
||||||
|
|
||||||
def setup_class(self):
|
def setup_class(self):
|
||||||
self.target = getattr(tests, "auxin")
|
self.target = getattr(tests, "auxin")
|
||||||
self.target = getattr(self.target[data.auxrtn], "config")
|
self.target = getattr(self.target[data.auxrtn], "preamp")
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"param,value",
|
"param,value",
|
||||||
[("name", "test0"), ("name", "test1")],
|
[("invert", True), ("invert", False)],
|
||||||
)
|
)
|
||||||
def test_it_sets_and_gets_auxrtn_string_params(self, param, value):
|
def test_it_sets_and_gets_auxrtn_bool_params(self, param, value):
|
||||||
setattr(self.target, param, value)
|
setattr(self.target, param, value)
|
||||||
assert getattr(self.target, param) == value
|
assert getattr(self.target, param) == value
|
||||||
|
|
||||||
@ -68,20 +68,20 @@ class TestSetAndGetAuxInConfigHigher:
|
|||||||
""" FX RETURN TESTS """
|
""" FX RETURN TESTS """
|
||||||
|
|
||||||
|
|
||||||
class TestSetAndGetFXReturnConfigHigher:
|
class TestSetAndGetFXReturnEQHigher:
|
||||||
"""Config"""
|
"""EQ"""
|
||||||
|
|
||||||
__test__ = True
|
__test__ = True
|
||||||
|
|
||||||
def setup_class(self):
|
def setup_class(self):
|
||||||
self.target = getattr(tests, "fxreturn")
|
self.target = getattr(tests, "fxreturn")
|
||||||
self.target = getattr(self.target[data.fx], "config")
|
self.target = getattr(self.target[data.fx], "eq")
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"param,value",
|
"param,value",
|
||||||
[("name", "test0"), ("name", "test1")],
|
[("on", True), ("on", False)],
|
||||||
)
|
)
|
||||||
def test_it_sets_and_gets_fxrtn_string_params(self, param, value):
|
def test_it_sets_and_gets_fxrtn_bool_params(self, param, value):
|
||||||
setattr(self.target, param, value)
|
setattr(self.target, param, value)
|
||||||
assert getattr(self.target, param) == value
|
assert getattr(self.target, param) == value
|
||||||
|
|
||||||
@ -89,19 +89,39 @@ class TestSetAndGetFXReturnConfigHigher:
|
|||||||
""" MATRIX TESTS """
|
""" MATRIX TESTS """
|
||||||
|
|
||||||
|
|
||||||
class TestSetAndGetMatrixConfigHigher:
|
class TestSetAndGetMatrixDynHigher:
|
||||||
"""Config"""
|
"""Dyn"""
|
||||||
|
|
||||||
__test__ = True
|
__test__ = True
|
||||||
|
|
||||||
def setup_class(self):
|
def setup_class(self):
|
||||||
self.target = getattr(tests, "matrix")
|
self.target = getattr(tests, "matrix")
|
||||||
self.target = getattr(self.target[data.matrix], "config")
|
self.target = getattr(self.target[data.matrix], "dyn")
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"param,value",
|
"param,value",
|
||||||
[("name", "test0"), ("name", "test1")],
|
[("mode", "comp"), ("mode", "exp")],
|
||||||
)
|
)
|
||||||
def test_it_sets_and_gets_matrix_string_params(self, param, value):
|
def test_it_sets_and_gets_matrix_string_params(self, param, value):
|
||||||
setattr(self.target, param, value)
|
setattr(self.target, param, value)
|
||||||
assert getattr(self.target, param) == value
|
assert getattr(self.target, param) == value
|
||||||
|
|
||||||
|
|
||||||
|
""" MAIN STEREO TESTS """
|
||||||
|
|
||||||
|
|
||||||
|
class TestSetAndGetMainStereoInsertHigher:
|
||||||
|
"""Insert"""
|
||||||
|
|
||||||
|
__test__ = True
|
||||||
|
|
||||||
|
def setup_class(self):
|
||||||
|
self.target = getattr(tests, "mainst")
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"param,value",
|
||||||
|
[("mode", "comp"), ("mode", "exp")],
|
||||||
|
)
|
||||||
|
def test_it_sets_and_gets_mainst_string_params(self, param, value):
|
||||||
|
setattr(self.target, param, value)
|
||||||
|
assert getattr(self.target, param) == value
|
||||||
|
@ -8,7 +8,7 @@ from xair_api import kinds
|
|||||||
kind_id = "MR18"
|
kind_id = "MR18"
|
||||||
ip = "mixer.local"
|
ip = "mixer.local"
|
||||||
|
|
||||||
tests = xair_api.connect(kind_id, ip=ip)
|
tests = xair_api.connect(kind_id, ip=ip, delay=0.008)
|
||||||
|
|
||||||
kind = kinds.get(kind_id)
|
kind = kinds.get(kind_id)
|
||||||
|
|
||||||
|
@ -48,8 +48,6 @@ class XAirRemote(abc.ABC):
|
|||||||
logger = logging.getLogger("xair.xairremote")
|
logger = logging.getLogger("xair.xairremote")
|
||||||
|
|
||||||
_CONNECT_TIMEOUT = 0.5
|
_CONNECT_TIMEOUT = 0.5
|
||||||
_WAIT_TIME = 0.025
|
|
||||||
_REFRESH_TIMEOUT = 5
|
|
||||||
|
|
||||||
_info_response = []
|
_info_response = []
|
||||||
|
|
||||||
@ -58,8 +56,9 @@ class XAirRemote(abc.ABC):
|
|||||||
dispatcher.set_default_handler(self.msg_handler)
|
dispatcher.set_default_handler(self.msg_handler)
|
||||||
self.xair_ip = kwargs["ip"] or self._ip_from_toml()
|
self.xair_ip = kwargs["ip"] or self._ip_from_toml()
|
||||||
self.xair_port = kwargs["port"]
|
self.xair_port = kwargs["port"]
|
||||||
if not (self.xair_ip and self.xair_port):
|
self._delay = kwargs["delay"]
|
||||||
raise XAirRemoteError("No valid ip or password detected")
|
if not self.xair_ip:
|
||||||
|
raise XAirRemoteError("No valid ip detected")
|
||||||
self.server = OSCClientServer((self.xair_ip, self.xair_port), dispatcher)
|
self.server = OSCClientServer((self.xair_ip, self.xair_port), dispatcher)
|
||||||
|
|
||||||
def __enter__(self):
|
def __enter__(self):
|
||||||
@ -79,7 +78,7 @@ class XAirRemote(abc.ABC):
|
|||||||
time.sleep(self._CONNECT_TIMEOUT)
|
time.sleep(self._CONNECT_TIMEOUT)
|
||||||
if not self.info_response:
|
if not self.info_response:
|
||||||
raise XAirRemoteError(
|
raise XAirRemoteError(
|
||||||
"Error: Failed to setup OSC connection to mixer. Please check for correct ip address."
|
"Failed to setup OSC connection to mixer. Please check for correct ip address."
|
||||||
)
|
)
|
||||||
print(
|
print(
|
||||||
f"Successfully connected to {self.info_response[2]} at {self.info_response[0]}."
|
f"Successfully connected to {self.info_response[2]} at {self.info_response[0]}."
|
||||||
@ -99,7 +98,7 @@ class XAirRemote(abc.ABC):
|
|||||||
def send(self, addr: str, param: Optional[str] = None):
|
def send(self, addr: str, param: Optional[str] = None):
|
||||||
self.logger.debug(f"sending: {addr} {param if param is not None else ''}")
|
self.logger.debug(f"sending: {addr} {param if param is not None else ''}")
|
||||||
self.server.send_message(addr, param)
|
self.server.send_message(addr, param)
|
||||||
time.sleep(self._WAIT_TIME)
|
time.sleep(self._delay)
|
||||||
|
|
||||||
def query(self, address):
|
def query(self, address):
|
||||||
self.send(address)
|
self.send(address)
|
||||||
@ -117,7 +116,7 @@ def _make_remote(kind: KindMap) -> XAirRemote:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def init_x32(self, *args, **kwargs):
|
def init_x32(self, *args, **kwargs):
|
||||||
defaultkwargs = {"ip": None, "port": 10023}
|
defaultkwargs = {"ip": None, "port": 10023, "delay": 0.02}
|
||||||
kwargs = defaultkwargs | kwargs
|
kwargs = defaultkwargs | kwargs
|
||||||
XAirRemote.__init__(self, *args, **kwargs)
|
XAirRemote.__init__(self, *args, **kwargs)
|
||||||
self.kind = kind
|
self.kind = kind
|
||||||
@ -135,7 +134,7 @@ def _make_remote(kind: KindMap) -> XAirRemote:
|
|||||||
self.config = Config.make(self)
|
self.config = Config.make(self)
|
||||||
|
|
||||||
def init_xair(self, *args, **kwargs):
|
def init_xair(self, *args, **kwargs):
|
||||||
defaultkwargs = {"ip": None, "port": 10024}
|
defaultkwargs = {"ip": None, "port": 10024, "delay": 0.02}
|
||||||
kwargs = defaultkwargs | kwargs
|
kwargs = defaultkwargs | kwargs
|
||||||
XAirRemote.__init__(self, *args, **kwargs)
|
XAirRemote.__init__(self, *args, **kwargs)
|
||||||
self.kind = kind
|
self.kind = kind
|
||||||
|
Loading…
Reference in New Issue
Block a user