2022-04-05 20:05:55 +01:00
|
|
|
import abc
|
|
|
|
from typing import Optional
|
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
|
2024-02-08 13:43:15 +00:00
|
|
|
from .shared import (
|
|
|
|
EQ,
|
|
|
|
GEQ,
|
|
|
|
Automix,
|
|
|
|
Config,
|
|
|
|
Dyn,
|
|
|
|
Gate,
|
|
|
|
Group,
|
|
|
|
Insert,
|
|
|
|
Mix,
|
|
|
|
Preamp,
|
|
|
|
Send,
|
|
|
|
)
|
2022-04-05 20:05:55 +01:00
|
|
|
|
|
|
|
|
|
|
|
class IRtn(abc.ABC):
|
2024-02-08 17:40:49 +00:00
|
|
|
"""Abstract Base Class for rtn"""
|
2022-04-05 20:05:55 +01:00
|
|
|
|
|
|
|
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):
|
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
|
|
|
|
|
|
|
|
|
2022-11-07 11:08:56 +00:00
|
|
|
class AuxRtn(IRtn):
|
2024-02-08 17:40:49 +00:00
|
|
|
"""Concrete class for auxrtn"""
|
2022-04-05 20:05:55 +01:00
|
|
|
|
|
|
|
@classmethod
|
2022-11-07 11:08:56 +00:00
|
|
|
def make(cls, remote, index=None):
|
2022-04-05 20:05:55 +01:00
|
|
|
"""
|
2022-11-07 11:08:56 +00:00
|
|
|
Factory function for auxrtn
|
2024-02-08 13:43:15 +00:00
|
|
|
|
2022-04-05 20:05:55 +01:00
|
|
|
Creates a mixin of shared subclasses, sets them as class attributes.
|
2024-02-08 13:43:15 +00:00
|
|
|
|
2022-11-07 11:08:56 +00:00
|
|
|
Returns an AuxRtn class of a kind.
|
2022-04-05 20:05:55 +01:00
|
|
|
"""
|
2022-11-07 11:08:56 +00:00
|
|
|
AUXRTN_cls = type(
|
|
|
|
f"AuxRtn{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-11-07 11:08:56 +00:00
|
|
|
)(remote, index)
|
2022-04-05 20:05:55 +01:00
|
|
|
for _cls in (
|
|
|
|
Config,
|
|
|
|
Preamp,
|
|
|
|
EQ.make_fourband(cls, remote),
|
|
|
|
Mix,
|
|
|
|
Group,
|
|
|
|
)
|
2022-11-16 15:51:26 +00:00
|
|
|
},
|
2024-02-08 13:43:15 +00:00
|
|
|
"send": tuple(
|
|
|
|
Send.make(cls, remote, i)
|
|
|
|
for i in range(remote.kind.num_bus + remote.kind.num_fx)
|
|
|
|
),
|
2022-11-16 15:51:26 +00:00
|
|
|
"mute": mute_prop(),
|
2022-04-05 20:05:55 +01:00
|
|
|
},
|
|
|
|
)
|
2022-11-07 11:08:56 +00:00
|
|
|
return AUXRTN_cls(remote, index)
|
2022-04-05 20:05:55 +01:00
|
|
|
|
|
|
|
@property
|
|
|
|
def address(self):
|
|
|
|
return "/rtn/aux"
|
|
|
|
|
|
|
|
|
2022-11-07 11:08:56 +00:00
|
|
|
class FxRtn(IRtn):
|
2024-02-08 17:40:49 +00:00
|
|
|
"""Concrete class for fxrtn"""
|
2022-04-05 20:05:55 +01:00
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def make(cls, remote, index):
|
|
|
|
"""
|
2022-11-07 11:08:56 +00:00
|
|
|
Factory function for fxrtn
|
2024-02-08 13:43:15 +00:00
|
|
|
|
2022-04-05 20:05:55 +01:00
|
|
|
Creates a mixin of shared subclasses, sets them as class attributes.
|
2024-02-08 13:43:15 +00:00
|
|
|
|
2022-11-07 11:08:56 +00:00
|
|
|
Returns an FxRtn class of a kind.
|
2022-04-05 20:05:55 +01:00
|
|
|
"""
|
2022-11-07 11:08:56 +00:00
|
|
|
FXRTN_cls = type(
|
|
|
|
f"FxRtn{remote.kind}",
|
2022-04-05 20:05:55 +01:00
|
|
|
(cls,),
|
|
|
|
{
|
|
|
|
**{
|
|
|
|
_cls.__name__.lower(): type(
|
2022-11-07 11:08:56 +00:00
|
|
|
f"{_cls.__name__}{remote.kind}", (_cls, cls), {}
|
2022-04-05 20:05:55 +01:00
|
|
|
)(remote, index)
|
|
|
|
for _cls in (
|
|
|
|
Config,
|
|
|
|
Preamp,
|
|
|
|
EQ.make_fourband(cls, remote, index),
|
|
|
|
Mix,
|
|
|
|
Group,
|
|
|
|
)
|
2022-11-16 15:51:26 +00:00
|
|
|
},
|
2024-02-08 13:43:15 +00:00
|
|
|
"send": tuple(
|
|
|
|
Send.make(cls, remote, i, index)
|
|
|
|
for i in range(remote.kind.num_bus + remote.kind.num_fx)
|
|
|
|
),
|
2022-11-16 15:51:26 +00:00
|
|
|
"mute": mute_prop(),
|
2022-04-05 20:05:55 +01:00
|
|
|
},
|
|
|
|
)
|
2022-11-07 11:08:56 +00:00
|
|
|
return FXRTN_cls(remote, index)
|
2022-04-05 20:05:55 +01:00
|
|
|
|
|
|
|
@property
|
|
|
|
def address(self):
|
|
|
|
return f"/rtn/{self.index}"
|