Page MenuHome

VSE: Use lines to draw waveform
ClosedPublic

Authored by Sebastian Parborg (zeddb) on May 6 2021, 8:50 PM.

Details

Summary

This makes it possible to see special sound waves where the min/max difference between steps doesn't differ.

Before:


After:

Diff Detail

Event Timeline

Sebastian Parborg (zeddb) requested review of this revision.May 6 2021, 8:50 PM
Sebastian Parborg (zeddb) created this revision.

Only issue I have found is aliasing of drawn waveform.

Updated so we now mix lines and triangles when drawing.
(Fixing the ugly AA artifacts we had before with just lines)

I also fixed and added RMS visualization:

Just a reminder for myself that I found a ASAN error in audaspace when loading very long audio files (~20min):

blender/extern/audaspace/plugins/ffmpeg/FFMPEGReader.cpp:377:63: runtime error: 8.84558e+20 is outside the range of representable values of type 'int'
blender/extern/audaspace/plugins/ffmpeg/FFMPEGReader.cpp:385:16: runtime error: signed integer overflow: 0 - -2147483648 cannot be represented in type 'int'

Perhaps I should split the RMS calculation fix and the fix for the above issue into separate commits.

extern/audaspace/bindings/C/AUD_Special.cpp
248

An other reminder for myself.
I got a division by zero error as is len == 0 in certain cases it seems.

I'm guessing that eof is also set when this is the case, but I haven't tried it yet.

Updated so that the drawn waveform doesn't jump around because of rounding when changing strip start offset.

So far I have checkedperformance and don't see any regression here

Some code here seems to be compactifyable I guess? especially over tri_strip_iter and line_strip_iter perhaps even in a way that would explain the code better?
Without studying it too deeply, it seems, that it can draw basically 2 waveforms, then they are blended with draw_waveform? now I don't quite see, if lines and triangles do overlap, or are they complementing each other and never overlap? or both?

So far I have checkedperformance and don't see any regression here

Some code here seems to be compactifyable I guess? especially over tri_strip_iter and line_strip_iter perhaps even in a way that would explain the code better?

I'm a bit unsure what you mean. I'm sure I could explain it better in the code but I don't think it can easily be simplified further. (I could of course be wrong).

Without studying it too deeply, it seems, that it can draw basically 2 waveforms, then they are blended with draw_waveform? now I don't quite see, if lines and triangles do overlap, or are they complementing each other and never overlap? or both?

It creates two data sets. One for the triangle strip and one for the linestrips. These two never overlap.
The strip_iter code makes sure that these start and ends after each other.

If the amplitude difference in the sound signal is small then we draw a line, if it is not small we draw a triangle to create a "filled in" area in the waveform.

In the end we draw two overlapping triangle strips to produce the RMS display.
To create the lighter colored middle part of the waveform (the RMS value) it takes the triangle strip data and scales it down so it matches the RMS value for that section.

Maybe this is unrelated to this patch?

When switching off Overlay texts, the waveform doesn't seem to be centered:

When transforming, the drawing of the waveform "jitters":

From the audio side this looks good (it's basically only the RMS fix anyway), I didn't check the drawing code in detail. And the issues raised by @Peter Fog (tintwotin) probably need to be fixed before committing this to master.

This revision is now accepted and ready to land.Aug 14 2021, 3:43 PM

From the audio side this looks good (it's basically only the RMS fix anyway), I didn't check the drawing code in detail. And the issues raised by @Peter Fog (tintwotin) probably need to be fixed before committing this to master.

Just wanted to run it by you so the small change did cause some unforeseen domino effect as the output data changed.

The issues pointed out has been fixed in my branch.

This revision was automatically updated to reflect the committed changes.