mirror of
https://github.com/onyx-and-iris/vban-cmd-python.git
synced 2026-04-06 23:53:31 +00:00
add apply
add apply to vbancmd and channel modules. add apply to readme
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user