Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenkernel/intern/nla.c')
-rw-r--r--source/blender/blenkernel/intern/nla.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c
index f2ce8e4e6f1..dad49646622 100644
--- a/source/blender/blenkernel/intern/nla.c
+++ b/source/blender/blenkernel/intern/nla.c
@@ -46,6 +46,8 @@
#include "DNA_anim_types.h"
#include "DNA_scene_types.h"
+#include "DNA_sound_types.h"
+#include "DNA_speaker_types.h"
#include "BKE_action.h"
#include "BKE_fcurve.h"
@@ -53,6 +55,9 @@
#include "BKE_global.h"
#include "BKE_library.h"
+#ifdef WITH_AUDASPACE
+# include "AUD_C-API.h"
+#endif
#include "RNA_access.h"
#include "nla_private.h"
@@ -337,6 +342,41 @@ NlaStrip *add_nlastrip_to_stack (AnimData *adt, bAction *act)
return strip;
}
+/* Add a NLA Strip referencing the given speaker's sound */
+NlaStrip *add_nla_soundstrip (Scene *scene, Speaker *speaker)
+{
+ NlaStrip *strip = MEM_callocN(sizeof(NlaStrip), "NlaSoundStrip");
+
+ /* if speaker has a sound, set the strip length to the length of the sound,
+ * otherwise default to length of 10 frames
+ */
+#ifdef WITH_AUDASPACE
+ if (speaker->sound)
+ {
+ AUD_SoundInfo info = AUD_getInfo(speaker->sound->playback_handle);
+
+ strip->end = ceil(info.length * FPS);
+ }
+ else
+#endif
+ {
+ strip->end = 10.0f;
+ }
+
+ /* general settings */
+ strip->type = NLASTRIP_TYPE_SOUND;
+
+ strip->flag = NLASTRIP_FLAG_SELECT;
+ strip->extendmode = NLASTRIP_EXTEND_NOTHING; /* nothing to extend... */
+
+ /* strip should be referenced as-is */
+ strip->scale= 1.0f;
+ strip->repeat = 1.0f;
+
+ /* return this strip */
+ return strip;
+}
+
/* *************************************************** */
/* NLA Evaluation <-> Editing Stuff */