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/space_sequencer | |
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/space_sequencer')
3 files changed, 77 insertions, 43 deletions
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); } } |