[Bf-extensions-cvs] [c402143c] temp-power-sequencer: Improve operators poll performances

Nathan Lovato noreply at git.blender.org
Thu Sep 5 13:52:34 CEST 2019


Commit: c402143c7e5c5f525996e71408e5192d657bc56b
Author: Nathan Lovato
Date:   Thu Sep 5 13:52:28 2019 +0200
Branches: temp-power-sequencer
https://developer.blender.org/rBACc402143c7e5c5f525996e71408e5192d657bc56b

Improve operators poll performances

===================================================================

M	power_sequencer/operators/__init__.py
M	power_sequencer/operators/align_audios.py
M	power_sequencer/operators/concatenate_strips.py
M	power_sequencer/operators/crossfade_edit.py
M	power_sequencer/operators/cut_strips_under_cursor.py
M	power_sequencer/operators/delete_direct.py
M	power_sequencer/operators/deselect_all_left_or_right.py
M	power_sequencer/operators/fade_clear.py
M	power_sequencer/operators/gap_remove.py
M	power_sequencer/operators/grab.py
M	power_sequencer/operators/grab_closest_handle_or_cut.py
M	power_sequencer/operators/grab_sequence_handles.py
M	power_sequencer/operators/jump_time_offset.py
M	power_sequencer/operators/jump_to_cut.py
M	power_sequencer/operators/marker_delete_closest.py
M	power_sequencer/operators/marker_delete_direct.py
M	power_sequencer/operators/markers_create_from_selected.py
M	power_sequencer/operators/markers_snap_matching_strips.py
M	power_sequencer/operators/meta_resize_to_content.py
M	power_sequencer/operators/meta_trim_content_to_bounds.py
M	power_sequencer/operators/meta_ungroup_and_trim.py
M	power_sequencer/operators/mouse_toggle_mute.py
M	power_sequencer/operators/open_project_directory.py
M	power_sequencer/operators/playback_speed_decrease.py
M	power_sequencer/operators/playback_speed_increase.py
M	power_sequencer/operators/preview_closest_cut.py
M	power_sequencer/operators/preview_to_selection.py
M	power_sequencer/operators/scene_create_from_selection.py
M	power_sequencer/operators/scene_cycle.py
M	power_sequencer/operators/scene_merge_from.py
M	power_sequencer/operators/scene_open_from_strip.py
M	power_sequencer/operators/scene_rename_with_strip.py
M	power_sequencer/operators/select_all_left_or_right.py
M	power_sequencer/operators/select_closest_to_mouse.py
M	power_sequencer/operators/select_linked_strips.py
M	power_sequencer/operators/select_related_strips.py
M	power_sequencer/operators/select_strips_under_cursor.py
M	power_sequencer/operators/space_sequences.py
M	power_sequencer/operators/swap_strips.py
M	power_sequencer/operators/transitions_remove.py
M	power_sequencer/operators/trim_left_or_right_handles.py
M	power_sequencer/operators/trim_to_surrounding_cuts.py
M	power_sequencer/ui/menu_toolbar.py

===================================================================

diff --git a/power_sequencer/operators/__init__.py b/power_sequencer/operators/__init__.py
index e1de647d..7c1e0ca0 100644
--- a/power_sequencer/operators/__init__.py
+++ b/power_sequencer/operators/__init__.py
@@ -15,7 +15,6 @@
 # not, see <https://www.gnu.org/licenses/>.
 #
 from .speed_up_movie_strip import POWER_SEQUENCER_OT_speed_up_movie_strip
-from .add_transform import POWER_SEQUENCER_OT_add_transform
 from .align_audios import POWER_SEQUENCER_OT_align_audios
 from .playback_speed_set import POWER_SEQUENCER_OT_playback_speed_set
 from .channel_offset import POWER_SEQUENCER_OT_channel_offset
