diff --git a/pyproject.toml b/pyproject.toml index 96c12d2..ab69681 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "vban-cmd" -version = "1.1.2" +version = "1.1.3" description = "Python interface for the VBAN RT Packet Service (Sendtext)" authors = ["onyx-and-iris "] license = "MIT" diff --git a/vban_cmd/base.py b/vban_cmd/base.py index 9a0509e..ffb06ff 100644 --- a/vban_cmd/base.py +++ b/vban_cmd/base.py @@ -14,7 +14,7 @@ from .packet import ( VBAN_VMRT_Packet_Header, ) from .subject import Subject -from .util import script +from .util import comp, script Socket = IntEnum("Socket", "register request response", start=0) @@ -170,14 +170,8 @@ class VbanCmd(metaclass=ABCMeta): def ldirty(self): """True iff a level value has changed.""" self._strip_comp, self._bus_comp = ( - tuple( - not a == b - for a, b in zip(self._public_packet.inputlevels, self._strip_buf) - ), - tuple( - not a == b - for a, b in zip(self._public_packet.outputlevels, self._bus_buf) - ), + tuple(not x for x in comp(self.cache["strip_level"], self._strip_buf)), + tuple(not x for x in comp(self.cache["bus_level"], self._bus_buf)), ) return any(any(l) for l in (self._strip_comp, self._bus_comp)) @@ -201,8 +195,8 @@ class VbanCmd(metaclass=ABCMeta): self._pdirty = self._pp.pdirty(self.public_packet) if self.ldirty: - self.cache["strip_level"] = tuple(self._strip_buf) - self.cache["bus_level"] = tuple(self._bus_buf) + self.cache["strip_level"] = self._strip_buf + self.cache["bus_level"] = self._bus_buf self.subject.notify("ldirty") if self.public_packet != self._pp: self._public_packet = self._pp @@ -219,8 +213,8 @@ class VbanCmd(metaclass=ABCMeta): strip levels in PREFADER mode. """ return ( - [val for val in packet.inputlevels], - [val for val in packet.outputlevels], + tuple(val for val in packet.inputlevels), + tuple(val for val in packet.outputlevels), ) def apply(self, data: dict): diff --git a/vban_cmd/bus.py b/vban_cmd/bus.py index 147d8f4..1b0fca9 100644 --- a/vban_cmd/bus.py +++ b/vban_cmd/bus.py @@ -71,7 +71,6 @@ class BusLevel(IRemote): def getter(self): """Returns a tuple of level values for the channel.""" - range_ = self.level_map[self.index] return tuple( round(-i * 0.01, 1) for i in self._remote.cache["bus_level"][self.range[0] : self.range[-1]] diff --git a/vban_cmd/util.py b/vban_cmd/util.py index 9f23661..2c92da5 100644 --- a/vban_cmd/util.py +++ b/vban_cmd/util.py @@ -1,3 +1,6 @@ +from typing import Iterator + + def cache_bool(func, param): """Check cache for a bool prop""" @@ -49,3 +52,15 @@ def script(func): return func(remote, script) return wrapper + + +def comp(t0: tuple, t1: tuple) -> Iterator[bool]: + """ + Generator function, accepts two tuples. + + Evaluates equality of each member in both tuples. + """ + for a, b in zip(t0, t1): + if b <= 9500: + yield a == b + yield True