mirror of
https://github.com/onyx-and-iris/voicemeeter-compact.git
synced 2024-11-21 20:30:56 +00:00
optimizations to reduce the number of api calls
comp, gate, eq parameter calls updated.
This commit is contained in:
parent
3b6e1f61a4
commit
d4df11f62d
@ -12,6 +12,8 @@ from .config import BusConfig, StripConfig
|
|||||||
from .data import _base_values, _configuration
|
from .data import _base_values, _configuration
|
||||||
from .navigation import Navigation
|
from .navigation import Navigation
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class AbstractBuilder(abc.ABC):
|
class AbstractBuilder(abc.ABC):
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
@ -28,11 +30,10 @@ class AbstractBuilder(abc.ABC):
|
|||||||
class MainFrameBuilder(AbstractBuilder):
|
class MainFrameBuilder(AbstractBuilder):
|
||||||
"""Responsible for building the frames that sit directly on the mainframe"""
|
"""Responsible for building the frames that sit directly on the mainframe"""
|
||||||
|
|
||||||
logger = logging.getLogger("builders.mainframebuilder")
|
|
||||||
|
|
||||||
def __init__(self, app):
|
def __init__(self, app):
|
||||||
self.kind = app.kind
|
self.kind = app.kind
|
||||||
self.app = app
|
self.app = app
|
||||||
|
self.logger = logger.getChild(self.__class__.__name__)
|
||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
self.app.title(
|
self.app.title(
|
||||||
@ -336,7 +337,7 @@ class StripConfigFrameBuilder(ChannelConfigFrameBuilder):
|
|||||||
self.configframe.slider_params = ("audibility",)
|
self.configframe.slider_params = ("audibility",)
|
||||||
self.configframe.slider_vars = (tk.DoubleVar(),)
|
self.configframe.slider_vars = (tk.DoubleVar(),)
|
||||||
else:
|
else:
|
||||||
self.configframe.slider_params = ("comp", "gate", "limit")
|
self.configframe.slider_params = ("comp.knob", "gate.knob", "limit")
|
||||||
self.configframe.slider_vars = [
|
self.configframe.slider_vars = [
|
||||||
tk.DoubleVar() for _ in self.configframe.slider_params
|
tk.DoubleVar() for _ in self.configframe.slider_params
|
||||||
]
|
]
|
||||||
@ -393,16 +394,16 @@ class StripConfigFrameBuilder(ChannelConfigFrameBuilder):
|
|||||||
orient="horizontal",
|
orient="horizontal",
|
||||||
length=_configuration.level_width,
|
length=_configuration.level_width,
|
||||||
variable=self.configframe.slider_vars[
|
variable=self.configframe.slider_vars[
|
||||||
self.configframe.slider_params.index("comp")
|
self.configframe.slider_params.index("comp.knob")
|
||||||
],
|
],
|
||||||
command=partial(self.configframe.scale_callback, "comp"),
|
command=partial(self.configframe.scale_callback, "comp.knob"),
|
||||||
)
|
)
|
||||||
comp_scale.bind(
|
comp_scale.bind(
|
||||||
"<Double-Button-1>", partial(self.configframe.reset_scale, "comp", 0)
|
"<Double-Button-1>", partial(self.configframe.reset_scale, "comp.knob", 0)
|
||||||
)
|
)
|
||||||
comp_scale.bind("<Button-1>", self.configframe.scale_press)
|
comp_scale.bind("<Button-1>", self.configframe.scale_press)
|
||||||
comp_scale.bind("<ButtonRelease-1>", self.configframe.scale_release)
|
comp_scale.bind("<ButtonRelease-1>", self.configframe.scale_release)
|
||||||
comp_scale.bind("<Enter>", partial(self.configframe.scale_enter, "comp"))
|
comp_scale.bind("<Enter>", partial(self.configframe.scale_enter, "comp.knob"))
|
||||||
comp_scale.bind("<Leave>", self.configframe.scale_leave)
|
comp_scale.bind("<Leave>", self.configframe.scale_leave)
|
||||||
|
|
||||||
comp_label.grid(column=0, row=0)
|
comp_label.grid(column=0, row=0)
|
||||||
@ -417,16 +418,16 @@ class StripConfigFrameBuilder(ChannelConfigFrameBuilder):
|
|||||||
orient="horizontal",
|
orient="horizontal",
|
||||||
length=_configuration.level_width,
|
length=_configuration.level_width,
|
||||||
variable=self.configframe.slider_vars[
|
variable=self.configframe.slider_vars[
|
||||||
self.configframe.slider_params.index("gate")
|
self.configframe.slider_params.index("gate.knob")
|
||||||
],
|
],
|
||||||
command=partial(self.configframe.scale_callback, "gate"),
|
command=partial(self.configframe.scale_callback, "gate.knob"),
|
||||||
)
|
)
|
||||||
gate_scale.bind(
|
gate_scale.bind(
|
||||||
"<Double-Button-1>", partial(self.configframe.reset_scale, "gate", 0)
|
"<Double-Button-1>", partial(self.configframe.reset_scale, "gate.knob", 0)
|
||||||
)
|
)
|
||||||
gate_scale.bind("<Button-1>", self.configframe.scale_press)
|
gate_scale.bind("<Button-1>", self.configframe.scale_press)
|
||||||
gate_scale.bind("<ButtonRelease-1>", self.configframe.scale_release)
|
gate_scale.bind("<ButtonRelease-1>", self.configframe.scale_release)
|
||||||
gate_scale.bind("<Enter>", partial(self.configframe.scale_enter, "gate"))
|
gate_scale.bind("<Enter>", partial(self.configframe.scale_enter, "gate.knob"))
|
||||||
gate_scale.bind("<Leave>", self.configframe.scale_leave)
|
gate_scale.bind("<Leave>", self.configframe.scale_leave)
|
||||||
|
|
||||||
gate_label.grid(column=2, row=0)
|
gate_label.grid(column=2, row=0)
|
||||||
@ -563,7 +564,7 @@ class BusConfigFrameBuilder(ChannelConfigFrameBuilder):
|
|||||||
}
|
}
|
||||||
self.configframe.bus_modes = list(self.configframe.bus_mode_map.keys())
|
self.configframe.bus_modes = list(self.configframe.bus_mode_map.keys())
|
||||||
# fmt: on
|
# fmt: on
|
||||||
self.configframe.params = ("mono", "eq", "eq_ab")
|
self.configframe.params = ("mono", "eq.on", "eq.ab")
|
||||||
self.configframe.param_vars = [tk.BooleanVar() for _ in self.configframe.params]
|
self.configframe.param_vars = [tk.BooleanVar() for _ in self.configframe.params]
|
||||||
self.configframe.bus_mode_label_text = tk.StringVar(
|
self.configframe.bus_mode_label_text = tk.StringVar(
|
||||||
value=self.configframe.bus_mode_map[self.configframe.current_bus_mode()]
|
value=self.configframe.bus_mode_map[self.configframe.current_bus_mode()]
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
import tkinter as tk
|
import logging
|
||||||
from functools import partial
|
|
||||||
from tkinter import ttk
|
from tkinter import ttk
|
||||||
|
|
||||||
from . import builders
|
from . import builders
|
||||||
from .data import _base_values, _configuration
|
from .data import _base_values, _configuration
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class Config(ttk.Frame):
|
class Config(ttk.Frame):
|
||||||
def __init__(self, parent, index, _id):
|
def __init__(self, parent, index, _id):
|
||||||
@ -12,6 +13,7 @@ class Config(ttk.Frame):
|
|||||||
self.parent = parent
|
self.parent = parent
|
||||||
self.index = index
|
self.index = index
|
||||||
self.id = _id
|
self.id = _id
|
||||||
|
self.logger = logger.getChild(self.__class__.__name__)
|
||||||
self.styletable = parent.styletable
|
self.styletable = parent.styletable
|
||||||
self.phys_in, self.virt_in = parent.kind.ins
|
self.phys_in, self.virt_in = parent.kind.ins
|
||||||
self.phys_out, self.virt_out = parent.kind.outs
|
self.phys_out, self.virt_out = parent.kind.outs
|
||||||
@ -29,12 +31,26 @@ class Config(ttk.Frame):
|
|||||||
return self.parent.target
|
return self.parent.target
|
||||||
|
|
||||||
def getter(self, param):
|
def getter(self, param):
|
||||||
if hasattr(self.target, param):
|
param = param.split(".")
|
||||||
return getattr(self.target, param)
|
try:
|
||||||
|
if len(param) == 2:
|
||||||
|
target = getattr(self.target, param[0])
|
||||||
|
return getattr(target, param[1])
|
||||||
|
else:
|
||||||
|
return getattr(self.target, param[0])
|
||||||
|
except AttributeError as e:
|
||||||
|
self.logger.error(f"{type(e).__name__}: {e}")
|
||||||
|
|
||||||
def setter(self, param, value):
|
def setter(self, param, value):
|
||||||
if hasattr(self.target, param):
|
param = param.split(".")
|
||||||
setattr(self.target, param, value)
|
try:
|
||||||
|
if len(param) == 2:
|
||||||
|
target = getattr(self.target, param[0])
|
||||||
|
setattr(target, param[1], value)
|
||||||
|
else:
|
||||||
|
setattr(self.target, param[0], value)
|
||||||
|
except AttributeError as e:
|
||||||
|
self.logger(f"{type(e).__name__}: {e}")
|
||||||
|
|
||||||
def scale_press(self, *args):
|
def scale_press(self, *args):
|
||||||
self.after(1, self.remove_events)
|
self.after(1, self.remove_events)
|
||||||
@ -66,7 +82,7 @@ class Config(ttk.Frame):
|
|||||||
"""callback function for scale widget"""
|
"""callback function for scale widget"""
|
||||||
|
|
||||||
val = self.slider_vars[self.slider_params.index(param)].get()
|
val = self.slider_vars[self.slider_params.index(param)].get()
|
||||||
self.setter(param, val)
|
self.setter(param, round(val, 1))
|
||||||
self.parent.nav_frame.info_text.set(round(val, 1))
|
self.parent.nav_frame.info_text.set(round(val, 1))
|
||||||
|
|
||||||
def reset_scale(self, param, val, *args):
|
def reset_scale(self, param, val, *args):
|
||||||
@ -98,6 +114,7 @@ class StripConfig(Config):
|
|||||||
self.make_row_2()
|
self.make_row_2()
|
||||||
self.builder.grid_configure()
|
self.builder.grid_configure()
|
||||||
|
|
||||||
|
self.parent.target.clear_dirty()
|
||||||
self.sync()
|
self.sync()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -155,6 +172,12 @@ class StripConfig(Config):
|
|||||||
self.param_vars[i].set(self.getter(param))
|
self.param_vars[i].set(self.getter(param))
|
||||||
for i, param in enumerate(self.params)
|
for i, param in enumerate(self.params)
|
||||||
]
|
]
|
||||||
|
if not _base_values.vban_connected: # slider vars not defined in RT Packet
|
||||||
|
[
|
||||||
|
self.slider_vars[i].set(self.getter(param))
|
||||||
|
for i, param in enumerate(self.slider_params)
|
||||||
|
if self.index < self.phys_in
|
||||||
|
]
|
||||||
|
|
||||||
if not _configuration.themes_enabled:
|
if not _configuration.themes_enabled:
|
||||||
[
|
[
|
||||||
@ -193,6 +216,7 @@ class BusConfig(Config):
|
|||||||
self.make_row_1()
|
self.make_row_1()
|
||||||
self.builder.grid_configure()
|
self.builder.grid_configure()
|
||||||
|
|
||||||
|
self.parent.target.clear_dirty()
|
||||||
self.sync()
|
self.sync()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import tkinter as tk
|
import tkinter as tk
|
||||||
from math import log
|
|
||||||
from tkinter import ttk
|
from tkinter import ttk
|
||||||
|
|
||||||
from . import builders
|
from . import builders
|
||||||
@ -42,11 +41,13 @@ class GainLayer(ttk.LabelFrame):
|
|||||||
return "gainlayer"
|
return "gainlayer"
|
||||||
|
|
||||||
def getter(self, param):
|
def getter(self, param):
|
||||||
if hasattr(self.target, param):
|
try:
|
||||||
return getattr(self.target, param)
|
return getattr(self.target, param)
|
||||||
|
except AttributeError as e:
|
||||||
|
self.logger(f"{type(e).__name__}: {e}")
|
||||||
|
|
||||||
def setter(self, param, value):
|
def setter(self, param, value):
|
||||||
if hasattr(self.target, param):
|
if param in dir(self.target): # avoid calling getattr (with hasattr)
|
||||||
setattr(self.target, param, value)
|
setattr(self.target, param, value)
|
||||||
|
|
||||||
def reset_gain(self, *args):
|
def reset_gain(self, *args):
|
||||||
@ -57,8 +58,9 @@ class GainLayer(ttk.LabelFrame):
|
|||||||
def scale_callback(self, *args):
|
def scale_callback(self, *args):
|
||||||
"""callback function for scale widget"""
|
"""callback function for scale widget"""
|
||||||
|
|
||||||
self.setter("gain", self.gain.get())
|
val = round(self.gain.get(), 1)
|
||||||
self.gainlabel.set(round(self.gain.get(), 1))
|
self.setter("gain", val)
|
||||||
|
self.gainlabel.set(val)
|
||||||
|
|
||||||
def scale_press(self, *args):
|
def scale_press(self, *args):
|
||||||
self.after(1, self.remove_events)
|
self.after(1, self.remove_events)
|
||||||
@ -157,7 +159,8 @@ class GainLayer(ttk.LabelFrame):
|
|||||||
self.level.set(
|
self.level.set(
|
||||||
(
|
(
|
||||||
0
|
0
|
||||||
if self.parent.target.strip[self.index].mute or not self.on.get()
|
if self.parent.parent.strip_frame.strips[self.index].mute.get()
|
||||||
|
or not self.on.get()
|
||||||
else 72 + val - 12 + self.gain.get()
|
else 72 + val - 12 + self.gain.get()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user