Send class added to shared module

Send mixed into Strip, AuxRtn, FxRtn classes.

addresses #4
This commit is contained in:
onyx-and-iris 2024-02-08 13:43:15 +00:00
parent df2d158618
commit 27d0811091
3 changed files with 116 additions and 47 deletions

View File

@ -3,7 +3,19 @@ from typing import Optional
from .errors import XAirRemoteError from .errors import XAirRemoteError
from .meta import mute_prop from .meta import mute_prop
from .shared import EQ, GEQ, Automix, Config, Dyn, Gate, Group, Insert, Mix, Preamp from .shared import (
EQ,
GEQ,
Automix,
Config,
Dyn,
Gate,
Group,
Insert,
Mix,
Preamp,
Send,
)
class IRtn(abc.ABC): class IRtn(abc.ABC):
@ -32,7 +44,9 @@ class AuxRtn(IRtn):
def make(cls, remote, index=None): def make(cls, remote, index=None):
""" """
Factory function for auxrtn Factory function for auxrtn
Creates a mixin of shared subclasses, sets them as class attributes. Creates a mixin of shared subclasses, sets them as class attributes.
Returns an AuxRtn class of a kind. Returns an AuxRtn class of a kind.
""" """
AUXRTN_cls = type( AUXRTN_cls = type(
@ -51,6 +65,10 @@ class AuxRtn(IRtn):
Group, Group,
) )
}, },
"send": tuple(
Send.make(cls, remote, i)
for i in range(remote.kind.num_bus + remote.kind.num_fx)
),
"mute": mute_prop(), "mute": mute_prop(),
}, },
) )
@ -68,7 +86,9 @@ class FxRtn(IRtn):
def make(cls, remote, index): def make(cls, remote, index):
""" """
Factory function for fxrtn Factory function for fxrtn
Creates a mixin of shared subclasses, sets them as class attributes. Creates a mixin of shared subclasses, sets them as class attributes.
Returns an FxRtn class of a kind. Returns an FxRtn class of a kind.
""" """
FXRTN_cls = type( FXRTN_cls = type(
@ -87,6 +107,10 @@ class FxRtn(IRtn):
Group, Group,
) )
}, },
"send": tuple(
Send.make(cls, remote, i, index)
for i in range(remote.kind.num_bus + remote.kind.num_fx)
),
"mute": mute_prop(), "mute": mute_prop(),
}, },
) )

View File

