From e8aa762c70dc4aa937a258033278c61a11a2b624 Mon Sep 17 00:00:00 2001 From: onyx-and-iris <75868496+onyx-and-iris@users.noreply.github.com> Date: Wed, 27 Apr 2022 14:00:55 +0100 Subject: [PATCH] rework bus mode getter rework bus mode getter --- vbancmd/meta.py | 36 +++++++++++++++++++----------------- vbancmd/vbancmd.py | 7 ++++--- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/vbancmd/meta.py b/vbancmd/meta.py index e8a3bef..fbde7c0 100644 --- a/vbancmd/meta.py +++ b/vbancmd/meta.py @@ -74,24 +74,26 @@ def bus_mode_prop(param): def fget(self): val = self.getter(f"mode.{param}") if val is None: + modelist = { + "amix": (1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1), + "repeat": (0, 2, 2, 0, 0, 2, 2, 0, 0, 2, 2), + "bmix": (1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3), + "composite": (0, 0, 0, 4, 4, 4, 4, 0, 0, 0, 0), + "tvmix": (1, 0, 1, 4, 5, 4, 5, 0, 1, 0, 1), + "upmix21": (0, 2, 2, 4, 4, 6, 6, 0, 0, 2, 2), + "upmix41": (1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3), + "upmix61": (0, 0, 0, 0, 0, 0, 0, 8, 8, 8, 8), + "centeronly": (1, 0, 1, 0, 1, 0, 1, 8, 9, 8, 9), + "lfeonly": (0, 2, 2, 0, 0, 2, 2, 8, 8, 10, 10), + "rearonly": (1, 2, 3, 0, 1, 2, 3, 8, 9, 10, 11), + } + vals = ( + int.from_bytes(self.public_packet.busstate[self.index], "little") & val + for val in self._modes.modevals + ) if param == "normal": - return any( - not int.from_bytes( - self.public_packet.busstate[self.index], "little" - ) - & val - == 0 - for val in self._modes.modevals - ) - else: - val = ( - not int.from_bytes( - self.public_packet.busstate[self.index], "little" - ) - & getattr(self._modes, f"_{param}") - == 0 - ) - return val + return not any(val for val in vals) + return tuple(round(val / 16) for val in vals) == modelist[param] return val == 1 def fset(self, val): diff --git a/vbancmd/vbancmd.py b/vbancmd/vbancmd.py index ef7e695..c67d283 100644 --- a/vbancmd/vbancmd.py +++ b/vbancmd/vbancmd.py @@ -203,10 +203,11 @@ class VbanCmd(abc.ABC): count = int.from_bytes(self._text_header.framecounter, "little") + 1 self._text_header.framecounter = count.to_bytes(4, "little") self.cache[f"{id_}.{param}"] = val + sleep(self._delay) if self._sync: sleep(self._delay) - if self.in_apply: - sleep(self._ratelimit) + # if self.in_apply: + # sleep(self._ratelimit) def sendtext(self, cmd): """Sends a multiple parameter string over a network.""" @@ -252,7 +253,7 @@ class VbanCmd(abc.ABC): else: raise ValueError(obj) target.apply(submapping) - sleep(self._ratelimit) + # sleep(self._ratelimit) self.in_apply = False def apply_profile(self, name: str):