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"],