2022-10-06 20:28:26 +01:00
|
|
|
import time
|
2022-06-16 16:10:06 +01:00
|
|
|
from abc import abstractmethod
|
|
|
|
from typing import Union
|
|
|
|
|
|
|
|
from .iremote import IRemote
|
|
|
|
from .kinds import kinds_all
|
|
|
|
from .meta import channel_bool_prop, channel_label_prop, strip_output_prop
|
|
|
|
|
|
|
|
|
|
|
|
class Strip(IRemote):
|
|
|
|
"""
|
|
|
|
Implements the common interface
|
|
|
|
|
|
|
|
Defines concrete implementation for strip
|
|
|
|
"""
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
def __str__(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
@property
|
|
|
|
def identifier(self) -> str:
|
2023-08-07 17:38:51 +01:00
|
|
|
return f"strip[{self.index}]"
|
2022-06-16 16:10:06 +01:00
|
|
|
|
|
|
|
@property
|
|
|
|
def limit(self) -> int:
|
|
|
|
return
|
|
|
|
|
|
|
|
@limit.setter
|
|
|
|
def limit(self, val: int):
|
|
|
|
self.setter("limit", val)
|
|
|
|
|
|
|
|
@property
|
|
|
|
def gain(self) -> float:
|
|
|
|
val = self.getter("gain")
|
|
|
|
if val is None:
|
|
|
|
val = self.gainlayer[0].gain
|
|
|
|
return round(val, 1)
|
|
|
|
|
|
|
|
@gain.setter
|
|
|
|
def gain(self, val: float):
|
|
|
|
self.setter("gain", val)
|
|
|
|
|
2022-10-06 20:28:26 +01:00
|
|
|
def fadeto(self, target: float, time_: int):
|
|
|
|
self.setter("FadeTo", f"({target}, {time_})")
|
|
|
|
time.sleep(self._remote.DELAY)
|
|
|
|
|
|
|
|
def fadeby(self, change: float, time_: int):
|
|
|
|
self.setter("FadeBy", f"({change}, {time_})")
|
|
|
|
time.sleep(self._remote.DELAY)
|
|
|
|
|
2022-06-16 16:10:06 +01:00
|
|
|
|
|
|
|
class PhysicalStrip(Strip):
|
2023-06-25 01:48:07 +01:00
|
|
|
@classmethod
|
|
|
|
def make(cls, remote, index):
|
|
|
|
return type(
|
|
|
|
f"PhysicalStrip{remote.kind}",
|
|
|
|
(cls,),
|
|
|
|
{
|
|
|
|
"comp": StripComp(remote, index),
|
|
|
|
"gate": StripGate(remote, index),
|
|
|
|
"denoiser": StripDenoiser(remote, index),
|
|
|
|
"eq": StripEQ(remote, index),
|
|
|
|
},
|
|
|
|
)
|
|
|
|
|
2022-06-16 16:10:06 +01:00
|
|
|
def __str__(self):
|
|
|
|
return f"{type(self).__name__}{self.index}"
|
|
|
|
|
|
|
|
@property
|
2023-06-25 01:48:07 +01:00
|
|
|
def device(self):
|
2022-06-16 16:10:06 +01:00
|
|
|
return
|
|
|
|
|
2023-06-25 01:48:07 +01:00
|
|
|
@property
|
|
|
|
def sr(self):
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
class StripComp(IRemote):
|
|
|
|
@property
|
|
|
|
def identifier(self) -> str:
|
2023-08-07 17:38:51 +01:00
|
|
|
return f"strip[{self.index}].comp"
|
2022-06-16 16:10:06 +01:00
|
|
|
|
|
|
|
@property
|
2023-06-25 01:48:07 +01:00
|
|
|
def knob(self) -> float:
|
2022-06-16 16:10:06 +01:00
|
|
|
return
|
|
|
|
|
2023-06-25 01:48:07 +01:00
|
|
|
@knob.setter
|
|
|
|
def knob(self, val: float):
|
|
|
|
self.setter("", val)
|
|
|
|
|
2023-06-25 13:59:08 +01:00
|
|
|
@property
|
|
|
|
def gainin(self) -> float:
|
|
|
|
return
|
|
|
|
|
|
|
|
@gainin.setter
|
|
|
|
def gainin(self, val: float):
|
|
|
|
self.setter("GainIn", val)
|
|
|
|
|
|
|
|
@property
|
|
|
|
def ratio(self) -> float:
|
|
|
|
return
|
|
|
|
|
|
|
|
@ratio.setter
|
|
|
|
def ratio(self, val: float):
|
|
|
|
self.setter("Ratio", val)
|
|
|
|
|
|
|
|
@property
|
|
|
|
def threshold(self) -> float:
|
|
|
|
return
|
|
|
|
|
|
|
|
@threshold.setter
|
|
|
|
def threshold(self, val: float):
|
|
|
|
self.setter("Threshold", val)
|
|
|
|
|
|
|
|
@property
|
|
|
|
def attack(self) -> float:
|
|
|
|
return
|
|
|
|
|
|
|
|
@attack.setter
|
|
|
|
def attack(self, val: float):
|
|
|
|
self.setter("Attack", val)
|
|
|
|
|
|
|
|
@property
|
|
|
|
def release(self) -> float:
|
|
|
|
return
|
|
|
|
|
|
|
|
@release.setter
|
|
|
|
def release(self, val: float):
|
|
|
|
self.setter("Release", val)
|
|
|
|
|
|
|
|
@property
|
|
|
|
def knee(self) -> float:
|
|
|
|
return
|
|
|
|
|
|
|
|
@knee.setter
|
|
|
|
def knee(self, val: float):
|
|
|
|
self.setter("Knee", val)
|
|
|
|
|
|
|
|
@property
|
|
|
|
def gainout(self) -> float:
|
|
|
|
return
|
|
|
|
|
|
|
|
@gainout.setter
|
|
|
|
def gainout(self, val: float):
|
|
|
|
self.setter("GainOut", val)
|
|
|
|
|
|
|
|
@property
|
|
|
|
def makeup(self) -> bool:
|
|
|
|
return
|
|
|
|
|
|
|
|
@makeup.setter
|
|
|
|
def makeup(self, val: bool):
|
|
|
|
self.setter("makeup", 1 if val else 0)
|
|
|
|
|
2022-06-16 16:10:06 +01:00
|
|
|
|
2023-06-25 01:48:07 +01:00
|
|
|
class StripGate(IRemote):
|
2022-06-16 16:10:06 +01:00
|
|
|
@property
|
2023-06-25 01:48:07 +01:00
|
|
|
def identifier(self) -> str:
|
2023-08-07 17:38:51 +01:00
|
|
|
return f"strip[{self.index}].gate"
|
2023-06-25 01:48:07 +01:00
|
|
|
|
|
|
|
@property
|
|
|
|
def knob(self) -> float:
|
2022-06-16 16:10:06 +01:00
|
|
|
return
|
|
|
|
|
2023-06-25 01:48:07 +01:00
|
|
|
@knob.setter
|
|
|
|
def knob(self, val: float):
|
|
|
|
self.setter("", val)
|
|
|
|
|
2023-06-25 13:59:08 +01:00
|
|
|
@property
|
|
|
|
def threshold(self) -> float:
|
|
|
|
return
|
|
|
|
|
|
|
|
@threshold.setter
|
|
|
|
def threshold(self, val: float):
|
|
|
|
self.setter("Threshold", val)
|
|
|
|
|
|
|
|
@property
|
|
|
|
def damping(self) -> float:
|
|
|
|
return
|
|
|
|
|
|
|
|
@damping.setter
|
|
|
|
def damping(self, val: float):
|
|
|
|
self.setter("Damping", val)
|
|
|
|
|
|
|
|
@property
|
|
|
|
def bpsidechain(self) -> int:
|
|
|
|
return
|
|
|
|
|
|
|
|
@bpsidechain.setter
|
|
|
|
def bpsidechain(self, val: int):
|
|
|
|
self.setter("BPSidechain", val)
|
|
|
|
|
|
|
|
@property
|
|
|
|
def attack(self) -> float:
|
|
|
|
return
|
|
|
|
|
|
|
|
@attack.setter
|
|
|
|
def attack(self, val: float):
|
|
|
|
self.setter("Attack", val)
|
|
|
|
|
|
|
|
@property
|
|
|
|
def hold(self) -> float:
|
|
|
|
return
|
|
|
|
|
|
|
|
@hold.setter
|
|
|
|
def hold(self, val: float):
|
|
|
|
self.setter("Hold", val)
|
|
|
|
|
|
|
|
@property
|
|
|
|
def release(self) -> float:
|
|
|
|
return
|
|
|
|
|
|
|
|
@release.setter
|
|
|
|
def release(self, val: float):
|
|
|
|
self.setter("Release", val)
|
|
|
|
|
2023-06-25 01:48:07 +01:00
|
|
|
|
|
|
|
class StripDenoiser(IRemote):
|
2022-06-16 16:10:06 +01:00
|
|
|
@property
|
2023-06-25 01:48:07 +01:00
|
|
|
def identifier(self) -> str:
|
2023-08-07 17:38:51 +01:00
|
|
|
return f"strip[{self.index}].denoiser"
|
2023-06-25 01:48:07 +01:00
|
|
|
|
|
|
|
@property
|
|
|
|
def knob(self) -> float:
|
2022-06-16 16:10:06 +01:00
|
|
|
return
|
|
|
|
|
2023-06-25 01:48:07 +01:00
|
|
|
@knob.setter
|
|
|
|
def knob(self, val: float):
|
|
|
|
self.setter("", val)
|
|
|
|
|
|
|
|
|
|
|
|
class StripEQ(IRemote):
|
|
|
|
@property
|
|
|
|
def identifier(self) -> str:
|
2023-08-07 17:38:51 +01:00
|
|
|
return f"strip[{self.index}].eq"
|
2023-06-25 01:48:07 +01:00
|
|
|
|
|
|
|
@property
|
|
|
|
def on(self):
|
|
|
|
return
|
|
|
|
|
|
|
|
@on.setter
|
|
|
|
def on(self, val: bool):
|
|
|
|
self.setter("on", 1 if val else 0)
|
|
|
|
|
|
|
|
@property
|
|
|
|
def ab(self):
|
|
|
|
return
|
|
|
|
|
|
|
|
@ab.setter
|
|
|
|
def ab(self, val: bool):
|
|
|
|
self.setter("ab", 1 if val else 0)
|
|
|
|
|
2022-06-16 16:10:06 +01:00
|
|
|
|
|
|
|
class VirtualStrip(Strip):
|
|
|
|
def __str__(self):
|
|
|
|
return f"{type(self).__name__}{self.index}"
|
|
|
|
|
|
|
|
mc = channel_bool_prop("mc")
|
|
|
|
|
|
|
|
mono = mc
|
|
|
|
|
|
|
|
@property
|
|
|
|
def k(self) -> int:
|
|
|
|
return
|
|
|
|
|
|
|
|
@k.setter
|
|
|
|
def k(self, val: int):
|
|
|
|
self.setter("karaoke", val)
|
|
|
|
|
2022-10-06 20:28:26 +01:00
|
|
|
def appgain(self, name: str, gain: float):
|
|
|
|
self.setter("AppGain", f'("{name}", {gain})')
|
|
|
|
|
|
|
|
def appmute(self, name: str, mute: bool = None):
|
|
|
|
self.setter("AppMute", f'("{name}", {1 if mute else 0})')
|
|
|
|
|
2022-06-16 16:10:06 +01:00
|
|
|
|
|
|
|
class StripLevel(IRemote):
|
|
|
|
def __init__(self, remote, index):
|
|
|
|
super().__init__(remote, index)
|
|
|
|
phys_map = tuple((i, i + 2) for i in range(0, remote.kind.phys_in * 2, 2))
|
|
|
|
virt_map = tuple(
|
|
|
|
(i, i + 8)
|
|
|
|
for i in range(
|
|
|
|
remote.kind.phys_in * 2,
|
|
|
|
remote.kind.phys_in * 2 + remote.kind.virt_in * 8,
|
|
|
|
8,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
self.level_map = phys_map + virt_map
|
2022-07-06 13:40:46 +01:00
|
|
|
self.range = self.level_map[self.index]
|
2022-06-16 16:10:06 +01:00
|
|
|
|
2022-07-06 13:40:46 +01:00
|
|
|
def getter(self):
|
2022-09-28 18:07:10 +01:00
|
|
|
"""Returns a tuple of level values for the channel."""
|
|
|
|
|
2022-10-04 15:40:32 +01:00
|
|
|
def fget(i):
|
|
|
|
return round((((1 << 16) - 1) - i) * -0.01, 1)
|
|
|
|
|
2023-08-04 23:13:58 +01:00
|
|
|
if not self._remote.stopped() and self._remote.event.ldirty:
|
2022-09-28 18:07:10 +01:00
|
|
|
return tuple(
|
2022-10-04 15:40:32 +01:00
|
|
|
fget(i)
|
2022-09-28 18:07:10 +01:00
|
|
|
for i in self._remote.cache["strip_level"][
|
|
|
|
self.range[0] : self.range[-1]
|
|
|
|
]
|
|
|
|
)
|
2022-06-16 16:10:06 +01:00
|
|
|
return tuple(
|
2022-10-04 15:40:32 +01:00
|
|
|
fget(i)
|
2022-09-28 18:07:10 +01:00
|
|
|
for i in self._remote._get_levels(self.public_packet)[0][
|
|
|
|
self.range[0] : self.range[-1]
|
|
|
|
]
|
2022-06-16 16:10:06 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
@property
|
|
|
|
def identifier(self) -> str:
|
2023-08-07 17:38:51 +01:00
|
|
|
return f"strip[{self.index}]"
|
2022-06-16 16:10:06 +01:00
|
|
|
|
|
|
|
@property
|
|
|
|
def prefader(self) -> tuple:
|
2022-07-06 13:40:46 +01:00
|
|
|
return self.getter()
|
2022-06-16 16:10:06 +01:00
|
|
|
|
|
|
|
@property
|
|
|
|
def postfader(self) -> tuple:
|
|
|
|
return
|
|
|
|
|
|
|
|
@property
|
|
|
|
def postmute(self) -> tuple:
|
|
|
|
return
|
|
|
|
|
|
|
|
@property
|
2022-08-02 09:31:08 +01:00
|
|
|
def isdirty(self) -> bool:
|
|
|
|
"""
|
|
|
|
Returns dirty status for this specific channel.
|
|
|
|
|
|
|
|
Expected to be used in a callback only.
|
|
|
|
"""
|
2022-07-06 13:40:46 +01:00
|
|
|
return any(self._remote._strip_comp[self.range[0] : self.range[-1]])
|
2022-06-16 16:10:06 +01:00
|
|
|
|
2022-08-02 09:31:08 +01:00
|
|
|
is_updated = isdirty
|
|
|
|
|
2022-06-16 16:10:06 +01:00
|
|
|
|
|
|
|
class GainLayer(IRemote):
|
|
|
|
def __init__(self, remote, index, i):
|
|
|
|
super().__init__(remote, index)
|
|
|
|
self._i = i
|
|
|
|
|
|
|
|
@property
|
|
|
|
def identifier(self) -> str:
|
2023-08-07 17:38:51 +01:00
|
|
|
return f"strip[{self.index}]"
|
2022-06-16 16:10:06 +01:00
|
|
|
|
|
|
|
@property
|
|
|
|
def gain(self) -> float:
|
|
|
|
def fget():
|
|
|
|
val = getattr(self.public_packet, f"stripgainlayer{self._i+1}")[self.index]
|
2022-09-28 18:07:10 +01:00
|
|
|
if 0 <= val <= 1200:
|
|
|
|
return val * 0.01
|
|
|
|
return (((1 << 16) - 1) - val) * -0.01
|
2022-06-16 16:10:06 +01:00
|
|
|
|
|
|
|
val = self.getter(f"GainLayer[{self._i}]")
|
2022-09-28 18:07:10 +01:00
|
|
|
return round(val if val else fget(), 1)
|
2022-06-16 16:10:06 +01:00
|
|
|
|
|
|
|
@gain.setter
|
|
|
|
def gain(self, val: float):
|
|
|
|
self.setter(f"GainLayer[{self._i}]", val)
|
|
|
|
|
|
|
|
|
|
|
|
def _make_gainlayer_mixin(remote, index):
|
|
|
|
"""Creates a GainLayer mixin"""
|
|
|
|
return type(
|
|
|
|
f"GainlayerMixin",
|
|
|
|
(),
|
|
|
|
{
|
|
|
|
"gainlayer": tuple(
|
|
|
|
GainLayer(remote, index, i) for i in range(remote.kind.num_bus)
|
|
|
|
)
|
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def _make_channelout_mixin(kind):
|
|
|
|
"""Creates a channel out property mixin"""
|
|
|
|
return type(
|
|
|
|
f"ChannelOutMixin{kind}",
|
|
|
|
(),
|
|
|
|
{
|
|
|
|
**{
|
|
|
|
f"A{i}": strip_output_prop(f"A{i}") for i in range(1, kind.phys_out + 1)
|
|
|
|
},
|
|
|
|
**{
|
|
|
|
f"B{i}": strip_output_prop(f"B{i}") for i in range(1, kind.virt_out + 1)
|
|
|
|
},
|
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
_make_channelout_mixins = {
|
|
|
|
kind.name: _make_channelout_mixin(kind) for kind in kinds_all
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
def strip_factory(is_phys_strip, remote, i) -> Union[PhysicalStrip, VirtualStrip]:
|
|
|
|
"""
|
|
|
|
Factory method for strips
|
|
|
|
|
|
|
|
Mixes in required classes
|
|
|
|
|
|
|
|
Returns a physical or virtual strip subclass
|
|
|
|
"""
|
2023-06-25 01:48:07 +01:00
|
|
|
STRIP_cls = PhysicalStrip.make(remote, i) if is_phys_strip else VirtualStrip
|
2022-06-16 16:10:06 +01:00
|
|
|
CHANNELOUTMIXIN_cls = _make_channelout_mixins[remote.kind.name]
|
|
|
|
GAINLAYERMIXIN_cls = _make_gainlayer_mixin(remote, i)
|
|
|
|
|
|
|
|
return type(
|
|
|
|
f"{STRIP_cls.__name__}{remote.kind}",
|
|
|
|
(STRIP_cls, CHANNELOUTMIXIN_cls, GAINLAYERMIXIN_cls),
|
|
|
|
{
|
|
|
|
"levels": StripLevel(remote, i),
|
|
|
|
**{param: channel_bool_prop(param) for param in ["mono", "solo", "mute"]},
|
|
|
|
"label": channel_label_prop(),
|
|
|
|
},
|
|
|
|
)(remote, i)
|
|
|
|
|
|
|
|
|
|
|
|
def request_strip_obj(is_phys_strip, remote, i) -> Strip:
|
|
|
|
"""
|
|
|
|
Strip entry point. Wraps factory method.
|
|
|
|
|
|
|
|
Returns a reference to a strip subclass of a kind
|
|
|
|
"""
|
|
|
|
return strip_factory(is_phys_strip, remote, i)
|