in comp, consider level value clean if below -60.0

vbancmd:
pass tuple expansion into string format in version method.
ldirty and _get_levels logic now moved into rt packet class
This commit is contained in:
onyx-and-iris 2022-10-04 15:42:36 +01:00
parent 8663aab2ce
commit 4659cf7cdb
2 changed files with 10 additions and 13 deletions

View File

@ -61,10 +61,12 @@ def comp(t0: tuple, t1: tuple) -> Iterator[bool]:
Evaluates equality of each member in both tuples. Evaluates equality of each member in both tuples.
""" """
for a, b in zip(t0, t1): for a, b in zip(t0, t1):
if b <= 9500: if ((1 << 16) - 1) - b <= 6000:
yield a == b yield a == b
yield True else:
yield True
Socket = IntEnum("Socket", "register request response", start=0) Socket = IntEnum("Socket", "register request response", start=0)

View File

@ -7,7 +7,7 @@ from typing import Iterable, Optional, Union
from .event import Event from .event import Event
from .packet import RequestHeader from .packet import RequestHeader
from .subject import Subject from .subject import Subject
from .util import Socket, comp, script from .util import Socket, script
from .worker import Subscriber, Updater from .worker import Subscriber, Updater
@ -37,7 +37,7 @@ class VbanCmd(metaclass=ABCMeta):
socket.socket(socket.AF_INET, socket.SOCK_DGRAM) for _ in Socket socket.socket(socket.AF_INET, socket.SOCK_DGRAM) for _ in Socket
) )
self.subject = Subject() self.subject = Subject()
self.cache = dict() self.cache = {}
self.event = Event(self.subs) self.event = Event(self.subs)
@abstractmethod @abstractmethod
@ -95,8 +95,7 @@ class VbanCmd(metaclass=ABCMeta):
@property @property
def version(self) -> str: def version(self) -> str:
"""Returns Voicemeeter's version as a string""" """Returns Voicemeeter's version as a string"""
v1, v2, v3, v4 = self.public_packet.voicemeeterversion return "{0}.{1}.{2}.{3}".format(*self.public_packet.voicemeeterversion)
return f"{v1}.{v2}.{v3}.{v4}"
@property @property
def pdirty(self): def pdirty(self):
@ -106,11 +105,7 @@ class VbanCmd(metaclass=ABCMeta):
@property @property
def ldirty(self): def ldirty(self):
"""True iff a level value has changed.""" """True iff a level value has changed."""
self._strip_comp, self._bus_comp = ( return self._ldirty
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))
@property @property
def public_packet(self): def public_packet(self):
@ -127,8 +122,8 @@ class VbanCmd(metaclass=ABCMeta):
strip levels in PREFADER mode. strip levels in PREFADER mode.
""" """
return ( return (
tuple(((1 << 16) - 1) - val for val in packet.inputlevels), packet.inputlevels,
tuple(((1 << 16) - 1) - val for val in packet.outputlevels), packet.outputlevels,
) )
def apply(self, data: dict): def apply(self, data: dict):