diff --git a/README.md b/README.md index 8502744..ed015ab 100644 --- a/README.md +++ b/README.md @@ -506,12 +506,6 @@ Sends a script block as a string request, for example: vban.sendtext("Strip[0].Mute=1;Bus[0].Mono=1") ``` -#### `vban.public_packet` - -Returns a `VbanRtPacket`. Designed to be used internally by the interface but available for parsing through this read only property object. - -States not guaranteed to be current (requires use of dirty parameters to confirm). - ## Errors - `errors.VBANCMDError`: Base VBANCMD Exception class. diff --git a/pyproject.toml b/pyproject.toml index 98a1f34..9852844 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "vban-cmd" -version = "2.4.11" +version = "2.4.12" description = "Python interface for the VBAN RT Packet Service (Sendtext)" authors = ["onyx-and-iris "] license = "MIT" diff --git a/vban_cmd/bus.py b/vban_cmd/bus.py index 3de4457..3809dae 100644 --- a/vban_cmd/bus.py +++ b/vban_cmd/bus.py @@ -137,35 +137,40 @@ class BusLevel(IRemote): def _make_bus_mode_mixin(): """Creates a mixin of Bus Modes.""" + modestates = { + "normal": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + "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], + } + def identifier(self) -> str: return f"bus[{self.index}].mode" def get(self): - time.sleep(0.01) - for i, val in enumerate( - [ - self.amix, - self.bmix, - self.repeat, - self.composite, - self.tvmix, - self.upmix21, - self.upmix41, - self.upmix61, - self.centeronly, - self.lfeonly, - self.rearonly, - ] - ): - if val: - return BusModes(i + 1).name - return "normal" + states = [ + (int.from_bytes(self.public_packet.busstate[self.index], "little") & val) + >> 4 + for val in self._modes.modevals + ] + for k, v in modestates.items(): + if states == v: + return k return type( "BusModeMixin", (IRemote,), { "identifier": property(identifier), + "modestates": modestates, **{mode.name: bus_mode_prop(mode.name) for mode in BusModes}, "get": get, }, diff --git a/vban_cmd/meta.py b/vban_cmd/meta.py index 3cb7f5a..e99a275 100644 --- a/vban_cmd/meta.py +++ b/vban_cmd/meta.py @@ -70,26 +70,11 @@ def bus_mode_prop(param): def fget(self): cmd = self._cmd(param) self.logger.debug(f"getter: {cmd}") - 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 + return [ + (int.from_bytes(self.public_packet.busstate[self.index], "little") & val) + >> 4 for val in self._modes.modevals - ) - if param == "normal": - return not any(vals) - return tuple(round(val / 16) for val in vals) == modelist[param] + ] == self.modestates[param] def fset(self, val): self.setter(param, 1 if val else 0)