From f92bb1e457fe5f03f8d8c9aac139bd7f19ee1bf1 Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Fri, 30 Jun 2023 01:22:30 +0100 Subject: [PATCH] adds RecorderMode RecorderArmStrip and RecorderArmBus to Recorder class. also adds a few properties, gain, channel, bitresolution. --- voicemeeterlib/recorder.py | 108 ++++++++++++++++++++++++++++++++++++- 1 file changed, 107 insertions(+), 1 deletion(-) diff --git a/voicemeeterlib/recorder.py b/voicemeeterlib/recorder.py index b6e6891..2bea520 100644 --- a/voicemeeterlib/recorder.py +++ b/voicemeeterlib/recorder.py @@ -19,9 +19,10 @@ class Recorder(IRemote): Returns a Recorder class of a kind. """ CHANNELOUTMIXIN_cls = _make_channelout_mixins[remote.kind.name] + ARMSTRIPMIXIN_cls = _make_armstrip_mixins(remote)[remote.kind.name] REC_cls = type( f"Recorder{remote.kind}", - (cls, CHANNELOUTMIXIN_cls), + (cls, CHANNELOUTMIXIN_cls, ARMSTRIPMIXIN_cls), { **{ param: action_fn(param) @@ -35,6 +36,7 @@ class Recorder(IRemote): "rew", ] }, + "mode": RecorderMode(remote), }, ) return REC_cls(remote) @@ -57,6 +59,110 @@ class Recorder(IRemote): loop = property(fset=set_loop) + @property + def bitresolution(self) -> int: + set.getter("bitresolution") + + @bitresolution.setter + def bitresolution(self, val: int): + set.getter("bitresolution", val) + + @property + def channel(self) -> int: + set.getter("channel") + + @channel.setter + def channel(self, val: int): + set.getter("channel", val) + + @property + def gain(self) -> float: + return round(self.getter("gain"), 1) + + @gain.setter + def gain(self, val: float): + self.setter("gain", val) + + +class RecorderMode(IRemote): + def identifier(self): + return "recorder.mode" + + @property + def recbus(self) -> bool: + self.getter("recbus") + + @recbus.setter + def recbus(self, val: bool): + self.setter("recbus", 1 if val else 0) + + @property + def playonload(self) -> bool: + self.getter("playonload") + + @playonload.setter + def playonload(self, val: bool): + self.setter("playonload", 1 if val else 0) + + @property + def loop(self) -> bool: + self.getter("loop") + + @loop.setter + def loop(self, val: bool): + self.setter("recbus", 1 if val else 0) + + @property + def multitrack(self) -> bool: + self.getter("recbus") + + @multitrack.setter + def multitrack(self, val: bool): + self.setter("recbus", 1 if val else 0) + + +class RecorderArmStrip(IRemote): + def __init__(self, remote, i): + super().__init__(remote) + self._i = i + + @property + def identifier(self): + return f"recorder.armstrip[{self._i}]" + + def set(self, val: bool): + self.setter("", 1 if val else 0) + + +class RecorderArmBus(IRemote): + def __init__(self, remote, i): + super().__init__(remote) + self._i = i + + @property + def identifier(self): + return f"recorder.armbus[{self._i}]" + + def set(self, val: bool): + self.setter("", 1 if val else 0) + + +def _make_armstrip_mixin(remote, kind): + return type( + f"ArmStripMixin", + (), + { + "armstrip": tuple( + RecorderArmStrip(remote, i) for i in range(kind.num_strip) + ), + "armbus": tuple(RecorderArmBus(remote, i) for i in range(kind.num_bus)), + }, + ) + + +def _make_armstrip_mixins(remote): + return {kind.name: _make_armstrip_mixin(remote, kind) for kind in kinds_all} + def _make_channelout_mixin(kind): """Creates a channel out property mixin"""