[Bf-extensions-cvs] [55b82018] master: Power Sequencer: fix package name and import error
Nathan Lovato
noreply at git.blender.org
Thu May 14 23:14:33 CEST 2020
Commit: 55b820186e64b5362f8c3e808f160cbff49621a3
Author: Nathan Lovato
Date: Thu May 14 15:11:08 2020 -0600
Branches: master
https://developer.blender.org/rBA55b820186e64b5362f8c3e808f160cbff49621a3
Power Sequencer: fix package name and import error
Fixes an error with not passing the python tests.
===================================================================
M power_sequencer/operators/__init__.py
D power_sequencer/operators/align_audios.py
D power_sequencer/operators/audiosync/__init__.py
D power_sequencer/operators/audiosync/convert_and_trim.py
D power_sequencer/operators/audiosync/cross_correlation.py
D power_sequencer/operators/audiosync/ensure_non_zero.py
D power_sequencer/operators/audiosync/find_offset.py
D power_sequencer/operators/audiosync/mfcc/__init__.py
D power_sequencer/operators/audiosync/mfcc/mfcc.py
D power_sequencer/operators/audiosync/mfcc/segment_axis.py
D power_sequencer/operators/audiosync/mfcc/trfbank.py
D power_sequencer/operators/audiosync/std_mfcc.py
===================================================================
diff --git a/power_sequencer/operators/__init__.py b/power_sequencer/operators/__init__.py
index 3ab79520..a362b599 100755
--- a/power_sequencer/operators/__init__.py
+++ b/power_sequencer/operators/__init__.py
@@ -22,14 +22,18 @@ def get_operator_classes():
"""Returns the list of operators in the add-on"""
this_file = os.path.dirname(__file__)
module_files = [
- f for f in os.listdir(this_file) if f.endswith(".py") and not f.startswith("__init__")
+ f
+ for f in os.listdir(this_file)
+ if f.endswith(".py") and not f.startswith("__init__")
]
module_paths = ["." + os.path.splitext(f)[0] for f in module_files]
classes = []
print(__name__)
for path in module_paths:
- module = importlib.import_module(path, package="blender_power_sequencer.operators")
- operator_names = [entry for entry in dir(module) if entry.startswith("POWER_SEQUENCER_OT")]
+ module = importlib.import_module(path, package="power_sequencer.operators")
+ operator_names = [
+ entry for entry in dir(module) if entry.startswith("POWER_SEQUENCER_OT")
+ ]
classes.extend([getattr(module, name) for name in operator_names])
return classes
@@ -38,7 +42,9 @@ doc = {
"sequencer.refresh_all": {
"name": "Refresh All",
"description": "",
- "shortcuts": [({"type": "R", "value": "PRESS", "shift": True}, {}, "Refresh All")],
+ "shortcuts": [
+ ({"type": "R", "value": "PRESS", "shift": True}, {}, "Refresh All")
+ ],
"demo": "",
"keymap": "Sequencer",
}
diff --git a/power_sequencer/operators/align_audios.py b/power_sequencer/operators/align_audios.py
deleted file mode 100644
index 0bd99aba..00000000
--- a/power_sequencer/operators/align_audios.py
+++ /dev/null
@@ -1,110 +0,0 @@
-#
-# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-#
-# This file is part of Power Sequencer.
-#
-# Power Sequencer is free software: you can redistribute it and/or modify it under the terms of the
-# GNU General Public License as published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# Power Sequencer is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
-# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# 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
-import subprocess
-
-from .utils.doc import doc_name, doc_idname, doc_brief, doc_description
-
-
-class POWER_SEQUENCER_OT_align_audios(bpy.types.Operator):
- """*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.
-
- 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.
-
- 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 = {
- "name": doc_name(__qualname__),
- "demo": "https://i.imgur.com/xkBUzDj.gif",
- "description": doc_description(__doc__),
- "shortcuts": [],
- "keymap": "Sequencer",
- }
- bl_idname = doc_idname(__qualname__)
- bl_label = doc["name"]
- bl_description = doc_brief(doc["description"])
- bl_options = {"REGISTER", "UNDO"}
-
- @classmethod
- def poll(cls, context):
- 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:
- import scipy
- except ImportError:
- self.report({"ERROR"}, "Scipy must be installed to align audios")
- return {"FINISHED"}
-
- if not is_ffmpeg_available():
- self.report({"ERROR"}, "ffmpeg must be installed to align audios")
- return {"FINISHED"}
-
- # This import is here because otherwise, it slows down blender startup
- from .audiosync import find_offset
-
- scene = context.scene
-
- active = scene.sequence_editor.active_strip
- active_filepath = bpy.path.abspath(active.sound.filepath)
-
- selected = context.selected_sequences
- selected.pop(selected.index(active))
-
- align_strip = selected[0]
- align_strip_filepath = bpy.path.abspath(align_strip.sound.filepath)
-
- offset, score = find_offset(align_strip_filepath, active_filepath)
-
- initial_offset = active.frame_start - align_strip.frame_start
-
- fps = scene.render.fps / scene.render.fps_base
- frames = int(offset * fps)
-
- align_strip.frame_start -= frames - initial_offset
-
- self.report({"INFO"}, "Alignment score: " + str(round(score, 1)))
-
- return {"FINISHED"}
-
-
-def is_ffmpeg_available():
- """
- Returns true if ffmpeg is installed and available from the PATH
- """
- try:
- subprocess.call(["ffmpeg", "--help"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- return True
- except OSError:
- return False
diff --git a/power_sequencer/operators/audiosync/__init__.py b/power_sequencer/operators/audiosync/__init__.py
deleted file mode 100644
index 74dd6f5a..00000000
--- a/power_sequencer/operators/audiosync/__init__.py
+++ /dev/null
@@ -1,17 +0,0 @@
-#
-# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-#
-# This file is part of Power Sequencer.
-#
-# Power Sequencer is free software: you can redistribute it and/or modify it under the terms of the
-# GNU General Public License as published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# Power Sequencer is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
-# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along with Power Sequencer. If
-# not, see <https://www.gnu.org/licenses/>.
-#
-from .find_offset import find_offset
diff --git a/power_sequencer/operators/audiosync/convert_and_trim.py b/power_sequencer/operators/audiosync/convert_and_trim.py
deleted file mode 100644
index fddf702d..00000000
--- a/power_sequencer/operators/audiosync/convert_and_trim.py
+++ /dev/null
@@ -1,60 +0,0 @@
-#
-# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-#
-# This file is part of Power Sequencer.
-#
-# Power Sequencer is free software: you can redistribute it and/or modify it under the terms of the
-# GNU General Public License as published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# Power Sequencer is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
-# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# 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 subprocess
-import tempfile
-
-
-def convert_and_trim(audio_filepath, freq, dur):
- """
- Uses ffmpeg to convert an audio file to a temporary wav file for use
- in finding offset.
-
- Args
- :audio: path to the audiofile to convert (string)
- :freq: Samples / second in the output wav (int)
- :dur: Max duration of the output wav in seconds (float)
-
- Returns
- :outpath: path to the output wav file
- """
-
- tmp = tempfile.NamedTemporaryFile(mode="r+b", prefix="offset_", suffix=".wav")
- outpath = tmp.name
- tmp.close()
-
- channel_count = "1"
-
- subprocess.call(
- [
- "ffmpeg",
- "-loglevel",
- "panic",
- "-i",
- audio_filepath,
- "-ac",
- channel_count,
- "-ar",
- str(freq),
- "-t",
- str(dur),
- "-acodec",
- "pcm_s16le",
- outpath,
- ]
- )
-
- return outpath
diff --git a/power_sequencer/operators/audiosync/cross_correlation.py b/power_sequencer/operators/audiosync/cross_correlation.py
deleted file mode 100644
index dc337475..00000000
--- a/power_sequencer/operators/audiosync/cross_correlation.py
+++ /dev/null
@@ -1,33 +0,0 @@
-#
-# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-#
-# This file is part of Power Sequencer.
-#
-# Power Sequencer is free software: you can redistribute it and/or modify it under the terms of the
-# GNU General Public License as published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# Power Sequencer is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
-# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# 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 numpy as np
-
-
-def cross_correlation(mfcc1, mfcc2, nframes):
- n1, mdim1 = mfcc1.shape
- # n2, mdim2 = mfcc2.shape
-
- n = n1 - nframes + 1
-
- if n < 0:
- return None
-
- c = np.zeros(n)
- for k in rang
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list