mirror of
https://github.com/onyx-and-iris/vban-cmd-python.git
synced 2025-01-18 18:40:47 +00:00
util:
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:
parent
8663aab2ce
commit
4659cf7cdb
@ -61,9 +61,11 @@ 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
|
||||||
|
else:
|
||||||
yield True
|
yield True
|
||||||
|
|
||||||
|
|
||||||
|
@ -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):
|
||||||
|
Loading…
Reference in New Issue
Block a user