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:
authorJoerg Mueller <nexyon@gmail.com>2011-07-26 17:56:31 +0400
committerJoerg Mueller <nexyon@gmail.com>2011-07-26 17:56:31 +0400
commit9077b8bffc6731062bbd6997379b4bf6badd13e2 (patch)
tree641b4fdb97c201727107c398517233ca313d1f38 /source/blender
parentc0373fb7ea2b6d36b57a7c43706626aa254c70b3 (diff)
3D Audio GSoC:
Main: Complete rewrite of the sequencer related audio code to support 3D Audio objects later and especially adressing the animation system problems (see mailing list if interested). Note: Animation is not working yet, so with this commit volume animation doesn't work anymore, that's the next step. Minor things: * Changed AUD_Reference behaviour a little to be more usage safe. * Fixed bug in AUD_I3DHandle: Missing virtual destructor * Fixed enmus in AUD_Space.h * Fixed a warning in rna_scene.c * Removed an unneeded call in rna_sound.c
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/BKE_sequencer.h4
-rw-r--r--source/blender/blenkernel/BKE_sound.h8
-rw-r--r--source/blender/blenkernel/intern/sequencer.c27
-rw-r--r--source/blender/blenkernel/intern/sound.c57
-rw-r--r--source/blender/blenloader/intern/readfile.c2
-rw-r--r--source/blender/makesrna/intern/rna_scene.c25
-rw-r--r--source/blender/makesrna/intern/rna_sequencer.c4
-rw-r--r--source/blender/makesrna/intern/rna_sound.c9
8 files changed, 95 insertions, 41 deletions
diff --git a/source/blender/blenkernel/BKE_sequencer.h b/source/blender/blenkernel/BKE_sequencer.h
index bedd58876bc..cebf99097aa 100644
--- a/source/blender/blenkernel/BKE_sequencer.h
+++ b/source/blender/blenkernel/BKE_sequencer.h
@@ -43,6 +43,7 @@ struct Scene;
struct Sequence;
struct Strip;
struct StripElem;
+struct bSound;
#define MAXSEQ 32
@@ -281,8 +282,9 @@ void free_imbuf_seq(struct Scene *scene, struct ListBase * seqbasep, int check_m
struct Sequence *seq_dupli_recursive(struct Scene *scene, struct Scene *scene_to, struct Sequence * seq, int dupe_flag);
int seq_swap(struct Sequence *seq_a, struct Sequence *seq_b, const char **error_str);
-void seq_update_sound(struct Scene* scene, struct Sequence *seq);
+void seq_update_sound_bounds(struct Scene* scene, struct Sequence *seq);
void seq_update_muting(struct Scene* scene, struct Editing *ed);
+void seq_update_sound(struct Scene *scene, struct bSound *sound);
void seqbase_sound_reload(struct Scene *scene, ListBase *seqbase);
void seqbase_unique_name_recursive(ListBase *seqbasep, struct Sequence *seq);
void seqbase_dupli_recursive(struct Scene *scene, struct Scene *scene_to, ListBase *nseqbase, ListBase *seqbase, int dupe_flag);
diff --git a/source/blender/blenkernel/BKE_sound.h b/source/blender/blenkernel/BKE_sound.h
index 7402d501120..549dc475320 100644
--- a/source/blender/blenkernel/BKE_sound.h
+++ b/source/blender/blenkernel/BKE_sound.h
@@ -64,6 +64,8 @@ void sound_delete(struct bContext *C, struct bSound* sound);
void sound_cache(struct bSound* sound, int ignore);
+void sound_cache_notifying(struct Main* main, struct bSound* sound, int ignore);
+
void sound_delete_cache(struct bSound* sound);
void sound_load(struct Main *main, struct bSound* sound);
@@ -80,6 +82,8 @@ void sound_destroy_scene(struct Scene *scene);
void sound_mute_scene(struct Scene *scene, int muted);
+void sound_update_fps(struct Scene *scene);
+
void* sound_scene_add_scene_sound(struct Scene *scene, struct Sequence* sequence, int startframe, int endframe, int frameskip);
void* sound_add_scene_sound(struct Scene *scene, struct Sequence* sequence, int startframe, int endframe, int frameskip);
@@ -90,6 +94,10 @@ void sound_mute_scene_sound(struct Scene *scene, void* handle, char mute);
void sound_move_scene_sound(struct Scene *scene, void* handle, int startframe, int endframe, int frameskip);
+void sound_update_scene_sound(void* handle, struct bSound* sound);
+
+void sound_update_sequencer(struct Main* main, struct bSound* sound);
+
void sound_play_scene(struct Scene *scene);
void sound_stop_scene(struct Scene *scene);
diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c
index 9673fee0b63..e4dc3a31cb1 100644
--- a/source/blender/blenkernel/intern/sequencer.c
+++ b/source/blender/blenkernel/intern/sequencer.c
@@ -533,7 +533,7 @@ void calc_sequence_disp(Scene *scene, Sequence *seq)
seq->handsize= (float)((seq->enddisp-seq->startdisp)/25);
}
- seq_update_sound(scene, seq);
+ seq_update_sound_bounds(scene, seq);
}
static void seq_update_sound_bounds_recursive(Scene *scene, Sequence *metaseq)
@@ -3145,7 +3145,7 @@ int shuffle_seq_time(ListBase * seqbasep, Scene *evil_scene)
return offset? 0:1;
}
-void seq_update_sound(Scene* scene, Sequence *seq)
+void seq_update_sound_bounds(Scene* scene, Sequence *seq)
{
if(seq->scene_sound)
{
@@ -3193,6 +3193,29 @@ void seq_update_muting(Scene *scene, Editing *ed)
}
}
+static void seq_update_sound_recursive(Scene *scene, ListBase *seqbasep, bSound *sound)
+{
+ Sequence *seq;
+
+ for(seq=seqbasep->first; seq; seq=seq->next) {
+ if(seq->type == SEQ_META) {
+ seq_update_sound_recursive(scene, &seq->seqbase, sound);
+ }
+ else if(seq->type == SEQ_SOUND) {
+ if(seq->scene_sound && sound == seq->sound) {
+ sound_update_scene_sound(seq->scene_sound, sound);
+ }
+ }
+ }
+}
+
+void seq_update_sound(struct Scene *scene, struct bSound *sound)
+{
+ if(scene->ed) {
+ seq_update_sound_recursive(scene, &scene->ed->seqbase, sound);
+ }
+}
+
/* in cases where we done know the sequence's listbase */
ListBase *seq_seqbase(ListBase *seqbase, Sequence *seq)
{
diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c
index 493dfa09a65..64ba9ed362a 100644
--- a/source/blender/blenkernel/intern/sound.c
+++ b/source/blender/blenkernel/intern/sound.c
@@ -34,6 +34,7 @@
#include "BKE_packedFile.h"
#include "BKE_fcurve.h"
#include "BKE_animsys.h"
+#include "BKE_sequencer.h"
struct bSound* sound_new_file(struct Main *bmain, const char *filename)
@@ -257,6 +258,12 @@ void sound_cache(struct bSound* sound, int ignore)
sound->playback_handle = sound->cache;
}
+void sound_cache_notifying(struct Main* main, struct bSound* sound, int ignore)
+{
+ sound_cache(sound, ignore);
+ sound_update_sequencer(main, sound);
+}
+
void sound_delete_cache(struct bSound* sound)
{
if(sound->cache)
@@ -326,24 +333,9 @@ void sound_load(struct Main *bmain, struct bSound* sound)
sound->playback_handle = sound->cache;
else
sound->playback_handle = sound->handle;
- }
-}
-static float sound_get_volume(Scene* scene, Sequence* sequence, float time)
-{
- AnimData *adt= BKE_animdata_from_id(&scene->id);
- FCurve *fcu = NULL;
- char buf[64];
-
- /* NOTE: this manually constructed path needs to be used here to avoid problems with RNA crashes */
- sprintf(buf, "sequence_editor.sequences_all[\"%s\"].volume", sequence->name+2);
- if (adt && adt->action && adt->action->curves.first)
- fcu= list_find_fcurve(&adt->action->curves, buf, 0);
-
- if(fcu)
- return evaluate_fcurve(fcu, time * (float)FPS);
- else
- return sequence->volume;
+ sound_update_sequencer(bmain, sound);
+ }
}
AUD_Device* sound_mixdown(struct Scene *scene, AUD_DeviceSpecs specs, int start, float volume)
@@ -360,7 +352,7 @@ AUD_Device* sound_mixdown(struct Scene *scene, AUD_DeviceSpecs specs, int start,
void sound_create_scene(struct Scene *scene)
{
- scene->sound_scene = AUD_createSequencer(scene->audio.flag & AUDIO_MUTE, scene, (AUD_volumeFunction)&sound_get_volume);
+ scene->sound_scene = AUD_createSequencer(FPS, scene->audio.flag & AUDIO_MUTE);
scene->sound_scene_handle = NULL;
scene->sound_scrub_handle = NULL;
}
@@ -381,31 +373,50 @@ void sound_mute_scene(struct Scene *scene, int muted)
AUD_setSequencerMuted(scene->sound_scene, muted);
}
+void sound_update_fps(struct Scene *scene)
+{
+ if(scene->sound_scene)
+ AUD_setSequencerFPS(scene->sound_scene, FPS);
+}
+
void* sound_scene_add_scene_sound(struct Scene *scene, struct Sequence* sequence, int startframe, int endframe, int frameskip)
{
if(scene != sequence->scene)
- return AUD_addSequencer(scene->sound_scene, &(sequence->scene->sound_scene), startframe / FPS, endframe / FPS, frameskip / FPS, sequence);
+ return AUD_addSequence(scene->sound_scene, sequence->scene->sound_scene, startframe / FPS, endframe / FPS, frameskip / FPS);
return NULL;
}
void* sound_add_scene_sound(struct Scene *scene, struct Sequence* sequence, int startframe, int endframe, int frameskip)
{
- return AUD_addSequencer(scene->sound_scene, &(sequence->sound->playback_handle), startframe / FPS, endframe / FPS, frameskip / FPS, sequence);
+ return AUD_addSequence(scene->sound_scene, sequence->sound->playback_handle, startframe / FPS, endframe / FPS, frameskip / FPS);
}
void sound_remove_scene_sound(struct Scene *scene, void* handle)
{
- AUD_removeSequencer(scene->sound_scene, handle);
+ AUD_removeSequence(scene->sound_scene, handle);
}
void sound_mute_scene_sound(struct Scene *scene, void* handle, char mute)
{
- AUD_muteSequencer(scene->sound_scene, handle, mute);
+ AUD_muteSequence(handle, mute);
}
void sound_move_scene_sound(struct Scene *scene, void* handle, int startframe, int endframe, int frameskip)
{
- AUD_moveSequencer(scene->sound_scene, handle, startframe / FPS, endframe / FPS, frameskip / FPS);
+ AUD_moveSequence(handle, startframe / FPS, endframe / FPS, frameskip / FPS);
+}
+
+void sound_update_scene_sound(void* handle, struct bSound* sound)
+{
+ AUD_updateSequenceSound(handle, sound->playback_handle);
+}
+
+void sound_update_sequencer(struct Main* main, struct bSound* sound)
+{
+ struct Scene* scene;
+
+ for(scene = main->scene.first; scene; scene = scene->id.next)
+ seq_update_sound(scene, sound);
}
static void sound_start_play_scene(struct Scene *scene)
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 8cfae0d9c7e..87f2a72cfe0 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -5590,7 +5590,7 @@ static void lib_link_sound(FileData *fd, Main *main)
sound_load(main, sound);
if(sound->cache)
- sound_cache(sound, 1);
+ sound_cache_notifying(main, sound, 1);
}
sound= sound->id.next;
}
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 2923bb62000..3a3a805f3ce 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -100,14 +100,6 @@ EnumPropertyItem snap_element_items[] = {
{SCE_SNAP_MODE_VOLUME, "VOLUME", ICON_SNAP_VOLUME, "Volume", "Snap to volume"},
{0, NULL, 0, NULL, NULL}};
-static EnumPropertyItem audio_channel_items[] = {
- {1, "MONO", 0, "Mono", "Set audio channels to mono"},
- {2, "STEREO", 0, "Stereo", "Set audio channels to stereo"},
- {4, "SURROUND4", 0, "4 Channels", "Set audio channels to 4 channels"},
- {6, "SURROUND51", 0, "5.1 Surround", "Set audio channels to 5.1 surround sound"},
- {8, "SURROUND71", 0, "7.1 Surround", "Set audio channels to 7.1 surround sound"},
- {0, NULL, 0, NULL, NULL}};
-
EnumPropertyItem image_type_items[] = {
{0, "", 0, "Image", NULL},
{R_BMP, "BMP", ICON_FILE_IMAGE, "BMP", "Output image in bitmap format"},
@@ -340,6 +332,11 @@ static void rna_Scene_layer_update(Main *bmain, Scene *scene, PointerRNA *ptr)
DAG_on_visible_update(bmain, FALSE);
}
+static void rna_Scene_fps_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr))
+{
+ sound_update_fps(scene);
+}
+
static void rna_Scene_framelen_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr))
{
scene->r.framelen= (float)scene->r.framapto/(float)scene->r.images;
@@ -2153,6 +2150,14 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
#endif
#ifdef WITH_FFMPEG
+ static EnumPropertyItem audio_channel_items[] = {
+ {1, "MONO", 0, "Mono", "Set audio channels to mono"},
+ {2, "STEREO", 0, "Stereo", "Set audio channels to stereo"},
+ {4, "SURROUND4", 0, "4 Channels", "Set audio channels to 4 channels"},
+ {6, "SURROUND51", 0, "5.1 Surround", "Set audio channels to 5.1 surround sound"},
+ {8, "SURROUND71", 0, "7.1 Surround", "Set audio channels to 7.1 surround sound"},
+ {0, NULL, 0, NULL, NULL}};
+
static EnumPropertyItem ffmpeg_format_items[] = {
{FFMPEG_MPEG1, "MPEG1", 0, "MPEG-1", ""},
{FFMPEG_MPEG2, "MPEG2", 0, "MPEG-2", ""},
@@ -2497,14 +2502,14 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_range(prop, 1, 120);
RNA_def_property_ui_text(prop, "FPS", "Framerate, expressed in frames per second");
- RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL);
+ RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_Scene_fps_update");
prop= RNA_def_property(srna, "fps_base", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "frs_sec_base");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_range(prop, 0.1f, 120.0f);
RNA_def_property_ui_text(prop, "FPS Base", "Framerate base");
- RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL);
+ RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_Scene_fps_update");
/* frame mapping */
prop= RNA_def_property(srna, "frame_map_old", PROP_INT, PROP_NONE);
diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c
index eb2d38e9778..3dab8266c2f 100644
--- a/source/blender/makesrna/intern/rna_sequencer.c
+++ b/source/blender/makesrna/intern/rna_sequencer.c
@@ -560,7 +560,7 @@ static void rna_Sequence_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *p
free_imbuf_seq(scene, &ed->seqbase, FALSE, TRUE);
if(RNA_struct_is_a(ptr->type, &RNA_SoundSequence))
- seq_update_sound(scene, ptr->data);
+ seq_update_sound_bounds(scene, ptr->data);
}
static void rna_Sequence_update_reopen_files(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr)
@@ -570,7 +570,7 @@ static void rna_Sequence_update_reopen_files(Main *UNUSED(bmain), Scene *scene,
free_imbuf_seq(scene, &ed->seqbase, FALSE, FALSE);
if(RNA_struct_is_a(ptr->type, &RNA_SoundSequence))
- seq_update_sound(scene, ptr->data);
+ seq_update_sound_bounds(scene, ptr->data);
}
static void rna_Sequence_mute_update(Main *bmain, Scene *scene, PointerRNA *ptr)
diff --git a/source/blender/makesrna/intern/rna_sound.c b/source/blender/makesrna/intern/rna_sound.c
index 97339058794..f471e5e0fe5 100644
--- a/source/blender/makesrna/intern/rna_sound.c
+++ b/source/blender/makesrna/intern/rna_sound.c
@@ -41,7 +41,7 @@
#include "BKE_sound.h"
#include "BKE_context.h"
-static void rna_Sound_filepath_update(Main *bmain, Scene *scene, PointerRNA *ptr)
+static void rna_Sound_filepath_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
{
sound_load(bmain, (bSound*)ptr->data);
}
@@ -61,6 +61,11 @@ static void rna_Sound_caching_set(PointerRNA *ptr, const int value)
sound_delete_cache(sound);
}
+static void rna_Sound_caching_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
+{
+ sound_update_sequencer(bmain, (bSound*)(ptr->data));
+}
+
#else
static void rna_def_sound(BlenderRNA *brna)
@@ -87,7 +92,7 @@ static void rna_def_sound(BlenderRNA *brna)
prop= RNA_def_property(srna, "use_memory_cache", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_funcs(prop, "rna_Sound_caching_get", "rna_Sound_caching_set");
RNA_def_property_ui_text(prop, "Caching", "The sound file is decoded and loaded into RAM");
- RNA_def_property_update(prop, 0, "rna_Sound_filepath_update");
+ RNA_def_property_update(prop, 0, "rna_Sound_caching_update");
}
void RNA_def_sound(BlenderRNA *brna)