From 8f3672029ae08f91b69c5ec5adf38aff8fb389c8 Mon Sep 17 00:00:00 2001 From: onyx-and-iris <75868496+onyx-and-iris@users.noreply.github.com> Date: Thu, 14 Apr 2022 18:05:17 +0100 Subject: [PATCH] refactor watch levels, now using max() refactor watch levels. now using max() to fetch peak --- vmcompact/channels.py | 64 +++++++++++++++++++++--------------------- vmcompact/gainlayer.py | 45 +++++++++++++++-------------- 2 files changed, 54 insertions(+), 55 deletions(-) diff --git a/vmcompact/channels.py b/vmcompact/channels.py index 4d6aade..1be6cbb 100644 --- a/vmcompact/channels.py +++ b/vmcompact/channels.py @@ -213,26 +213,25 @@ 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 ] - ): - 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.mute.get() else 100 + (peak - 18) + self.gain.get()) - ) + ) + and _base_vals.strip_level_array_size + == len(self._parent._parent.comp_strip) + ): + vals = ( + self.convert_level( + self._parent._parent.strip_levels[self.level_offset] + ), + self.convert_level( + self._parent._parent.strip_levels[self.level_offset + 1] + ), + ) + self.level.set( + (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, self.watch_levels_step, @@ -279,24 +278,25 @@ 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 ] - ): - vals = ( - self.convert_level( - 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] - self.level.set((0 if self.mute.get() else 100 + (peak - 18))) + ) + and _base_vals.bus_level_array_size + == len(self._parent._parent.comp_bus) + ): + vals = ( + self.convert_level( + self._parent._parent.bus_levels[self.level_offset] + ), + self.convert_level( + self._parent._parent.bus_levels[self.level_offset + 1] + ), + ) + 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, diff --git a/vmcompact/gainlayer.py b/vmcompact/gainlayer.py index 6e8a442..606517c 100644 --- a/vmcompact/gainlayer.py +++ b/vmcompact/gainlayer.py @@ -168,33 +168,32 @@ 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 ] - ): - 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() - ) + ) + and _base_vals.strip_level_array_size + == len(self._parent._parent.comp_strip) + ): + vals = ( + self.convert_level( + self._parent._parent.strip_levels[self.level_offset] + ), + self.convert_level( + self._parent._parent.strip_levels[self.level_offset + 1] + ), + ) + self.level.set( + ( + 0 + if self._parent._parent.channel_frame.strips[ + self.index + ].mute.get() + or not self.on.get() + else 100 + (max(vals) - 18) + self.gain.get() ) + ) self.after( _base_vals.ldelay if not _base_vals.in_scale_button_1 else 100, self.watch_levels_step,