@@ -86,7 +85,6 @@ from .trim_to_surrounding_cuts import POWER_SEQUENCER_OT_trim_to_surrounding_cut
 
 classes = [
     POWER_SEQUENCER_OT_speed_up_movie_strip,
-    POWER_SEQUENCER_OT_add_transform,
     POWER_SEQUENCER_OT_align_audios,
     POWER_SEQUENCER_OT_playback_speed_set,
     POWER_SEQUENCER_OT_channel_offset,
diff --git a/power_sequencer/operators/align_audios.py b/power_sequencer/operators/align_audios.py
index 485783fb..a280f1fd 100644
--- a/power_sequencer/operators/align_audios.py
+++ b/power_sequencer/operators/align_audios.py
@@ -20,19 +20,17 @@ from .utils.doc import doc_name, doc_idname, doc_brief, doc_description
 
 
 class POWER_SEQUENCER_OT_align_audios(bpy.types.Operator):
-    """
-    *brief* Align two similar audios
+    """*brief* Align two audio strips
+
 
+    Tries to synchronize the selected audio strip to the active audio strip by comparing the sound.
+    Useful to synchronize audio of the same event recorded with different microphones.
 
-    Attempt alignment between the selected audio strip to the active
-    audio strip. The better the correlation, the better the result.
+    To use this feature, you must have [ffmpeg](https://www.ffmpeg.org/download.html) and
+    [scipy](https://www.scipy.org/install.html) installed on your computer and available on the PATH (command line) to work.
 
-    This operator requires
-    [ffmpeg](https://www.ffmpeg.org/download.html) and
-    [scipy](https://www.scipy.org/install.html) to work. Audio must be
-    converted to WAV data prior to analyzing, so longer strips may take
-    longer to align. To mitigate this issue, analysis will be limited to
-    the first 15 minutes of audio at most.
+    The longer the audio files, the longer the tool can take to run, as it has to convert, analyze,
+    and compare the audio sources to work.
     """
 
     doc = {
@@ -49,16 +47,17 @@ class POWER_SEQUENCER_OT_align_audios(bpy.types.Operator):
 
     @classmethod
     def poll(cls, context):
-        scene = context.scene
-        if scene.sequence_editor and scene.sequence_editor.active_strip:
-            active = scene.sequence_editor.active_strip
-            selected = context.selected_sequences
-
-            if len(selected) == 2 and active in selected:
-                selected.pop(selected.index(active))
-                if selected[0].type == "SOUND" and active.type == "SOUND":
-                    return context.selected_sequences
-        return False
+        if not context.scene:
+            return False
+
+        active = context.scene.sequence_editor.active_strip
+        selected = context.selected_sequences
+        ok = (
+            len(selected) == 2
+            and active in selected
+            and all(map(lambda s: s.type == "SOUND", selected))
+        )
+        return ok
 
     def execute(self, context):
         try:
@@ -71,7 +70,7 @@ class POWER_SEQUENCER_OT_align_audios(bpy.types.Operator):
             self.report({"ERROR"}, "ffmpeg must be installed to align audios")
             return {"FINISHED"}
 
-        # This import is here because it slows blender startup a little
+        # This import is here because otherwise, it slows down blender startup
         from .audiosync import find_offset
 
         scene = context.scene
diff --git a/power_sequencer/operators/concatenate_strips.py b/power_sequencer/operators/concatenate_strips.py
index c0a8c71e..29d11384 100644
--- a/power_sequencer/operators/concatenate_strips.py
+++ b/power_sequencer/operators/concatenate_strips.py
@@ -18,8 +18,7 @@ import bpy
 from operator import attrgetter
 
 from .utils.global_settings import SequenceTypes
-from .utils.functions import find_sequences_after
-from .utils.functions import get_mouse_frame_and_channel
+from .utils.functions import find_sequences_after, get_mouse_frame_and_channel, sequencer_workaround_2_80_audio_bug
 from .utils.doc import doc_name, doc_idname, doc_brief, doc_description
 
 
@@ -85,7 +84,7 @@ class POWER_SEQUENCER_OT_concatenate_strips(bpy.types.Operator):
 
     @classmethod
     def poll(cls, context):
-        return context.sequences
+        return context.sequences and context.selected_sequences
 
     def invoke(self, context, event):
         if not context.selected_sequences:
@@ -123,6 +122,8 @@ class POWER_SEQUENCER_OT_concatenate_strips(bpy.types.Operator):
                 )
                 to_concatenate.remove(strip_target)
                 self.concatenate(strip_target, to_concatenate, force_all=True)
+
+        sequencer_workaround_2_80_audio_bug(context)
         return {"FINISHED"}
 
     def concatenate(self, strip_target, sequences, force_all=False):
diff --git a/power_sequencer/operators/crossfade_edit.py b/power_sequencer/operators/crossfade_edit.py
index 37dda951..127ab603 100644
--- a/power_sequencer/operators/crossfade_edit.py
+++ b/power_sequencer/operators/crossfade_edit.py
@@ -46,11 +46,8 @@ class POWER_SEQUENCER_OT_crossfade_edit(bpy.types.Operator):
 
     @classmethod
     def poll(cls, context):
-        return (
-            context.scene.sequence_editor
-            and context.scene.sequence_editor.active_strip
-            and len(context.selected_sequences) > 0
-        )
+        return context.scene.sequence_editor.active_strip and context.selected_sequences
+
 
     def execute(self, context):
         active = context.scene.sequence_editor.active_strip
diff --git a/power_sequencer/operators/cut_strips_under_cursor.py b/power_sequencer/operators/cut_strips_under_cursor.py
index 0fd8a9ae..de1fff3e 100644
--- a/power_sequencer/operators/cut_strips_under_cursor.py
+++ b/power_sequencer/operators/cut_strips_under_cursor.py
@@ -14,52 +14,52 @@
 # You should have received a copy of the GNU General Public License along with Power Sequencer. If
 # not, see <https://www.gnu.org/licenses/>.
 #
-import bpy
-
-from .utils.doc import doc_name, doc_idname, doc_brief, doc_description
-from .utils.functions import get_mouse_frame_and_channel
-
-
-class POWER_SEQUENCER_OT_split_strips_under_cursor(bpy.types.Operator):
-    """
-    Splits all strips under cursor including muted strips, but excluding locked strips.
-    Auto selects sequences under the time cursor when you don't have a selection.
-    """
-
-    doc = {
-        "name": doc_name(__qualname__),
-        "demo": "https://i.imgur.com/ZyEd0jD.gif",
-        "description": doc_description(__doc__),
-        "shortcuts": [({"type": "K", "value": "PRESS"}, {}, "Cut All Strips Under Cursor")],
-        "keymap": "Sequencer",
-    }
-    bl_idname = doc_idname(__qualname__)
-    bl_label = doc["name"]
-    bl_description = doc_brief(doc["description"])
-    bl_options = {"REGISTER", "UNDO"}
-
-    side: bpy.props.EnumProperty(
-        items=[("LEFT", "", ""), ("RIGHT", "", "")], name="Side", default="LEFT", options={"HIDDEN"}
-    )
-
-    @classmethod
-    def poll(cls, context):
-        return len(context.sequences) > 0
-
-    def invoke(self, context, event):
-        frame, channel = get_mouse_frame_and_channel(context, event)
-        self.side = "LEFT" if frame < context.scene.frame_current else "RIGHT"
-        return self.execute(context)
-
-    def execute(self, context):
-        # Deselect to trigger a call to select_strips_under_cursor below if the
-        # time cursor doesn't overlap any of the selected strip: if so, it
-        # can't cut anything!
-        deselect = True
-        for s in bpy.context.selected_sequences:
-            if s.frame_final_start <= context.scene.frame_current <= s.frame_final_end:
-                deselect = False
-        if deselect:
-            bpy.ops.sequencer.select_all(action="DESELECT")
-        (context.selected_sequences or bpy.ops.power_sequencer.select_strips_under_cursor())
-        return bpy.ops.sequencer.cut(frame=context.scene.frame_current, side=self.side)
+import bpy
+
+from .utils.doc import doc_name, doc_idname, doc_brief, doc_description
+from .utils.functions import get_mouse_frame_and_channel
+
+
+class POWER_SEQUENCER_OT_split_strips_under_cursor(bpy.types.Operator):
+    """
+    Splits all strips under cursor including muted strips, but excluding locked strips.
+    Auto selects sequences under the time cursor when you don't have a selection.
+    """
+
+    doc = {
+        "name": doc_name(__qualname__),
+        "demo": "https://i.imgur.com/ZyEd0jD.gif",
+        "description": doc_description(__doc__),
+        "shortcuts": [({"type": "K", "value": "PRESS"}, {}, "Cut All Strips Under Cursor")],
+        "keymap": "Sequencer",
+    }
+    bl_idname = doc_idname(__qualname__)
+    bl_label = doc["name"]
+    bl_description = doc_brief(doc["description"])
+    bl_options = {"REGISTER", "UNDO"}
+
+    side: bpy.props.EnumProperty(
+        items=[("LEFT", "", ""), ("RIGHT", "", "")], name="Side", default="LEFT", options={"HIDDEN"}
+    )
+
+    @classmethod
+    def poll(cls, context):
+        return context.sequences
+
+    def invoke(self, context, event):
+        frame, channel = get_mouse_frame_and_channel(context, event)
+        self.side = "LEFT" if frame < context.scene.frame_current else "RIGHT"
+        return self.execute(context)
+
+    def execute(self, context):
+        # Deselect to trigger a call to select_strips_under_cursor below if the
+        # time cursor doesn't overlap any of the selected strip: if so, it
+        # can't cut anything!
+        deselect = True
+        for s in bpy.context.selected_sequences:
+            if s.frame_final_start <= context.scene.frame_current <= s.frame_final_end:
+                deselect = False
+        if deselect:
+           

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list