From ab25c69b597201c1c4909e017943a7c79d62eae9 Mon Sep 17 00:00:00 2001 From: Jamie Hardt Date: Wed, 5 Nov 2025 20:58:58 -0800 Subject: [PATCH] Removing some dead code --- intern/soundbank.py | 48 ---------------------------------- operator_wav_import.py | 58 ------------------------------------------ 2 files changed, 106 deletions(-) delete mode 100644 intern/soundbank.py delete mode 100644 operator_wav_import.py diff --git a/intern/soundbank.py b/intern/soundbank.py deleted file mode 100644 index 9e65b9f..0000000 --- a/intern/soundbank.py +++ /dev/null @@ -1,48 +0,0 @@ -import bpy - -import numpy - -from typing import List -from random import choice -from aud import Sound - -class SoundBank: - def __init__(self, prefix): - self.prefix = prefix - self.cached_info = {} - - def sounds(self) -> List[Sound]: - return [sound for sound in bpy.data.sounds if sound.name.startswith(self.prefix)] - - def random_sound(self) -> Sound: - if len(self.sounds()) == 0: - return None - else: - return choice(self.sounds()) - - def get_audiofile_info(self, sound, fps) -> (int, int): - """ - Returns frame of max_peak and duration in frames - """ - - if sound.filepath in self.cached_info.keys(): - return self.cached_info[sound.filepath] - else: - if sound.filepath.startswith("//"): - path = bpy.path.abspath(sound.filepath) - else: - path = sound.filepath - - aud_sound = Sound(path) - samples = aud_sound.data() - sample_rate = aud_sound.specs[0] - index = numpy.where(samples == numpy.amax(samples))[0][0] - max_peak_frame = (index * fps / sample_rate) - - sample_count = aud_sound.length - frame_length = sample_count * fps / sample_rate - - retvalue = (max_peak_frame , frame_length) - self.cached_info[sound.filepath] = retvalue - - return retvalue \ No newline at end of file diff --git a/operator_wav_import.py b/operator_wav_import.py deleted file mode 100644 index b514257..0000000 --- a/operator_wav_import.py +++ /dev/null @@ -1,58 +0,0 @@ -import bpy -import os - -def import_wav_files(filepath, pack, dir, fake): - - def import_one(fp): - sound = bpy.data.sounds.load(fp, check_existing=False) - if pack: - sound.pack() - - if fake: - sound.use_fake_user = True - - if dir: - the_dir = os.path.dirname(filepath) - for child in os.listdir(the_dir): - if child.endswith(".wav"): - import_one(os.path.join(the_dir, child)) - - else: - import_one(filepath) - - return {'FINISHED'} - - -from bpy_extras.io_utils import ImportHelper -from bpy.props import StringProperty, BoolProperty, EnumProperty -from bpy.types import Operator - - -class ImportWav(Operator, ImportHelper): - """Import WAV audio files""" - bl_idname = "import_test.wav_file_batch" - bl_label = "Import WAV Files" - - filename_ext = ".wav" - - filter_glob: StringProperty( - default="*.wav", - options={'HIDDEN'}, - maxlen=255, # Max internal buffer length, longer would be clamped. - ) - - fake: BoolProperty( - name="Add Fake User", - description="Add the Fake User to each of the sound files", - default=True, - ) - - all_in_directory: BoolProperty( - name="All Files in Folder", - description="Import every WAV file found in the folder as the selected file", - default=False, - ) - - def execute(self, _): - return import_wav_files(filepath=self.filepath, pack=False, dir=self.all_in_directory, fake=self.fake) -