2022-04-05 20:05:55 +01:00
|
|
|
import abc
|
2022-08-07 23:55:51 +01:00
|
|
|
|
|
|
|
from .errors import XAirRemoteError
|
2022-11-16 15:51:26 +00:00
|
|
|
from .meta import mute_prop
|
2022-08-07 23:55:51 +01:00
|
|
|
from .shared import EQ, GEQ, Automix, Config, Dyn, Gate, Group, Insert, Mix, Preamp
|
2022-04-05 20:05:55 +01:00
|
|
|
|
|
|
|
|
|
|
|
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:
|
2024-02-03 13:03:49 +00:00
|
|
|
return self._remote.query(f"{self.address}/{param}")
|
2022-04-05 20:05:55 +01:00
|
|
|
|
|
|
|
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.
|
|
|
|
"""
|
2022-11-16 15:51:26 +00:00
|
|
|
|
2022-04-05 20:05:55 +01:00
|
|
|
STRIP_cls = type(
|
2022-08-07 23:55:51 +01:00
|
|
|
f"Strip{remote.kind}",
|
2022-04-05 20:05:55 +01:00
|
|
|
(cls,),
|
|
|
|
{
|
|
|
|
**{
|
|
|
|
_cls.__name__.lower(): type(
|
2022-08-07 23:55:51 +01:00
|
|
|
f"{_cls.__name__}{remote.kind}", (_cls, cls), {}
|
2022-04-05 20:05:55 +01:00
|
|
|
)(remote, index)
|
|
|
|
for _cls in (
|
|
|
|
Config,
|
|
|
|
Preamp,
|
|
|
|
Gate,
|
|
|
|
Dyn,
|
|
|
|
Insert,
|
|
|
|
EQ.make_fourband(cls, remote, index),
|
|
|
|
Mix,
|
|
|
|
Group,
|
|
|
|
Automix,
|
|
|
|
)
|
|
|
|
},
|
2022-11-16 15:51:26 +00:00
|
|
|
"mute": mute_prop(),
|
2022-04-05 20:05:55 +01:00
|
|
|
},
|
|
|
|
)
|
|
|
|
return STRIP_cls(remote, index)
|
|
|
|
|
|
|
|
@property
|
|
|
|
def address(self) -> str:
|
|
|
|
return f"/ch/{str(self.index).zfill(2)}"
|