mirror of
https://github.com/onyx-and-iris/voicemeeter-compact.git
synced 2024-11-15 17:40:52 +00:00
changes to level updates
strip/bus levels compared by index iteratively. strip/bus level array size added to _base_vals dataclass. Helps to keep track of level array size when switching between kinds. level_offset class attributes added to strip/bus/gainlayer labelframe classes. watch_levels adjusted to only updated frames when a level has changed.
This commit is contained in:
parent
4ce288e474
commit
26832b3cb9
@ -67,10 +67,8 @@ class App(tk.Tk):
|
||||
|
||||
# start pdirty watcher
|
||||
self.upd_pdirty()
|
||||
self.strip_levels = None
|
||||
self.bus_levels = None
|
||||
self._strip_levels = None
|
||||
self._bus_levels = None
|
||||
self.strip_levels = self.target.strip_levels
|
||||
self.bus_levels = self.target.bus_levels
|
||||
self.watch_levels()
|
||||
|
||||
self.resizable(False, False)
|
||||
@ -180,20 +178,16 @@ class App(tk.Tk):
|
||||
self.after(1, self.watch_levels_step)
|
||||
|
||||
def watch_levels_step(self):
|
||||
"""
|
||||
Continuously fetch level arrays, only update
|
||||
if ldirty
|
||||
"""
|
||||
self._strip_levels = self.target.strip_levels
|
||||
self._bus_levels = self.target.bus_levels
|
||||
"""Continuously fetch level arrays, only update if ldirty"""
|
||||
_strip_levels = self.target.strip_levels
|
||||
_bus_levels = self.target.bus_levels
|
||||
self.comp_strip = [not a == b for a, b in zip(self.strip_levels, _strip_levels)]
|
||||
self.comp_bus = [not a == b for a, b in zip(self.bus_levels, _bus_levels)]
|
||||
|
||||
self.ldirty = not (
|
||||
self.strip_levels == self._strip_levels
|
||||
and self.bus_levels == self._bus_levels
|
||||
)
|
||||
self.ldirty = any(self.comp_strip) or any(self.comp_bus)
|
||||
if self.ldirty:
|
||||
self.strip_levels = self._strip_levels
|
||||
self.bus_levels = self._bus_levels
|
||||
self.strip_levels = _strip_levels
|
||||
self.bus_levels = _bus_levels
|
||||
self.after(_base_vals.ldelay, self.watch_levels_step)
|
||||
|
||||
def dragging(self, event, *args):
|
||||
|
@ -175,6 +175,10 @@ class Strip(Channel):
|
||||
|
||||
def __init__(self, parent, index, id):
|
||||
super().__init__(parent, index, id)
|
||||
if index <= parent.phys_in:
|
||||
self.level_offset = index * 2
|
||||
else:
|
||||
self.level_offset = parent.phys_in * 2 + (index - parent.phys_in) * 8
|
||||
|
||||
@property
|
||||
def target(self):
|
||||
@ -207,30 +211,39 @@ class Strip(Channel):
|
||||
|
||||
def watch_levels_step(self):
|
||||
if not _base_vals.dragging:
|
||||
if self._parent._parent.ldirty:
|
||||
if self.index <= self._parent.phys_in:
|
||||
if (
|
||||
self._parent._parent.ldirty
|
||||
and _base_vals.strip_level_array_size
|
||||
== len(self._parent._parent.comp_strip)
|
||||
):
|
||||
if self.index <= self._parent.phys_in and any(
|
||||
self._parent._parent.comp_strip[
|
||||
self.level_offset : self.level_offset + 1
|
||||
]
|
||||
):
|
||||
vals = (
|
||||
self.convert_level(
|
||||
self._parent._parent.strip_levels[self.index * 2]
|
||||
self._parent._parent.strip_levels[self.level_offset]
|
||||
),
|
||||
self.convert_level(
|
||||
self._parent._parent.strip_levels[self.index * 2 + 1]
|
||||
self._parent._parent.strip_levels[self.level_offset + 1]
|
||||
),
|
||||
)
|
||||
else:
|
||||
peak = vals[0] if vals[0] > vals[1] else vals[1]
|
||||
self.level.set(
|
||||
(0 if self.mute.get() else 100 + (peak - 18) + self.gain.get())
|
||||
)
|
||||
elif any(
|
||||
self._parent._parent.comp_strip[
|
||||
self.level_offset : self.level_offset + 1
|
||||
]
|
||||
):
|
||||
vals = (
|
||||
self.convert_level(
|
||||
self._parent._parent.strip_levels[
|
||||
self._parent.phys_in * 2
|
||||
+ (self.index - self._parent.phys_in) * 8
|
||||
]
|
||||
self._parent._parent.strip_levels[self.level_offset]
|
||||
),
|
||||
self.convert_level(
|
||||
self._parent._parent.strip_levels[
|
||||
self._parent.phys_in * 2
|
||||
+ (self.index - self._parent.phys_in) * 8
|
||||
+ 1
|
||||
]
|
||||
self._parent._parent.strip_levels[self.level_offset + 1]
|
||||
),
|
||||
)
|
||||
peak = vals[0] if vals[0] > vals[1] else vals[1]
|
||||
@ -248,6 +261,7 @@ class Bus(Channel):
|
||||
|
||||
def __init__(self, parent, index, id):
|
||||
super().__init__(parent, index, id)
|
||||
self.level_offset = self.index * 8
|
||||
|
||||
@property
|
||||
def target(self):
|
||||
@ -282,11 +296,20 @@ class Bus(Channel):
|
||||
|
||||
def watch_levels_step(self):
|
||||
if not _base_vals.dragging:
|
||||
if self._parent._parent.ldirty:
|
||||
if self._parent._parent.ldirty and _base_vals.bus_level_array_size == len(
|
||||
self._parent._parent.comp_bus
|
||||
):
|
||||
if any(
|
||||
self._parent._parent.comp_bus[
|
||||
self.level_offset : self.level_offset + 1
|
||||
]
|
||||
):
|
||||
vals = (
|
||||
self.convert_level(self._parent._parent.bus_levels[self.index * 8]),
|
||||
self.convert_level(
|
||||
self._parent._parent.bus_levels[self.index * 8 + 1]
|
||||
self._parent._parent.bus_levels[self.level_offset]
|
||||
),
|
||||
self.convert_level(
|
||||
self._parent._parent.bus_levels[self.level_offset + 1]
|
||||
),
|
||||
)
|
||||
peak = vals[0] if vals[0] > vals[1] else vals[1]
|
||||
@ -312,6 +335,8 @@ class ChannelFrame(ttk.Frame):
|
||||
self._is_strip = is_strip
|
||||
self.phys_in, self.virt_in = parent.kind.ins
|
||||
self.phys_out, self.virt_out = parent.kind.outs
|
||||
_base_vals.strip_level_array_size = 2 * self.phys_in + 8 * self.virt_in
|
||||
_base_vals.bus_level_array_size = 8 * (self.phys_out + self.virt_out)
|
||||
|
||||
defaults = {
|
||||
"width": 80,
|
||||
|
@ -25,6 +25,10 @@ class BaseValues:
|
||||
pdelay: int = 5
|
||||
# ldirty delay
|
||||
ldelay: int = 50
|
||||
# size of strip level array for a kind
|
||||
strip_level_array_size: int = None
|
||||
# size of bus level array for a kind
|
||||
bus_level_array_size: int = None
|
||||
|
||||
|
||||
_base_vals = BaseValues()
|
||||
|
@ -18,6 +18,10 @@ class GainLayer(ttk.LabelFrame):
|
||||
self.level = tk.DoubleVar()
|
||||
self.on = tk.BooleanVar()
|
||||
self.s = self._parent._parent.styletable
|
||||
if index <= parent.phys_in:
|
||||
self.level_offset = index * 2
|
||||
else:
|
||||
self.level_offset = parent.phys_in * 2 + (index - parent.phys_in) * 8
|
||||
|
||||
self.sync()
|
||||
self._make_widgets()
|
||||
@ -162,30 +166,22 @@ class GainLayer(ttk.LabelFrame):
|
||||
|
||||
def watch_levels_step(self):
|
||||
if not _base_vals.dragging:
|
||||
if self._parent._parent.ldirty:
|
||||
if self.index <= self._parent.phys_in:
|
||||
if (
|
||||
self._parent._parent.ldirty
|
||||
and _base_vals.strip_level_array_size
|
||||
== len(self._parent._parent.comp_strip)
|
||||
):
|
||||
if self.index <= self._parent.phys_in and any(
|
||||
self._parent._parent.comp_strip[
|
||||
self.level_offset : self.level_offset + 1
|
||||
]
|
||||
):
|
||||
vals = (
|
||||
self.convert_level(
|
||||
self._parent._parent.strip_levels[self.index * 2]
|
||||
self._parent._parent.strip_levels[self.level_offset]
|
||||
),
|
||||
self.convert_level(
|
||||
self._parent._parent.strip_levels[self.index * 2 + 1]
|
||||
),
|
||||
)
|
||||
else:
|
||||
vals = (
|
||||
self.convert_level(
|
||||
self._parent._parent.strip_levels[
|
||||
self._parent.phys_in * 2
|
||||
+ (self.index - self._parent.phys_in) * 8
|
||||
]
|
||||
),
|
||||
self.convert_level(
|
||||
self._parent._parent.strip_levels[
|
||||
self._parent.phys_in * 2
|
||||
+ (self.index - self._parent.phys_in) * 8
|
||||
+ 1
|
||||
]
|
||||
self._parent._parent.strip_levels[self.level_offset + 1]
|
||||
),
|
||||
)
|
||||
peak = vals[0] if vals[0] > vals[1] else vals[1]
|
||||
@ -195,6 +191,31 @@ class GainLayer(ttk.LabelFrame):
|
||||
if self._parent._parent.channel_frame.strips[
|
||||
self.index
|
||||
].mute.get()
|
||||
or not self.on.get()
|
||||
else 100 + (peak - 18) + self.gain.get()
|
||||
)
|
||||
)
|
||||
elif any(
|
||||
self._parent._parent.comp_strip[
|
||||
self.level_offset : self.level_offset + 1
|
||||
]
|
||||
):
|
||||
vals = (
|
||||
self.convert_level(
|
||||
self._parent._parent.strip_levels[self.level_offset]
|
||||
),
|
||||
self.convert_level(
|
||||
self._parent._parent.strip_levels[self.level_offset + 1]
|
||||
),
|
||||
)
|
||||
peak = vals[0] if vals[0] > vals[1] else vals[1]
|
||||
self.level.set(
|
||||
(
|
||||
0
|
||||
if self._parent._parent.channel_frame.strips[
|
||||
self.index
|
||||
].mute.get()
|
||||
or not self.on.get()
|
||||
else 100 + (peak - 18) + self.gain.get()
|
||||
)
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user