Re: [linux-audio-dev] Algorithm for displaying waveforms

From: Them <idragosani@email-addr-hidden>
Date: Mon Jun 06 2005 - 18:50:30 EEST

vanDongen/Gilcher wrote:

> As I recently found out, this can be very messy :)
> The basic algorithm is this:
> Each horizontal pixel represents n samples. Usually n is pretty big.
> Of those n samples you take the min and the max, and then you draw a vertical
> line between them.
> Obviously this has to be scaled to your vertical resolution and vertically
> translated to the right position on your canvas.
> If n<=1 you can choose to draw lines between the points, or just show the
> points.
>
> What is often done is to generate a peakfile, containing the min and max for a
> set chunksize.
> This is usefull if you have to redraw the waveform often.
>
> Where it gets messy is if you want to zoom, display parts of the file, rapidly
> scroll etc.etc. Then you need to set up clever caching and deal with rounding
> problems.
> In ardour the is ardour/gtk_ardour/canvas-waveview.c that does the clever
> caching and libs/ardour/source.cc read_peaks() that generates the peaks.

Actually this may be the case, since the tool is going to be used for
analyzing recorded dialog, and zooming may be required.

> The code in ardour may be to complex for your application because it is made
> to show any part of an audiofile at any position, where you may move an
> audioregion to a position "in between" screen pixels, where the region starts
> at any frame and the frames_per_pixel of the display is not an integer.

Yeah, my needs are much simpler than what Ardour... you can't do
anything with the displayed waveform beyond scroll and zoom (and maybe
basic scrubbing capability).

Thanks for your input.

-- Brett
Received on Mon Jun 6 20:15:09 2005

This archive was generated by hypermail 2.1.8 : Mon Jun 06 2005 - 20:15:10 EEST