From f996fc0d9c09ff28e97bcfb24525e66cc30beb32 Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Thu, 20 Jul 2023 11:10:05 +0100 Subject: [PATCH] num_strip_levels, num_bus_levesl added to KindMaps --- voicemeeterlib/kinds.py | 20 ++++++++++++++------ voicemeeterlib/remote.py | 20 ++++++++------------ voicemeeterlib/updater.py | 6 ++---- 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/voicemeeterlib/kinds.py b/voicemeeterlib/kinds.py index 218d676..3b6f54a 100644 --- a/voicemeeterlib/kinds.py +++ b/voicemeeterlib/kinds.py @@ -32,29 +32,37 @@ class KindMapClass(metaclass=SingletonType): insert: int @property - def phys_in(self): + def phys_in(self) -> int: return self.ins[0] @property - def virt_in(self): + def virt_in(self) -> int: return self.ins[-1] @property - def phys_out(self): + def phys_out(self) -> int: return self.outs[0] @property - def virt_out(self): + def virt_out(self) -> int: return self.outs[-1] @property - def num_strip(self): + def num_strip(self) -> int: return sum(self.ins) @property - def num_bus(self): + def num_bus(self) -> int: return sum(self.outs) + @property + def num_strip_levels(self) -> int: + return 2 * self.phys_in + 8 * self.virt_in + + @property + def num_bus_levels(self) -> int: + return 8 * (self.phys_out + self.virt_out) + def __str__(self) -> str: return self.name.capitalize() diff --git a/voicemeeterlib/remote.py b/voicemeeterlib/remote.py index ad25cf6..323b7e8 100644 --- a/voicemeeterlib/remote.py +++ b/voicemeeterlib/remote.py @@ -1,4 +1,3 @@ -import copy import ctypes as ct import logging import time @@ -244,12 +243,9 @@ class Remote(CBindings): return ( tuple( self.get_level(self.strip_mode, i) - for i in range(2 * self.kind.phys_in + 8 * self.kind.virt_in) - ), - tuple( - self.get_level(3, i) - for i in range(8 * (self.kind.phys_out + self.kind.virt_out)) + for i in range(self.kind.num_strip_levels) ), + tuple(self.get_level(3, i) for i in range(self.kind.num_bus_levels)), ) def get_midi_message(self): @@ -325,16 +321,16 @@ class Remote(CBindings): self.apply(config) self.logger.info(f"Profile '{name}' applied!") - def logout(self) -> NoReturn: - """Wait for dirty parameters to clear, then logout of the API""" - time.sleep(0.1) - self.call(self.vm_logout) - self.logger.info(f"{type(self).__name__}: Successfully logged out of {self}") - def end_thread(self): self.logger.debug("events thread shutdown started") self.running = False + def logout(self) -> NoReturn: + """Logout of the API""" + time.sleep(0.1) + self.call(self.vm_logout) + self.logger.info(f"{type(self).__name__}: Successfully logged out of {self}") + def __exit__(self, exc_type, exc_value, exc_traceback) -> NoReturn: """teardown procedures""" self.end_thread() diff --git a/voicemeeterlib/updater.py b/voicemeeterlib/updater.py index 8b48d3e..a682555 100644 --- a/voicemeeterlib/updater.py +++ b/voicemeeterlib/updater.py @@ -36,10 +36,8 @@ class Updater(threading.Thread): super().__init__(name="updater", daemon=True) self._remote = remote self.queue = queue - self._remote._strip_comp = [False] * ( - 2 * self._remote.kind.phys_in + 8 * self._remote.kind.virt_in - ) - self._remote._bus_comp = [False] * (self._remote.kind.num_bus * 8) + self._remote._strip_comp = [False] * (self._remote.kind.num_strip_levels) + self._remote._bus_comp = [False] * (self._remote.kind.num_bus_levels) ( self._remote.cache["strip_level"], self._remote.cache["bus_level"],