diff options
Diffstat (limited to 'source/blender/editors/space_sequencer')
4 files changed, 60 insertions, 25 deletions
diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c index 14004e7fbba..2fe16b3a85d 100644 --- a/source/blender/editors/space_sequencer/sequencer_add.c +++ b/source/blender/editors/space_sequencer/sequencer_add.c @@ -350,7 +350,7 @@ static int sequencer_add_generic_strip_exec(bContext *C, wmOperator *op, SeqLoad } sort_seq(scene); - seq_update_muting(scene, ed); + seq_update_muting(ed); WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene); diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index 9a904b1a970..299fe9df460 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -172,30 +172,63 @@ static void drawseqwave(Scene *scene, Sequence *seq, float x1, float y1, float x x2 the end x value, same for y1 and y2 stepsize is width of a pixel. */ - if(seq->sound->cache) + if(seq->flag & SEQ_AUDIO_DRAW_WAVEFORM) { - int i; + int i, j, pos; int length = floor((x2-x1)/stepsize)+1; float ymid = (y1+y2)/2; float yscale = (y2-y1)/2; - float* samples = MEM_mallocN(length * sizeof(float) * 2, "seqwave_samples"); - if(!samples) - return; - if(sound_read_sound_buffer(seq->sound, samples, length, - (seq->startofs + seq->anim_startofs)/FPS, - (seq->startofs + seq->anim_startofs + seq->enddisp - seq->startdisp)/FPS) != length) + float samplestep; + float startsample, endsample; + float value; + + SoundWaveform* waveform; + + if(!seq->sound->waveform) + sound_read_waveform(seq->sound); + + waveform = seq->sound->waveform; + + startsample = floor((seq->startofs + seq->anim_startofs)/FPS * SOUND_WAVE_SAMPLES_PER_SECOND); + endsample = ceil((seq->startofs + seq->anim_startofs + seq->enddisp - seq->startdisp)/FPS * SOUND_WAVE_SAMPLES_PER_SECOND); + samplestep = (endsample-startsample) * stepsize / (x2-x1); + + if(length > floor((waveform->length - startsample) / samplestep)) + length = floor((waveform->length - startsample) / samplestep); + + glBegin(GL_LINE_STRIP); + for(i = 0; i < length; i++) { - MEM_freeN(samples); - return; + pos = startsample + i * samplestep; + + value = waveform->data[pos * 3]; + + for(j = pos+1; (j < waveform->length) && (j < pos + samplestep); j++) + { + if(value > waveform->data[j * 3]) + value = waveform->data[j * 3]; + } + + glVertex2f(x1+i*stepsize, ymid + value * yscale); } - glBegin(GL_LINES); + glEnd(); + + glBegin(GL_LINE_STRIP); 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); + pos = startsample + i * samplestep; + + value = waveform->data[pos * 3 + 1]; + + for(j = pos+1; (j < waveform->length) && (j < pos + samplestep); j++) + { + if(value < waveform->data[j * 3 + 1]) + value = waveform->data[j * 3 + 1]; + } + + glVertex2f(x1+i*stepsize, ymid + value * yscale); } glEnd(); - MEM_freeN(samples); } } @@ -1042,8 +1075,8 @@ void draw_timeline_seq(const bContext *C, ARegion *ar) SpaceSeq *sseq= CTX_wm_space_seq(C); View2D *v2d= &ar->v2d; View2DScrollers *scrollers; + short unit=0, flag=0; float col[3]; - int flag=0; /* clear and setup matrix */ UI_GetThemeColor3fv(TH_BACK, col); @@ -1065,9 +1098,10 @@ void draw_timeline_seq(const bContext *C, ARegion *ar) /* draw backdrop */ draw_seq_backdrop(v2d); - /* regular grid-pattern over the rest of the view (i.e. frame grid lines) */ + /* regular grid-pattern over the rest of the view (i.e. 25-frame grid lines) */ + // NOTE: the gridlines are currently spaced every 25 frames, which is only fine for 25 fps, but maybe not for 30... UI_view2d_constant_grid_draw(v2d); - + seq_draw_sfra_efra(scene, v2d); /* sequence strips (if there is data available to be drawn) */ @@ -1110,7 +1144,8 @@ void draw_timeline_seq(const bContext *C, ARegion *ar) UI_view2d_view_restore(C); /* scrollers */ - scrollers= UI_view2d_scrollers_calc(C, v2d, V2D_UNIT_SECONDSSEQ, V2D_GRID_CLAMP, V2D_UNIT_VALUES, V2D_GRID_CLAMP); + unit= (sseq->flag & SEQ_DRAWFRAMES)? V2D_UNIT_FRAMES : V2D_UNIT_SECONDSSEQ; + scrollers= UI_view2d_scrollers_calc(C, v2d, unit, V2D_GRID_CLAMP, V2D_UNIT_VALUES, V2D_GRID_CLAMP); UI_view2d_scrollers_draw(C, v2d, scrollers); UI_view2d_scrollers_free(scrollers); } diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 18ff33fd8a9..df347506e74 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -1141,7 +1141,7 @@ static int sequencer_mute_exec(bContext *C, wmOperator *op) } } - seq_update_muting(scene, ed); + seq_update_muting(ed); WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene); return OPERATOR_FINISHED; @@ -1188,7 +1188,7 @@ static int sequencer_unmute_exec(bContext *C, wmOperator *op) } } - seq_update_muting(scene, ed); + seq_update_muting(ed); WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene); return OPERATOR_FINISHED; @@ -1862,7 +1862,7 @@ static int sequencer_meta_toggle_exec(bContext *C, wmOperator *UNUSED(op)) } - seq_update_muting(scene, ed); + seq_update_muting(ed); WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene); return OPERATOR_FINISHED; @@ -1926,7 +1926,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(scene, ed); + seq_update_muting(ed); seqbase_unique_name_recursive(&scene->ed->seqbase, seqm); @@ -1999,7 +1999,7 @@ static int sequencer_meta_separate_exec(bContext *C, wmOperator *UNUSED(op)) } sort_seq(scene); - seq_update_muting(scene, ed); + seq_update_muting(ed); WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene); diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c index d1df9699fa3..36471c7ffcf 100644 --- a/source/blender/editors/space_sequencer/space_sequencer.c +++ b/source/blender/editors/space_sequencer/space_sequencer.c @@ -223,7 +223,7 @@ static SpaceLink *sequencer_new(const bContext *C) ar->v2d.cur= ar->v2d.tot; ar->v2d.min[0]= 10.0f; - ar->v2d.min[1]= 4.0f; + ar->v2d.min[1]= 0.5f; ar->v2d.max[0]= MAXFRAMEF; ar->v2d.max[1]= MAXSEQ; |