Fix T46189, draw style for waveforms occludes sequence strip text.

Used old (2.49 era) filled style for drawing here, with white color and
alpha blending.
Also changed drawing to do linear interpolation between samples instead
of ugly square wave in high zoom.
This could be improved upon, with real waveform drawing in higher zoom
levels, but I'll leave this for later since it may need some hacking on
audaspace level.
This commit is contained in:
Antonis Ryakiotakis 2015-10-14 12:15:03 +03:00
parent 904db487a7
commit 6562e4ebe9
Notes: blender-bot 2023-02-14 08:38:11 +01:00
Referenced by issue #46189, New draw-style for audio-sequence causes problem
1 changed files with 25 additions and 23 deletions

View File

@ -198,7 +198,7 @@ static void drawseqwave(const bContext *C, SpaceSeq *sseq, Scene *scene, Sequenc
float yscale = (y2 - y1) / 2;
float samplestep;
float startsample, endsample;
float value;
float value1, value2;
bSound *sound = seq->sound;
SoundWaveform *waveform;
@ -238,35 +238,37 @@ static void drawseqwave(const bContext *C, SpaceSeq *sseq, Scene *scene, Sequenc
if (length > floor((waveform->length - startsample) / samplestep))
length = floor((waveform->length - startsample) / samplestep);
glBegin(GL_LINE_STRIP);
glColor4f(1.0f, 1.0f, 1.0f, 0.5);
glEnable(GL_BLEND);
glBegin(GL_TRIANGLE_STRIP);
for (i = 0; i < length; i++) {
pos = startsample + i * samplestep;
float sampleoffset = startsample + i * samplestep;
pos = sampleoffset;
value = waveform->data[pos * 3];
value1 = waveform->data[pos * 3];
value2 = waveform->data[pos * 3 + 1];
for (j = pos + 1; (j < waveform->length) && (j < pos + samplestep); j++) {
if (value > waveform->data[j * 3])
value = waveform->data[j * 3];
if (samplestep >= 2.0f) {
for (j = pos + 1; (j < waveform->length) && (j < pos + samplestep); j++) {
if (value1 > waveform->data[j * 3])
value1 = waveform->data[j * 3];
if (value2 < waveform->data[j * 3 + 1])
value2 = waveform->data[j * 3 + 1];
}
}
else {
float f = sampleoffset - pos;
value1 = (1.0f - f) * value1 + f * waveform->data[pos * 3 + 3];
value2 = (1.0f - f) * value2 + f * waveform->data[pos * 3 + 4];
}
glVertex2f(x1 + i * stepsize, ymid + value * yscale);
}
glEnd();
glBegin(GL_LINE_STRIP);
for (i = 0; i < length; i++) {
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);
/* max(value, -1) ensures that no sound gets drawn as a line */
glVertex2f(x1 + i * stepsize, ymid + value1 * yscale);
glVertex2f(x1 + i * stepsize, ymid + value2 * yscale);
}
glEnd();
glDisable(GL_BLEND);
}
}