add apply

add apply to vbancmd and channel modules.

add apply to readme
This commit is contained in:
onyx-and-iris
2022-03-11 19:21:26 +00:00
parent 127ef1e10f
commit 3e0152082b
3 changed files with 44 additions and 16 deletions

View File

@@ -73,3 +73,10 @@ class Channel(abc.ABC):
def public_packet(self):
""" Returns an RT data packet. """
return self._remote.public_packet
def apply(self, mapping):
""" Sets all parameters of a dict for the strip. """
for key, val in mapping.items():
if not hasattr(self, key):
raise VMCMDErrors(f'Invalid {self.identifier} attribute: {key}')
setattr(self, key, val)

View File

@@ -74,7 +74,7 @@ class VbanCmd(abc.ABC):
while self.running:
if self._rt_register_socket in self.ready_to_write:
self._rt_register_socket.sendto(
self._register_rt_header.header + bytes(1), (socket.gethostbyname(self._ip), self._port)
self._register_rt_header.header, (socket.gethostbyname(self._ip), self._port)
)
count = int.from_bytes(self._register_rt_header.framecounter, 'little') + 1
self._register_rt_header.framecounter = count.to_bytes(4, 'little')
@@ -185,6 +185,19 @@ class VbanCmd(abc.ABC):
""" Restarts Voicemeeter's audio engine. """
self.set_rt('Command', 'Restart', 1)
def apply(self, mapping: dict):
""" Sets all parameters of a di """
for key, submapping in mapping.items():
obj, index = key.split('-')
if obj in ('strip'):
target = self.strip[int(index)]
elif obj in ('bus'):
target = self.bus[int(index)]
else:
raise ValueError(obj)
target.apply(submapping)
def close(self):
""" sets thread flag, closes sockets """
self.running = False