mirror of
https://github.com/onyx-and-iris/xair-api-python.git
synced 2024-11-24 13:50:57 +00:00
a69734b738
factory method for x32 added logging module added for tracing OSC requests/reponses.
64 lines
1.6 KiB
Python
64 lines
1.6 KiB
Python
import abc
|
|
from typing import Optional
|
|
|
|
from .errors import XAirRemoteError
|
|
from .shared import EQ, GEQ, Automix, Config, Dyn, Gate, Group, Insert, Mix, Preamp
|
|
|
|
|
|
class ILR(abc.ABC):
|
|
"""Abstract Base Class for buses"""
|
|
|
|
def __init__(self, remote, index: Optional[int] = None):
|
|
self._remote = remote
|
|
if index is not None:
|
|
self.index = index + 1
|
|
|
|
def getter(self, param: str):
|
|
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 LR(ILR):
|
|
"""Concrete class for buses"""
|
|
|
|
@classmethod
|
|
def make(cls, remote, index=None):
|
|
"""
|
|
Factory function for LR
|
|
|
|
Creates a mixin of shared subclasses, sets them as class attributes.
|
|
|
|
Returns an LR class of a kind.
|
|
"""
|
|
LR_cls = type(
|
|
f"LR{remote.kind}",
|
|
(cls,),
|
|
{
|
|
**{
|
|
_cls.__name__.lower(): type(
|
|
f"{_cls.__name__}{remote.kind}", (_cls, cls), {}
|
|
)(remote, index)
|
|
for _cls in (
|
|
Config,
|
|
Dyn,
|
|
Insert,
|
|
GEQ.make(),
|
|
EQ.make_sixband(cls, remote, index),
|
|
Mix,
|
|
)
|
|
},
|
|
},
|
|
)
|
|
return LR_cls(remote, index)
|
|
|
|
@property
|
|
def address(self) -> str:
|
|
return f"/lr"
|