diff options
author | Joerg Mueller <nexyon@gmail.com> | 2011-12-17 04:22:15 +0400 |
---|---|---|
committer | Joerg Mueller <nexyon@gmail.com> | 2011-12-17 04:22:15 +0400 |
commit | 9276fb479ed1c5b472c5d831f52913157efe9288 (patch) | |
tree | e304904a3f225ca180026e7e9b5fa6fd2128c789 /source/blender/editors/sound | |
parent | 4d6c34462c1473afb6a0896f97bc5cd2393d0171 (diff) |
Automatically update sound animation cache when doing a mixdown.
Diffstat (limited to 'source/blender/editors/sound')
-rw-r--r-- | source/blender/editors/sound/sound_ops.c | 198 |
1 files changed, 100 insertions, 98 deletions
diff --git a/source/blender/editors/sound/sound_ops.c b/source/blender/editors/sound/sound_ops.c index dd7ea81d520..8eb1f08b5b0 100644 --- a/source/blender/editors/sound/sound_ops.c +++ b/source/blender/editors/sound/sound_ops.c @@ -212,6 +212,104 @@ static void SOUND_OT_open_mono(wmOperatorType *ot) RNA_def_boolean(ot->srna, "mono", TRUE, "Mono", "Mixdown the sound to mono"); } +/* ******************************************************* */ + +static int sound_update_animation_flags_exec(bContext *C, wmOperator *UNUSED(op)) +{ + Sequence* seq; + Scene* scene = CTX_data_scene(C); + struct FCurve* fcu; + char driven; + + SEQ_BEGIN(scene->ed, seq) { + fcu = id_data_find_fcurve(&scene->id, seq, &RNA_Sequence, "volume", 0, &driven); + if(fcu || driven) + seq->flag |= SEQ_AUDIO_VOLUME_ANIMATED; + else + seq->flag &= ~SEQ_AUDIO_VOLUME_ANIMATED; + + fcu = id_data_find_fcurve(&scene->id, seq, &RNA_Sequence, "pitch", 0, &driven); + if(fcu || driven) + seq->flag |= SEQ_AUDIO_PITCH_ANIMATED; + else + seq->flag &= ~SEQ_AUDIO_PITCH_ANIMATED; + + fcu = id_data_find_fcurve(&scene->id, seq, &RNA_Sequence, "pan", 0, &driven); + if(fcu || driven) + seq->flag |= SEQ_AUDIO_PAN_ANIMATED; + else + seq->flag &= ~SEQ_AUDIO_PAN_ANIMATED; + } + SEQ_END + + fcu = id_data_find_fcurve(&scene->id, scene, &RNA_Scene, "audio_volume", 0, &driven); + if(fcu || driven) + scene->audio.flag |= AUDIO_VOLUME_ANIMATED; + else + scene->audio.flag &= ~AUDIO_VOLUME_ANIMATED; + + return OPERATOR_FINISHED; +} + +static void SOUND_OT_update_animation_flags(wmOperatorType *ot) +{ + /* + This operator is needed to set a correct state of the sound animation + System. Unfortunately there's no really correct place to call the exec + function, that's why I made it an operator that's only visible in the + search menu. Apart from that the bake animation operator calls it too. + */ + + /* identifiers */ + ot->name= "Update animation"; + ot->description= "Update animation flags"; + ot->idname= "SOUND_OT_update_animation_flags"; + + /* api callbacks */ + ot->exec= sound_update_animation_flags_exec; + + /* flags */ + ot->flag= OPTYPE_REGISTER; +} + +/* ******************************************************* */ + +static int sound_bake_animation_exec(bContext *C, wmOperator *UNUSED(op)) +{ + Main* bmain = CTX_data_main(C); + Scene* scene = CTX_data_scene(C); + int oldfra = scene->r.cfra; + int cfra; + + sound_update_animation_flags_exec(C, NULL); + + for(cfra = scene->r.sfra > 0 ? scene->r.sfra - 1 : 0; cfra <= scene->r.efra + 1; cfra++) + { + scene->r.cfra = cfra; + scene_update_for_newframe(bmain, scene, scene->lay); + } + + scene->r.cfra = oldfra; + scene_update_for_newframe(bmain, scene, scene->lay); + + return OPERATOR_FINISHED; +} + +static void SOUND_OT_bake_animation(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Update animation cache"; + ot->description= "Updates the audio animation cache so that it's up to date"; + ot->idname= "SOUND_OT_bake_animation"; + + /* api callbacks */ + ot->exec= sound_bake_animation_exec; + + /* flags */ + ot->flag= OPTYPE_REGISTER; +} + + /******************** mixdown operator ********************/ static int sound_mixdown_exec(bContext *C, wmOperator *op) @@ -228,6 +326,8 @@ static int sound_mixdown_exec(bContext *C, wmOperator *op) AUD_Codec codec; const char* result; + sound_bake_animation_exec(C, op); + RNA_string_get(op->ptr, "filepath", path); bitrate = RNA_int_get(op->ptr, "bitrate") * 1000; accuracy = RNA_int_get(op->ptr, "accuracy"); @@ -615,104 +715,6 @@ static void SOUND_OT_unpack(wmOperatorType *ot) /* ******************************************************* */ -static int sound_update_animation_flags_exec(bContext *C, wmOperator *UNUSED(op)) -{ - Sequence* seq; - Scene* scene = CTX_data_scene(C); - struct FCurve* fcu; - char driven; - - SEQ_BEGIN(scene->ed, seq) { - fcu = id_data_find_fcurve(&scene->id, seq, &RNA_Sequence, "volume", 0, &driven); - if(fcu || driven) - seq->flag |= SEQ_AUDIO_VOLUME_ANIMATED; - else - seq->flag &= ~SEQ_AUDIO_VOLUME_ANIMATED; - - fcu = id_data_find_fcurve(&scene->id, seq, &RNA_Sequence, "pitch", 0, &driven); - if(fcu || driven) - seq->flag |= SEQ_AUDIO_PITCH_ANIMATED; - else - seq->flag &= ~SEQ_AUDIO_PITCH_ANIMATED; - - fcu = id_data_find_fcurve(&scene->id, seq, &RNA_Sequence, "pan", 0, &driven); - if(fcu || driven) - seq->flag |= SEQ_AUDIO_PAN_ANIMATED; - else - seq->flag &= ~SEQ_AUDIO_PAN_ANIMATED; - } - SEQ_END - - fcu = id_data_find_fcurve(&scene->id, scene, &RNA_Scene, "audio_volume", 0, &driven); - if(fcu || driven) - scene->audio.flag |= AUDIO_VOLUME_ANIMATED; - else - scene->audio.flag &= ~AUDIO_VOLUME_ANIMATED; - - return OPERATOR_FINISHED; -} - -static void SOUND_OT_update_animation_flags(wmOperatorType *ot) -{ - /* - This operator is needed to set a correct state of the sound animation - System. Unfortunately there's no really correct place to call the exec - function, that's why I made it an operator that's only visible in the - search menu. Apart from that the bake animation operator calls it too. - */ - - /* identifiers */ - ot->name= "Update animation"; - ot->description= "Update animation flags"; - ot->idname= "SOUND_OT_update_animation_flags"; - - /* api callbacks */ - ot->exec= sound_update_animation_flags_exec; - - /* flags */ - ot->flag= OPTYPE_REGISTER; -} - -/* ******************************************************* */ - -static int sound_bake_animation_exec(bContext *C, wmOperator *UNUSED(op)) -{ - Main* bmain = CTX_data_main(C); - Scene* scene = CTX_data_scene(C); - int oldfra = scene->r.cfra; - int cfra; - - sound_update_animation_flags_exec(C, NULL); - - for(cfra = scene->r.sfra > 0 ? scene->r.sfra - 1 : 0; cfra <= scene->r.efra + 1; cfra++) - { - scene->r.cfra = cfra; - scene_update_for_newframe(bmain, scene, scene->lay); - } - - scene->r.cfra = oldfra; - scene_update_for_newframe(bmain, scene, scene->lay); - - return OPERATOR_FINISHED; -} - -static void SOUND_OT_bake_animation(wmOperatorType *ot) -{ - /* identifiers */ - ot->name= "Update animation cache"; - ot->description= "Updates the audio animation cache so that it's up to date"; - ot->idname= "SOUND_OT_bake_animation"; - - /* api callbacks */ - ot->exec= sound_bake_animation_exec; - - /* flags */ - ot->flag= OPTYPE_REGISTER; -} - - -/* ******************************************************* */ - void ED_operatortypes_sound(void) { WM_operatortype_append(SOUND_OT_open); |