Merging revision 30434 from my GSoC branch, log: Fixed sound wave display bug for sounds that are not full length.

This commit is contained in:
Joerg Mueller 2010-07-17 13:41:22 +00:00
parent 06193537ed
commit fd982af447
3 changed files with 10 additions and 6 deletions

@ -94,6 +94,6 @@ float sound_sync_scene(struct Scene *scene);
int sound_scene_playing(struct Scene *scene); int sound_scene_playing(struct Scene *scene);
int sound_read_sound_buffer(struct bSound* sound, float* buffer, int length); int sound_read_sound_buffer(struct bSound* sound, float* buffer, int length, float start, float end);
#endif #endif

@ -468,7 +468,9 @@ int sound_scene_playing(struct Scene *scene)
return -1; return -1;
} }
int sound_read_sound_buffer(struct bSound* sound, float* buffer, int length) int sound_read_sound_buffer(struct bSound* sound, float* buffer, int length, float start, float end)
{ {
return AUD_readSound(sound->cache, buffer, length); AUD_Sound* limiter = AUD_limitSound(sound->cache, start, end);
return AUD_readSound(limiter, buffer, length);
AUD_unload(limiter);
} }

@ -168,7 +168,7 @@ 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) static void drawseqwave(Scene *scene, Sequence *seq, float x1, float y1, float x2, float y2, float stepsize)
{ {
/* /*
x1 is the starting x value to draw the wave, x1 is the starting x value to draw the wave,
@ -184,7 +184,9 @@ static void drawseqwave(Sequence *seq, float x1, float y1, float x2, float y2, f
float* samples = MEM_mallocN(length * sizeof(float) * 2, "seqwave_samples"); float* samples = MEM_mallocN(length * sizeof(float) * 2, "seqwave_samples");
if(!samples) if(!samples)
return; return;
if(sound_read_sound_buffer(seq->sound, samples, length) != length) 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)
{ {
MEM_freeN(samples); MEM_freeN(samples);
return; return;
@ -636,7 +638,7 @@ static void draw_seq_strip(Scene *scene, ARegion *ar, SpaceSeq *sseq, Sequence *
x2= seq->enddisp; x2= seq->enddisp;
/* draw sound wave */ /* draw sound wave */
if(seq->type == SEQ_SOUND) drawseqwave(seq, x1, y1, x2, y2, (ar->v2d.cur.xmax - ar->v2d.cur.xmin)/ar->winx); if(seq->type == SEQ_SOUND) drawseqwave(scene, seq, x1, y1, x2, y2, (ar->v2d.cur.xmax - ar->v2d.cur.xmin)/ar->winx);
get_seq_color3ubv(scene, seq, col); get_seq_color3ubv(scene, seq, col);
if (G.moving && (seq->flag & SELECT)) { if (G.moving && (seq->flag & SELECT)) {