From 92e04f14196cd643697891641b196e0e618d50c3 Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Fri, 23 Jun 2023 01:19:55 +0100 Subject: [PATCH] comp, gate, denoiser, eq params updated in TOMLStrBuilder Path.home() / ".config" / "voicemeeter" / kind.name added to loader path --- voicemeeterlib/config.py | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/voicemeeterlib/config.py b/voicemeeterlib/config.py index 1e0cbf9..c1c7fdf 100644 --- a/voicemeeterlib/config.py +++ b/voicemeeterlib/config.py @@ -2,6 +2,8 @@ import itertools import logging from pathlib import Path +from .error import VMError + try: import tomllib except ModuleNotFoundError: @@ -9,6 +11,8 @@ except ModuleNotFoundError: from .kinds import request_kind_map as kindmap +logger = logging.getLogger(__name__) + class TOMLStrBuilder: """builds a config profile, as a string, for the toml parser""" @@ -32,10 +36,17 @@ class TOMLStrBuilder: + [f"B{i} = false" for i in range(1, self.kind.virt_out + 1)] ) self.phys_strip_params = self.virt_strip_params + [ - "comp = 0.0", - "gate = 0.0", + "comp.knob = 0.0", + "gate.knob = 0.0", + "denoiser.knob = 0.0", + "eq.on = false", + ] + self.bus_params = [ + "mono = false", + "eq.on = false", + "mute = false", + "gain = 0.0", ] - self.bus_bool = ["mono = false", "eq = false", "mute = false"] if profile == "reset": self.reset_config() @@ -66,7 +77,7 @@ class TOMLStrBuilder: else self.virt_strip_params ) case "bus": - toml_str += ("\n").join(self.bus_bool) + toml_str += ("\n").join(self.bus_params) case _: pass return toml_str + "\n" @@ -119,10 +130,9 @@ class Loader(metaclass=SingletonType): loads data into memory if not found """ - logger = logging.getLogger("config.Loader") - def __init__(self, kind): self._kind = kind + self.logger = logger.getChild(self.__class__.__name__) self._configs = dict() self.defaults(kind) self.parser = None @@ -166,16 +176,16 @@ def loader(kind): returns configs loaded into memory """ - logger = logging.getLogger("config.loader") + logger_loader = logger.getChild("loader") loader = Loader(kind) for path in ( Path.cwd() / "configs" / kind.name, - Path(__file__).parent / "configs" / kind.name, - Path.home() / "Documents/Voicemeeter" / "configs" / kind.name, + Path.home() / ".config" / "voicemeeter" / kind.name, + Path.home() / "Documents" / "Voicemeeter" / "configs" / kind.name, ): if path.is_dir(): - logger.info(f"Checking [{path}] for TOML config files:") + logger_loader.info(f"Checking [{path}] for TOML config files:") for file in path.glob("*.toml"): identifier = file.with_suffix("").stem if loader.parse(identifier, file): @@ -192,5 +202,5 @@ def request_config(kind_id: str): try: configs = loader(kindmap(kind_id)) except KeyError as e: - print(f"Unknown Voicemeeter kind '{kind_id}'") + raise VMError(f"Unknown Voicemeeter kind {kind_id}") from e return configs