Fixed sound wave display bug for sounds that are not full length.
authorJoerg Mueller <nexyon@gmail.com>
Sat, 17 Jul 2010 13:37:28 +0000 (13:37 +0000)
committerJoerg Mueller <nexyon@gmail.com>
Sat, 17 Jul 2010 13:37:28 +0000 (13:37 +0000)
source/blender/blenkernel/BKE_sound.h
source/blender/blenkernel/intern/sound.c
source/blender/editors/space_sequencer/sequencer_draw.c

index 50c86e80b08ff690ae2b90d9e293dbefdf560bf1..190b0400aff7826ed22c92b35c44380163b5d899 100644 (file)
@@ -94,6 +94,6 @@ float sound_sync_scene(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
index 6402f908422723b4e41e9ee7ba27714006d04e0e..f780e71d5cdd599ea01b881ac8d71b46964c4c26 100644 (file)
@@ -468,7 +468,9 @@ int sound_scene_playing(struct Scene *scene)
                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);
 }
index e46294513e755dc90e70ae59de4d85586f9e24f2..76c9c9c35b1647ac23ad2b6e19134a7d918eae4d 100644 (file)
@@ -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,
@@ -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");
                if(!samples)
                        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);
                        return;
@@ -636,7 +638,7 @@ static void draw_seq_strip(Scene *scene, ARegion *ar, SpaceSeq *sseq, Sequence *
        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);
+       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);
        if (G.moving && (seq->flag & SELECT)) {