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

View File

@ -168,33 +168,32 @@ class GainLayer(ttk.LabelFrame):
if not _base_vals.dragging: if not _base_vals.dragging:
if ( if (
self._parent._parent.ldirty self._parent._parent.ldirty
and _base_vals.strip_level_array_size and any(
== len(self._parent._parent.comp_strip)
):
if any(
self._parent._parent.comp_strip[ self._parent._parent.comp_strip[
self.level_offset : self.level_offset + 1 self.level_offset : self.level_offset + 1
] ]
): )
vals = ( and _base_vals.strip_level_array_size
self.convert_level( == len(self._parent._parent.comp_strip)
self._parent._parent.strip_levels[self.level_offset] ):
), vals = (
self.convert_level( self.convert_level(
self._parent._parent.strip_levels[self.level_offset + 1] self._parent._parent.strip_levels[self.level_offset]
), ),
) self.convert_level(
peak = vals[0] if vals[0] > vals[1] else vals[1] self._parent._parent.strip_levels[self.level_offset + 1]
self.level.set( ),
( )
0 self.level.set(
if self._parent._parent.channel_frame.strips[ (
self.index 0
].mute.get() if self._parent._parent.channel_frame.strips[
or not self.on.get() self.index
else 100 + (peak - 18) + self.gain.get() ].mute.get()
) or not self.on.get()
else 100 + (max(vals) - 18) + self.gain.get()
) )
)
self.after( self.after(
_base_vals.ldelay if not _base_vals.in_scale_button_1 else 100, _base_vals.ldelay if not _base_vals.in_scale_button_1 else 100,
self.watch_levels_step, self.watch_levels_step,