Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/space_sequencer/sequencer_draw.c')
-rw-r--r--source/blender/editors/space_sequencer/sequencer_draw.c61
1 files changed, 47 insertions, 14 deletions
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c
index 7e4207c75fe..bc97ff341db 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -173,30 +173,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);
}
}