Handle no sounds found

This commit is contained in:
Jamie Hardt
2020-09-19 22:57:25 -07:00
parent 17bc2744ce
commit 723b20a5b6
2 changed files with 11 additions and 8 deletions

View File

@@ -166,13 +166,13 @@ def add_speakers_to_meshes(meshes, context, sound=None,
if sound is not None:
speaker_obj.data.sound = sound
sync_audio(speaker_obj, sound, context,
sync_peak=sync_peak,
trigger_mode=trigger_mode,
gaussian_stddev=gaussian_stddev,
sound_bank=sound_bank, envelope=envelope)
apply_gain_envelope(speaker_obj, envelope)
sync_audio(speaker_obj, sound, context,
sync_peak=sync_peak,
trigger_mode=trigger_mode,
gaussian_stddev=gaussian_stddev,
sound_bank=sound_bank, envelope=envelope)
apply_gain_envelope(speaker_obj, envelope)
speaker_obj.data.update_tag()

View File

@@ -16,7 +16,10 @@ class SoundBank:
return [sound for sound in bpy.data.sounds if sound.name.startswith(self.prefix)]
def random_sound(self) -> Sound:
return choice(self.sounds())
if len(self.sounds()) == 0:
return None
else:
return choice(self.sounds())
def get_audiofile_info(self, sound, fps) -> (int, int):
"""