diff options
author | Joerg Mueller <nexyon@gmail.com> | 2010-02-08 02:41:17 +0300 |
---|---|---|
committer | Joerg Mueller <nexyon@gmail.com> | 2010-02-08 02:41:17 +0300 |
commit | 9827a3e9eac70f68db6dc16d03016c51b7ece3f0 (patch) | |
tree | 8825b454008d3b97a64018884c179ea94874af44 /source/blender/editors | |
parent | 2f72b91a54faa7cfbdfd97eff608c8911df1d221 (diff) |
2.5 Audio:
- recode of the whole sequencer audio handling
- encode audio flag removed, instead you choose None as audio codec, added None for video codec too
- ffmpeg formats/codecs: enabled: theora, ogg, vorbis; added: matroska, flac (not working, who can fix?), mp3, wav
- sequencer wave drawing
- volume animation (now also working when mixing down to a file!)
- made sequencer strip position and length values unanimatable
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/animation/anim_ops.c | 2 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_ops.c | 14 | ||||
-rw-r--r-- | source/blender/editors/sound/sound_ops.c | 4 | ||||
-rw-r--r-- | source/blender/editors/space_graph/graph_ops.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_sequencer/sequencer_add.c | 8 | ||||
-rw-r--r-- | source/blender/editors/space_sequencer/sequencer_draw.c | 38 | ||||
-rw-r--r-- | source/blender/editors/space_sequencer/sequencer_edit.c | 74 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_conversions.c | 14 |
8 files changed, 98 insertions, 58 deletions
diff --git a/source/blender/editors/animation/anim_ops.c b/source/blender/editors/animation/anim_ops.c index 82a2b615681..8ac2bd5753a 100644 --- a/source/blender/editors/animation/anim_ops.c +++ b/source/blender/editors/animation/anim_ops.c @@ -83,7 +83,7 @@ static void change_frame_apply(bContext *C, wmOperator *op) CFRA= RNA_int_get(op->ptr, "frame"); /* do updates */ - sound_scrub(C); + sound_seek_scene(C); WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); } diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index f7aeee14cb7..53cd34c46f5 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -1513,9 +1513,11 @@ static int frame_offset_exec(bContext *C, wmOperator *op) int delta; delta = RNA_int_get(op->ptr, "delta"); - + CTX_data_scene(C)->r.cfra += delta; + sound_seek_scene(C); + WM_event_add_notifier(C, NC_SCENE|ND_FRAME, CTX_data_scene(C)); return OPERATOR_FINISHED; @@ -2473,12 +2475,13 @@ static int screen_animation_step(bContext *C, wmOperator *op, wmEvent *event) } } + if(sad->flag & ANIMPLAY_FLAG_JUMPED) + sound_seek_scene(C); + /* since we follow drawflags, we can't send notifier but tag regions ourselves */ ED_update_for_newframe(C, 1); - sound_update_playing(C); - for(sa= screen->areabase.first; sa; sa= sa->next) { ARegion *ar; for(ar= sa->regionbase.first; ar; ar= ar->next) { @@ -2521,16 +2524,19 @@ static void SCREEN_OT_animation_step(wmOperatorType *ot) static int screen_animation_play(bContext *C, wmOperator *op, wmEvent *event) { bScreen *screen= CTX_wm_screen(C); + struct Scene* scene = CTX_data_scene(C); if(screen->animtimer) { /* stop playback now */ ED_screen_animation_timer(C, 0, 0, 0); - sound_stop_all(C); + sound_stop_scene(scene); } else { ScrArea *sa= CTX_wm_area(C); int mode= (RNA_boolean_get(op->ptr, "reverse")) ? -1 : 1; int sync= -1; + if(mode == 1) // XXX only play audio forwards!? + sound_play_scene(scene); if(RNA_property_is_set(op->ptr, "sync")) sync= (RNA_boolean_get(op->ptr, "sync")); diff --git a/source/blender/editors/sound/sound_ops.c b/source/blender/editors/sound/sound_ops.c index 064baafbd95..7398017a267 100644 --- a/source/blender/editors/sound/sound_ops.c +++ b/source/blender/editors/sound/sound_ops.c @@ -74,12 +74,12 @@ static int open_exec(bContext *C, wmOperator *op) sound = sound_new_file(CTX_data_main(C), path); - if (sound==NULL || sound->handle == NULL) { + if (sound==NULL || sound->playback_handle == NULL) { BKE_report(op->reports, RPT_ERROR, "Unsupported audio format"); return OPERATOR_CANCELLED; } - info = AUD_getInfo(sound->handle); + info = AUD_getInfo(sound->playback_handle); if (info.specs.channels == AUD_CHANNELS_INVALID) { sound_delete(C, sound); diff --git a/source/blender/editors/space_graph/graph_ops.c b/source/blender/editors/space_graph/graph_ops.c index 648a162890d..f8a12c566df 100644 --- a/source/blender/editors/space_graph/graph_ops.c +++ b/source/blender/editors/space_graph/graph_ops.c @@ -77,7 +77,7 @@ static void graphview_cursor_apply(bContext *C, wmOperator *op) * NOTE: sync this part of the code with ANIM_OT_change_frame */ CFRA= RNA_int_get(op->ptr, "frame"); - sound_scrub(C); + sound_seek_scene(C); /* set the cursor value */ sipo->cursorVal= RNA_float_get(op->ptr, "value"); diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c index 359082c470a..566abaa18c3 100644 --- a/source/blender/editors/space_sequencer/sequencer_add.c +++ b/source/blender/editors/space_sequencer/sequencer_add.c @@ -215,7 +215,7 @@ static int sequencer_add_scene_strip_exec(bContext *C, wmOperator *op) else strcpy(seq->name+2, sce_seq->id.name+2); - calc_sequence_disp(seq); + calc_sequence_disp(scene, seq); sort_seq(scene); if (RNA_boolean_get(op->ptr, "replace_sel")) { @@ -303,7 +303,7 @@ static int sequencer_add_generic_strip_exec(bContext *C, wmOperator *op, SeqLoad } sort_seq(scene); - seq_update_muting(ed); + seq_update_muting(scene, ed); WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene); @@ -428,7 +428,7 @@ static int sequencer_add_image_strip_exec(bContext *C, wmOperator *op) } } - calc_sequence_disp(seq); + calc_sequence_disp(scene, seq); sort_seq(scene); @@ -530,7 +530,7 @@ static int sequencer_add_effect_strip_exec(bContext *C, wmOperator *op) seq->flag |= SEQ_USE_EFFECT_DEFAULT_FADE; - calc_sequence(seq); + calc_sequence(scene, seq); /* basic defaults */ seq->strip= strip= MEM_callocN(sizeof(Strip), "strip"); diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index b3682681fd7..5339acf74d9 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -49,7 +49,8 @@ #include "BKE_sequencer.h" #include "BKE_scene.h" #include "BKE_utildefines.h" - +#include "BKE_sound.h" + #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" @@ -172,6 +173,38 @@ static void get_seq_color3ubv(Scene *curscene, Sequence *seq, char *col) } } +static void drawseqwave(Sequence *seq, float x1, float y1, float x2, float y2, float stepsize) +{ + /* + x1 is the starting x value to draw the wave, + x2 the end x value, same for y1 and y2 + stepsize is width of a pixel. + */ + if(seq->sound->cache) + { + int i; + int length = floor((x2-x1)/stepsize)+1; + float ymid = (y1+y2)/2; + float yscale = (y2-y1)/2; + float* samples = malloc(length * sizeof(float) * 2); + if(!samples) + return; + if(sound_read_sound_buffer(seq->sound, samples, length) != length) + { + free(samples); + return; + } + glBegin(GL_LINES); + for(i = 0; i < length; i++) + { + glVertex2f(x1+i*stepsize, ymid + samples[i * 2] * yscale); + glVertex2f(x1+i*stepsize, ymid + samples[i * 2 + 1] * yscale); + } + glEnd(); + free(samples); + } +} + static void drawmeta_contents(Scene *scene, Sequence *seqm, float x1, float y1, float x2, float y2) { /* Note, this used to use WHILE_SEQ, but it messes up the seq->depth value, (needed by transform when doing overlap checks) @@ -557,6 +590,9 @@ static void draw_seq_strip(Scene *scene, ARegion *ar, SpaceSeq *sseq, Sequence * x1= seq->startdisp; x2= seq->enddisp; + /* draw sound wave */ + if(seq->type == SEQ_SOUND) drawseqwave(seq, x1, y1, x2, y2, (ar->v2d.cur.xmax - ar->v2d.cur.xmin)/ar->winx); + get_seq_color3ubv(scene, seq, col); if (G.moving && (seq->flag & SELECT)) { if(seq->flag & SEQ_OVERLAP) { diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index fb8f3b37683..4f19cfa86af 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -479,7 +479,7 @@ static void reload_sound_strip(Scene *scene, char *name) seqact->strip= seq->strip; seqact->len= seq->len; - calc_sequence(seqact); + calc_sequence(scene, seqact); seq->strip= 0; seq_free_sequence(scene, seq); @@ -519,7 +519,7 @@ static void reload_image_strip(Scene *scene, char *name) seqact->strip= seq->strip; seqact->len= seq->len; - calc_sequence(seqact); + calc_sequence(scene, seqact); seq->strip= 0; seq_free_sequence(scene, seq); @@ -857,8 +857,8 @@ static Sequence *dupli_seq(struct Scene *scene, Sequence *seq) } else if(seq->type == SEQ_SOUND) { seqn->strip->stripdata = MEM_dupallocN(seq->strip->stripdata); - if(seq->sound_handle) - seqn->sound_handle = sound_new_handle(scene, seqn->sound, seq->sound_handle->startframe, seq->sound_handle->endframe, seq->sound_handle->frameskip); + if(seq->scene_sound) + seqn->scene_sound = sound_add_scene_sound(scene, seqn, seq->startdisp, seq->enddisp, seq->startofs + seq->anim_startofs); seqn->sound->id.us++; } else if(seq->type == SEQ_IMAGE) { @@ -983,7 +983,7 @@ static Sequence *cut_seq_hard(Scene *scene, Sequence * seq, int cutframe) } reload_sequence_new_file(scene, seq); - calc_sequence(seq); + calc_sequence(scene, seq); if (!skip_dup) { /* Duplicate AFTER the first change */ @@ -1022,7 +1022,7 @@ static Sequence *cut_seq_hard(Scene *scene, Sequence * seq, int cutframe) } reload_sequence_new_file(scene, seqn); - calc_sequence(seqn); + calc_sequence(scene, seqn); } return seqn; } @@ -1072,7 +1072,7 @@ static Sequence *cut_seq_soft(Scene *scene, Sequence * seq, int cutframe) } } - calc_sequence(seq); + calc_sequence(scene, seq); if (!skip_dup) { /* Duplicate AFTER the first change */ @@ -1107,7 +1107,7 @@ static Sequence *cut_seq_soft(Scene *scene, Sequence * seq, int cutframe) seqn->startstill = 0; } - calc_sequence(seqn); + calc_sequence(scene, seqn); } return seqn; } @@ -1161,7 +1161,7 @@ int insert_gap(Scene *scene, int gap, int cfra) SEQP_BEGIN(ed, seq) { if(seq->startdisp >= cfra) { seq->start+= gap; - calc_sequence(seq); + calc_sequence(scene, seq); done= 1; } } @@ -1336,7 +1336,7 @@ static int sequencer_snap_exec(bContext *C, wmOperator *op) } seq_tx_handle_xlimits(seq, seq->flag & SEQ_LEFTSEL, seq->flag & SEQ_RIGHTSEL); } - calc_sequence(seq); + calc_sequence(scene, seq); } } SEQ_END @@ -1351,11 +1351,11 @@ static int sequencer_snap_exec(bContext *C, wmOperator *op) } else if(seq->type & SEQ_EFFECT) { if(seq->seq1 && (seq->seq1->flag & SELECT)) - calc_sequence(seq); + calc_sequence(scene, seq); else if(seq->seq2 && (seq->seq2->flag & SELECT)) - calc_sequence(seq); + calc_sequence(scene, seq); else if(seq->seq3 && (seq->seq3->flag & SELECT)) - calc_sequence(seq); + calc_sequence(scene, seq); } } SEQ_END; @@ -1425,7 +1425,7 @@ static int sequencer_mute_exec(bContext *C, wmOperator *op) } } - seq_update_muting(ed); + seq_update_muting(scene, ed); WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene); return OPERATOR_FINISHED; @@ -1476,7 +1476,7 @@ static int sequencer_unmute_exec(bContext *C, wmOperator *op) } } - seq_update_muting(ed); + seq_update_muting(scene, ed); WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene); return OPERATOR_FINISHED; @@ -1623,8 +1623,6 @@ static int sequencer_refresh_all_exec(bContext *C, wmOperator *op) free_imbuf_seq(scene, &ed->seqbase, FALSE); - seqbase_sound_reload(scene, &ed->seqbase); - WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene); return OPERATOR_FINISHED; @@ -1840,7 +1838,7 @@ static int sequencer_delete_exec(bContext *C, wmOperator *op) /* updates lengths etc */ seq= ed->seqbasep->first; while(seq) { - calc_sequence(seq); + calc_sequence(scene, seq); seq= seq->next; } @@ -1848,7 +1846,7 @@ static int sequencer_delete_exec(bContext *C, wmOperator *op) ms= ed->metastack.last; while(ms) { ms->parseq->strip->len= 0; /* force new alloc */ - calc_sequence(ms->parseq); + calc_sequence(scene, ms->parseq); ms= ms->prev; } @@ -1923,7 +1921,7 @@ static int sequencer_separate_images_exec(bContext *C, wmOperator *op) /* new stripdata */ strip_new->stripdata= se_new= MEM_callocN(sizeof(StripElem)*1, "stripelem"); strncpy(se_new->name, se->name, FILE_MAXFILE-1); - calc_sequence(seq_new); + calc_sequence(scene, seq_new); seq_new->flag &= ~SEQ_OVERLAP; if (seq_test_overlap(ed->seqbasep, seq_new)) { shuffle_seq(ed->seqbasep, seq_new, scene); @@ -2011,7 +2009,7 @@ static int sequencer_meta_toggle_exec(bContext *C, wmOperator *op) /* recalc all: the meta can have effects connected to it */ for(seq= ed->seqbasep->first; seq; seq= seq->next) - calc_sequence(seq); + calc_sequence(scene, seq); active_seq_set(scene, ms->parseq); @@ -2022,7 +2020,7 @@ static int sequencer_meta_toggle_exec(bContext *C, wmOperator *op) } - seq_update_muting(ed); + seq_update_muting(scene, ed); WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene); return OPERATOR_FINISHED; @@ -2081,7 +2079,7 @@ static int sequencer_meta_make_exec(bContext *C, wmOperator *op) seq= next; } seqm->machine= channel_max; - calc_sequence(seqm); + calc_sequence(scene, seqm); seqm->strip= MEM_callocN(sizeof(Strip), "metastrip"); seqm->strip->len= seqm->len; @@ -2091,7 +2089,7 @@ static int sequencer_meta_make_exec(bContext *C, wmOperator *op) if( seq_test_overlap(ed->seqbasep, seqm) ) shuffle_seq(ed->seqbasep, seqm, scene); - seq_update_muting(ed); + seq_update_muting(scene, ed); seqUniqueName(scene->ed->seqbasep, seqm); @@ -2165,7 +2163,7 @@ static int sequencer_meta_separate_exec(bContext *C, wmOperator *op) SEQ_END; sort_seq(scene); - seq_update_muting(ed); + seq_update_muting(scene, ed); WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene); @@ -2521,13 +2519,13 @@ void SEQUENCER_OT_previous_edit(wmOperatorType *ot) /* properties */ } -static void swap_sequence(Sequence* seqa, Sequence* seqb) +static void swap_sequence(Scene* scene, Sequence* seqa, Sequence* seqb) { int gap = seqb->startdisp - seqa->enddisp; seqb->start = seqa->start; - calc_sequence(seqb); + calc_sequence(scene, seqb); seqa->start = seqb->enddisp + gap; - calc_sequence(seqa); + calc_sequence(scene, seqa); } static Sequence* sequence_find_parent(Scene* scene, Sequence* child) @@ -2571,17 +2569,17 @@ static int sequencer_swap_exec(bContext *C, wmOperator *op) switch (side) { case SEQ_SIDE_LEFT: - swap_sequence(seq, active_seq); + swap_sequence(scene, seq, active_seq); break; case SEQ_SIDE_RIGHT: - swap_sequence(active_seq, seq); + swap_sequence(scene, active_seq, seq); break; } // XXX - should be a generic function for(iseq= scene->ed->seqbasep->first; iseq; iseq= iseq->next) { if((iseq->type & SEQ_EFFECT) && (seq_is_parent(iseq, active_seq) || seq_is_parent(iseq, seq))) { - calc_sequence(iseq); + calc_sequence(scene, iseq); } } @@ -2682,9 +2680,9 @@ static void seq_del_sound(Scene *scene, Sequence *seq) seq_del_sound(scene, iseq); } } - else if(seq->sound_handle) { - sound_delete_handle(scene, seq->sound_handle); - seq->sound_handle= NULL; + else if(seq->scene_sound) { + sound_remove_scene_sound(scene, seq->scene_sound); + seq->scene_sound = NULL; } } @@ -2733,19 +2731,19 @@ void SEQUENCER_OT_copy(wmOperatorType *ot) /* properties */ } -static void seq_offset(Sequence *seq, int ofs) +static void seq_offset(Scene *scene, Sequence *seq, int ofs) { if(seq->type == SEQ_META) { Sequence *iseq; for(iseq= seq->seqbase.first; iseq; iseq= iseq->next) { - seq_offset(iseq, ofs); + seq_offset(scene, iseq, ofs); } } else { seq->start += ofs; } - calc_sequence_disp(seq); + calc_sequence_disp(scene, seq); } static int sequencer_paste_exec(bContext *C, wmOperator *op) @@ -2764,7 +2762,7 @@ static int sequencer_paste_exec(bContext *C, wmOperator *op) /* transform pasted strips before adding */ if(ofs) { for(iseq= new.first; iseq; iseq= iseq->next) { - seq_offset(iseq, ofs); + seq_offset(scene, iseq, ofs); } } diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 15b812dc1f2..e93e9c42e10 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -2369,10 +2369,10 @@ void flushTransSeq(TransInfo *t) /* Calculate this strip and all nested strips * children are ALWAYS transformed first * so we dont need to do this in another loop. */ - calc_sequence(seq); + calc_sequence(t->scene, seq); } else { - calc_sequence_disp(seq); + calc_sequence_disp(t->scene, seq); } } seq_prev= seq; @@ -2404,7 +2404,7 @@ void flushTransSeq(TransInfo *t) while(seq) { if (seq->type == SEQ_META && seq->flag & SELECT) - calc_sequence(seq); + calc_sequence(t->scene, seq); seq= seq->next; } } @@ -4105,9 +4105,9 @@ static void freeSeqData(TransInfo *t) for(seq= seqbasep->first; seq; seq= seq->next) { /* We might want to build a list of effects that need to be updated during transform */ if(seq->type & SEQ_EFFECT) { - if (seq->seq1 && seq->seq1->flag & SELECT) calc_sequence(seq); - else if (seq->seq2 && seq->seq2->flag & SELECT) calc_sequence(seq); - else if (seq->seq3 && seq->seq3->flag & SELECT) calc_sequence(seq); + if (seq->seq1 && seq->seq1->flag & SELECT) calc_sequence(t->scene, seq); + else if (seq->seq2 && seq->seq2->flag & SELECT) calc_sequence(t->scene, seq); + else if (seq->seq3 && seq->seq3->flag & SELECT) calc_sequence(t->scene, seq); } } @@ -4118,7 +4118,7 @@ static void freeSeqData(TransInfo *t) for(a=0; a<t->total; a++, td++) { seq= ((TransDataSeq *)td->extra)->seq; if ((seq != seq_prev) && (seq->depth==0)) { - calc_sequence_disp(seq); + calc_sequence_disp(t->scene, seq); } seq_prev= seq; } |