refactor watch levels, now using max()

refactor watch levels.

now using max() to fetch peak
This commit is contained in:
onyx-and-iris 2022-04-14 18:05:17 +01:00
parent 1d29e5113c
commit 8f3672029a
2 changed files with 54 additions and 55 deletions

View File

@ -213,13 +213,13 @@ class Strip(Channel):
if not _base_vals.dragging:
if (
self._parent._parent.ldirty
and _base_vals.strip_level_array_size
== len(self._parent._parent.comp_strip)
):
if any(
and any(
self._parent._parent.comp_strip[
self.level_offset : self.level_offset + 1
]
)
and _base_vals.strip_level_array_size
== len(self._parent._parent.comp_strip)
):
vals = (
self.convert_level(
@ -229,9 +229,8 @@ class Strip(Channel):
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.mute.get() else 100 + (peak - 18) + self.gain.get())
(0 if self.mute.get() else 100 + (max(vals) - 18) + self.gain.get())
)
self.after(
_base_vals.ldelay if not _base_vals.in_scale_button_1 else 100,
@ -279,13 +278,15 @@ class Bus(Channel):
def watch_levels_step(self):
if not _base_vals.dragging:
if self._parent._parent.ldirty and _base_vals.bus_level_array_size == len(
self._parent._parent.comp_bus
):
if any(
if (
self._parent._parent.ldirty
and any(
self._parent._parent.comp_bus[
self.level_offset : self.level_offset + 1
]
)
and _base_vals.bus_level_array_size
== len(self._parent._parent.comp_bus)
):
vals = (
self.convert_level(
@ -295,8 +296,7 @@ class Bus(Channel):
self._parent._parent.bus_levels[self.level_offset + 1]
),
)
peak = vals[0] if vals[0] > vals[1] else vals[1]
self.level.set((0 if self.mute.get() else 100 + (peak - 18)))
self.level.set((0 if self.mute.get() else 100 + (max(vals) - 18)))
self.after(
_base_vals.ldelay if not _base_vals.in_scale_button_1 else 100,
self.watch_levels_step,

View File

@ -168,13 +168,13 @@ class GainLayer(ttk.LabelFrame):
if not _base_vals.dragging:
if (
self._parent._parent.ldirty
and _base_vals.strip_level_array_size
== len(self._parent._parent.comp_strip)
):
if any(
and any(
self._parent._parent.comp_strip[
self.level_offset : self.level_offset + 1
]
)
and _base_vals.strip_level_array_size
== len(self._parent._parent.comp_strip)
):
vals = (
self.convert_level(
@ -184,7 +184,6 @@ class GainLayer(ttk.LabelFrame):
self._parent._parent.strip_levels[self.level_offset + 1]
),
)
peak = vals[0] if vals[0] > vals[1] else vals[1]
self.level.set(
(
0
@ -192,7 +191,7 @@ class GainLayer(ttk.LabelFrame):
self.index
].mute.get()
or not self.on.get()
else 100 + (peak - 18) + self.gain.get()
else 100 + (max(vals) - 18) + self.gain.get()
)
)
self.after(