mirror of
https://github.com/onyx-and-iris/xair-api-python.git
synced 2024-11-22 12:50:58 +00:00
f8c6659fd8
now packaged with poetry and added to pypi using tomllib, requires python 3.11 readme, changelog updated to reflect changes major version bump
65 lines
1.7 KiB
Python
65 lines
1.7 KiB
Python
import abc
|
|
|
|
from .errors import XAirRemoteError
|
|
from .shared import EQ, GEQ, Automix, Config, Dyn, Gate, Group, Insert, Mix, Preamp
|
|
|
|
|
|
class IStrip(abc.ABC):
|
|
"""Abstract Base Class for strips"""
|
|
|
|
def __init__(self, remote, index: int):
|
|
self._remote = remote
|
|
self.index = index + 1
|
|
|
|
def getter(self, param: str) -> tuple:
|
|
self._remote.send(f"{self.address}/{param}")
|
|
return self._remote.info_response
|
|
|
|
def setter(self, param: str, val: int):
|
|
self._remote.send(f"{self.address}/{param}", val)
|
|
|
|
@abc.abstractmethod
|
|
def address(self):
|
|
pass
|
|
|
|
|
|
class Strip(IStrip):
|
|
"""Concrete class for strips"""
|
|
|
|
@classmethod
|
|
def make(cls, remote, index):
|
|
"""
|
|
Factory function for strips
|
|
|
|
Creates a mixin of shared subclasses, sets them as class attributes.
|
|
|
|
Returns a Strip class of a kind.
|
|
"""
|
|
STRIP_cls = type(
|
|
f"Strip{remote.kind}",
|
|
(cls,),
|
|
{
|
|
**{
|
|
_cls.__name__.lower(): type(
|
|
f"{_cls.__name__}{remote.kind}", (_cls, cls), {}
|
|
)(remote, index)
|
|
for _cls in (
|
|
Config,
|
|
Preamp,
|
|
Gate,
|
|
Dyn,
|
|
Insert,
|
|
EQ.make_fourband(cls, remote, index),
|
|
Mix,
|
|
Group,
|
|
Automix,
|
|
)
|
|
},
|
|
},
|
|
)
|
|
return STRIP_cls(remote, index)
|
|
|
|
@property
|
|
def address(self) -> str:
|
|
return f"/ch/{str(self.index).zfill(2)}"
|