'Algorithm to draw a waveform
This is not a duplicate of this to draw the waveform, I 'm looking do it efficiently. Perhaps it's more an opinion-based question but I'm not sure of the best way I can handle it. I have a waveform and a set of positive/negative peaks (at first load, grabbed from the audio and cached in a peak database) for it and I am about to draw it with Direct2D.
I can draw it by:
- Raw line drawing of the peaks depending on the current zoom level line by line. This ought to be the slowest method but with maximum quality.
- Caching bitmaps for a set of defined zoom levels and upscaling in case of larger zoom (lowers quality) and lots of memory used especially for when lots of waveforms are loaded - this is a sequencer and I may have 100 waves loaded.
- Drawing with a ID2D1Geometry created from the peaks I get. The more peaks I use in the geometry, the slowest geometry drawing I will get. The less peaks I use, the more sparse waveform I have in big zooms.
- Ther's a concept in Windows 8+ called Geometry Realizations which, as I undesrtand, are semi-rasterizations of the geometry so I 'd create a few geometry realizations (exponentially scaled?) that would cover various zoom areas.
From your experience, what would be some almost-optimal performance method?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