@ -1,8 +1,8 @@
from typing import Union from typing import Optional, Union
from . import util
from .errors import XAirRemoteError from .errors import XAirRemoteError
from .meta import geq_prop from .meta import geq_prop
from .util import _get_fader_val, _set_fader_val, lin_get, lin_set, log_get, log_set
""" """
Classes shared by /ch, /rtn, /rtn/aux, /bus, /fxsend, /lr Classes shared by /ch, /rtn, /rtn/aux, /bus, /fxsend, /lr
@ -56,13 +56,13 @@ class Preamp:
@property @property
def usbtrim(self) -> float: def usbtrim(self) -> float:
return round(lin_get(-18, 18, self.getter("rtntrim")[0]), 1) return round(util.lin_get(-18, 18, self.getter("rtntrim")[0]), 1)
@usbtrim.setter @usbtrim.setter
def usbtrim(self, val: float): def usbtrim(self, val: float):
if not -18 <= val <= 18: if not -18 <= val <= 18:
raise XAirRemoteError("expected value in range -18.0 to 18.0") raise XAirRemoteError("expected value in range -18.0 to 18.0")
self.setter("rtntrim", lin_set(-18, 18, val)) self.setter("rtntrim", util.lin_set(-18, 18, val))
@property @property
def usbinput(self) -> bool: def usbinput(self) -> bool:
@ -90,13 +90,13 @@ class Preamp:
@property @property
def highpassfilter(self) -> int: def highpassfilter(self) -> int:
return int(log_get(20, 400, self.getter("hpf")[0])) return int(util.log_get(20, 400, self.getter("hpf")[0]))
@highpassfilter.setter @highpassfilter.setter
def highpassfilter(self, val: int): def highpassfilter(self, val: int):
if not 20 <= val <= 400: if not 20 <= val <= 400:
raise XAirRemoteError("expected value in range 20 to 400") raise XAirRemoteError("expected value in range 20 to 400")
self.setter("hpf", log_set(20, 400, val)) self.setter("hpf", util.log_set(20, 400, val))
class Gate: class Gate:
@ -127,54 +127,54 @@ class Gate:
@property @property
def threshold(self) -> float: def threshold(self) -> float:
return round(lin_get(-80, 0, self.getter("thr")[0]), 1) return round(util.lin_get(-80, 0, self.getter("thr")[0]), 1)
@threshold.setter @threshold.setter
def threshold(self, val: float): def threshold(self, val: float):
if not -80 <= val <= 0: if not -80 <= val <= 0:
raise XAirRemoteError("expected value in range -80.0 to 0.0") raise XAirRemoteError("expected value in range -80.0 to 0.0")
self.setter("thr", lin_set(-80, 0, val)) self.setter("thr", util.lin_set(-80, 0, val))
@property @property
def range(self) -> int: def range(self) -> int:
return int(lin_get(3, 60, self.getter("range")[0])) return int(util.lin_get(3, 60, self.getter("range")[0]))
@range.setter @range.setter
def range(self, val: int): def range(self, val: int):
if not 3 <= val <= 60: if not 3 <= val <= 60:
raise XAirRemoteError("expected value in range 3 to 60") raise XAirRemoteError("expected value in range 3 to 60")
self.setter("range", lin_set(3, 60, val)) self.setter("range", util.lin_set(3, 60, val))
@property @property
def attack(self) -> int: def attack(self) -> int:
return int(lin_get(0, 120, self.getter("attack")[0])) return int(util.lin_get(0, 120, self.getter("attack")[0]))
@attack.setter @attack.setter
def attack(self, val: int): def attack(self, val: int):
if not 0 <= val <= 120: if not 0 <= val <= 120:
raise XAirRemoteError("expected value in range 0 to 120") raise XAirRemoteError("expected value in range 0 to 120")
self.setter("attack", lin_set(0, 120, val)) self.setter("attack", util.lin_set(0, 120, val))
@property @property
def hold(self) -> Union[float, int]: def hold(self) -> Union[float, int]:
val = log_get(0.02, 2000, self.getter("hold")[0]) val = util.log_get(0.02, 2000, self.getter("hold")[0])
return round(val, 1) if val < 100 else int(val) return round(val, 1) if val < 100 else int(val)
@hold.setter @hold.setter
def hold(self, val: float): def hold(self, val: float):
if not 0.02 <= val <= 2000: if not 0.02 <= val <= 2000:
raise XAirRemoteError("expected value in range 0.02 to 2000.0") raise XAirRemoteError("expected value in range 0.02 to 2000.0")
self.setter("hold", log_set(0.02, 2000, val)) self.setter("hold", util.log_set(0.02, 2000, val))
@property @property
def release(self) -> int: def release(self) -> int:
return int(log_get(5, 4000, self.getter("release")[0])) return int(util.log_get(5, 4000, self.getter("release")[0]))
@release.setter @release.setter
def release(self, val: int): def release(self, val: int):
if not 5 <= val <= 4000: if not 5 <= val <= 4000:
raise XAirRemoteError("expected value in range 5 to 4000") raise XAirRemoteError("expected value in range 5 to 4000")
self.setter("release", log_set(5, 4000, val)) self.setter("release", util.log_set(5, 4000, val))
@property @property
def keysource(self): def keysource(self):
@ -202,14 +202,14 @@ class Gate:
@property @property
def filterfreq(self) -> Union[float, int]: def filterfreq(self) -> Union[float, int]:
retval = log_get(20, 20000, self.getter("filter/f")[0]) retval = util.log_get(20, 20000, self.getter("filter/f")[0])
return int(retval) if retval > 1000 else round(retval, 1) return int(retval) if retval > 1000 else round(retval, 1)
@filterfreq.setter @filterfreq.setter
def filterfreq(self, val: Union[float, int]): def filterfreq(self, val: Union[float, int]):
if not 20 <= val <= 20000: if not 20 <= val <= 20000:
raise XAirRemoteError("expected value in range 20 to 20000") raise XAirRemoteError("expected value in range 20 to 20000")
self.setter("filter/f", log_set(20, 20000, val)) self.setter("filter/f", util.log_set(20, 20000, val))
class Dyn: class Dyn:
@ -264,13 +264,13 @@ class Dyn:
@property @property
def threshold(self) -> float: def threshold(self) -> float:
return round(lin_get(-60, 0, self.getter("thr")[0]), 1) return round(util.lin_get(-60, 0, self.getter("thr")[0]), 1)
@threshold.setter @threshold.setter
def threshold(self, val: float): def threshold(self, val: float):
if not -60 <= val <= 0: if not -60 <= val <= 0:
raise XAirRemoteError("expected value in range -60.0 to 0") raise XAirRemoteError("expected value in range -60.0 to 0")
self.setter("thr", lin_set(-60, 0, val)) self.setter("thr", util.lin_set(-60, 0, val))
@property @property
def ratio(self) -> Union[float, int]: def ratio(self) -> Union[float, int]:
@ -283,64 +283,64 @@ class Dyn:
@property @property
def knee(self) -> int: def knee(self) -> int:
return int(lin_get(0, 5, self.getter("knee")[0])) return int(util.lin_get(0, 5, self.getter("knee")[0]))
@knee.setter @knee.setter
def knee(self, val: int): def knee(self, val: int):
if not 0 <= val <= 5: if not 0 <= val <= 5:
raise XAirRemoteError("expected value in range 0 to 5") raise XAirRemoteError("expected value in range 0 to 5")
self.setter("knee", lin_set(0, 5, val)) self.setter("knee", util.lin_set(0, 5, val))
@property @property
def mgain(self) -> float: def mgain(self) -> float:
return round(lin_get(0, 24, self.getter("mgain")[0]), 1) return round(util.lin_get(0, 24, self.getter("mgain")[0]), 1)
@mgain.setter @mgain.setter
def mgain(self, val: float): def mgain(self, val: float):
if not 0 <= val <= 24: if not 0 <= val <= 24:
raise XAirRemoteError("expected value in range 0.0 to 24.0") raise XAirRemoteError("expected value in range 0.0 to 24.0")
self.setter("mgain", lin_set(0, 24, val)) self.setter("mgain", util.lin_set(0, 24, val))
@property @property
def attack(self) -> int: def attack(self) -> int:
return int(lin_get(0, 120, self.getter("attack")[0])) return int(util.lin_get(0, 120, self.getter("attack")[0]))
@attack.setter @attack.setter
def attack(self, val: int): def attack(self, val: int):
if not 0 <= val <= 120: if not 0 <= val <= 120:
raise XAirRemoteError("expected value in range 0 to 120") raise XAirRemoteError("expected value in range 0 to 120")
self.setter("attack", lin_set(0, 120, val)) self.setter("attack", util.lin_set(0, 120, val))
@property @property
def hold(self) -> Union[float, int]: def hold(self) -> Union[float, int]:
val = log_get(0.02, 2000, self.getter("hold")[0]) val = util.log_get(0.02, 2000, self.getter("hold")[0])
return round(val, 1) if val < 100 else int(val) return round(val, 1) if val < 100 else int(val)
@hold.setter @hold.setter
def hold(self, val: float): def hold(self, val: float):
if not 0.02 <= val <= 2000: if not 0.02 <= val <= 2000:
raise XAirRemoteError("expected value in range 0.02 to 2000.0") raise XAirRemoteError("expected value in range 0.02 to 2000.0")
self.setter("hold", log_set(0.02, 2000, val)) self.setter("hold", util.log_set(0.02, 2000, val))
@property @property
def release(self) -> int: def release(self) -> int:
return int(log_get(5, 4000, self.getter("release")[0])) return int(util.log_get(5, 4000, self.getter("release")[0]))
@release.setter @release.setter
def release(self, val: int): def release(self, val: int):
if not 5 <= val <= 4000: if not 5 <= val <= 4000:
raise XAirRemoteError("expected value in range 5 to 4000") raise XAirRemoteError("expected value in range 5 to 4000")
self.setter("release", log_set(5, 4000, val)) self.setter("release", util.log_set(5, 4000, val))
@property @property
def mix(self) -> int: def mix(self) -> int:
return int(lin_get(0, 100, self.getter("mix")[0])) return int(util.lin_get(0, 100, self.getter("mix")[0]))
@mix.setter @mix.setter
def mix(self, val: int): def mix(self, val: int):
if not 0 <= val <= 100: if not 0 <= val <= 100:
raise XAirRemoteError("expected value in range 0 to 100") raise XAirRemoteError("expected value in range 0 to 100")
self.setter("mix", lin_set(0, 100, val)) self.setter("mix", util.lin_set(0, 100, val))
@property @property
def keysource(self): def keysource(self):
@ -376,14 +376,14 @@ class Dyn:
@property @property
def filterfreq(self) -> Union[float, int]: def filterfreq(self) -> Union[float, int]:
retval = log_get(20, 20000, self.getter("filter/f")[0]) retval = util.log_get(20, 20000, self.getter("filter/f")[0])
return int(retval) if retval > 1000 else round(retval, 1) return int(retval) if retval > 1000 else round(retval, 1)
@filterfreq.setter @filterfreq.setter
def filterfreq(self, val: Union[float, int]): def filterfreq(self, val: Union[float, int]):
if not 20 <= val <= 20000: if not 20 <= val <= 20000:
raise XAirRemoteError("expected value in range 20 to 20000") raise XAirRemoteError("expected value in range 20 to 20000")
self.setter("filter/f", log_set(20, 20000, val)) self.setter("filter/f", util.log_set(20, 20000, val))
class Insert: class Insert:
@ -488,35 +488,35 @@ class EQ:
@property @property
def frequency(self) -> float: def frequency(self) -> float:
retval = log_get(20, 20000, self.getter("f")[0]) retval = util.log_get(20, 20000, self.getter("f")[0])
return round(retval, 1) return round(retval, 1)
@frequency.setter @frequency.setter
def frequency(self, val: float): def frequency(self, val: float):
if not 20 <= val <= 20000: if not 20 <= val <= 20000:
raise XAirRemoteError("expected value in range 20.0 to 20000.0") raise XAirRemoteError("expected value in range 20.0 to 20000.0")
self.setter("f", log_set(20, 20000, val)) self.setter("f", util.log_set(20, 20000, val))
@property @property
def gain(self) -> float: def gain(self) -> float:
return round(lin_get(-15, 15, self.getter("g")[0]), 1) return round(util.lin_get(-15, 15, self.getter("g")[0]), 1)
@gain.setter @gain.setter
def gain(self, val: float): def gain(self, val: float):
if not -15 <= val <= 15: if not -15 <= val <= 15:
raise XAirRemoteError("expected value in range -15.0 to 15.0") raise XAirRemoteError("expected value in range -15.0 to 15.0")
self.setter("g", lin_set(-15, 15, val)) self.setter("g", util.lin_set(-15, 15, val))
@property @property
def quality(self) -> float: def quality(self) -> float:
retval = log_get(0.3, 10, self.getter("q")[0]) retval = util.log_get(0.3, 10, self.getter("q")[0])
return round(retval, 1) return round(retval, 1)
@quality.setter @quality.setter
def quality(self, val: float): def quality(self, val: float):
if not 0.3 <= val <= 10: if not 0.3 <= val <= 10:
raise XAirRemoteError("expected value in range 0.3 to 10.0") raise XAirRemoteError("expected value in range 0.3 to 10.0")
self.setter("q", log_set(0.3, 10, val)) self.setter("q", util.log_set(0.3, 10, val))
class GEQ: class GEQ:
@ -561,13 +561,14 @@ class Mix:
self.setter("on", 1 if val else 0) self.setter("on", 1 if val else 0)
@property @property
@util.from_db
def fader(self) -> float: def fader(self) -> float:
retval = self.getter("fader")[0] return self.getter("fader")[0]
return _get_fader_val(retval)
@fader.setter @fader.setter
@util.to_db
def fader(self, val: float): def fader(self, val: float):
_set_fader_val(self, val) self.setter("fader", val)
@property @property
def lr(self) -> bool: def lr(self) -> bool:
@ -617,10 +618,38 @@ class Automix:
@property @property
def weight(self) -> float: def weight(self) -> float:
return round(lin_get(-12, 12, self.getter("weight")[0]), 1) return round(util.lin_get(-12, 12, self.getter("weight")[0]), 1)
@weight.setter @weight.setter
def weight(self, val: float): def weight(self, val: float):
if not -12 <= val <= 12: if not -12 <= val <= 12:
raise XAirRemoteError("expected value in range -12.0 to 12.0") raise XAirRemoteError("expected value in range -12.0 to 12.0")
self.setter("weight", lin_set(-12, 12, val)) self.setter("weight", util.lin_set(-12, 12, val))
class Send:
def __init__(self, remote, i, index: Optional[int] = None):
self._remote = remote
if index is not None:
self.index = index + 1
self.i = i + 1
@classmethod
def make(cls, _cls, remote, i, index=None):
STRIPSEND_cls = type("Send", (cls, _cls), {})
return STRIPSEND_cls(remote, i, index)
@property
def address(self) -> str:
root = super(Send, self).address
return f"{root}/mix/{str(self.i).zfill(2)}"
@property
@util.from_db
def level(self):
return self.getter("level")[0]
@level.setter
@util.to_db
def level(self, val):
self.setter("level", val)

View File

@ -2,7 +2,19 @@ import abc
from .errors import XAirRemoteError from .errors import XAirRemoteError
from .meta import mute_prop from .meta import mute_prop
from .shared import EQ, GEQ, Automix, Config, Dyn, Gate, Group, Insert, Mix, Preamp from .shared import (
EQ,
GEQ,
Automix,
Config,
Dyn,
Gate,
Group,
Insert,
Mix,
Preamp,
Send,
)
class IStrip(abc.ABC): class IStrip(abc.ABC):
@ -56,6 +68,10 @@ class Strip(IStrip):
Automix, Automix,
) )
}, },
"send": tuple(
Send.make(cls, remote, i, index)
for i in range(remote.kind.num_bus + remote.kind.num_fx)
),
"mute": mute_prop(), "mute": mute_prop(),
}, },
) )