[cairo] Drawing a sound wave
Joe Bain
mrjoebain at gmail.com
Wed Nov 5 04:48:44 PST 2008
Thanks for the responses guys. To elaborate:
> 1.) Do you want to draw the sound wave from left to right or do you want to
> draw on the left while scrolling to the right?
>
I want the window to be static, no scrolling. At the moment I have it
drawing the most recent data on the left and the 10 seconds old data on the
rightmost part of the window.
> That means you'll need some sort of peak detection ... otherwise what would
> you draw?
>
This is a good point. What I tried already was to go through all 480,000
points and draw the amplitude value on the y axis with the x value
being just i/1000 (I might double check this later as it seems like more
than I remember, I don't have access to the code right now). This drew a
fine picture but used a lot of cpu and usually would only run for a few
seconds before it stopped updating.
> You could move the graph along by copying the existing image to a
> temporary surface, clear the primary surface and draw the old image
> using cairo_set_source_surface with an x-offset. Then you can draw the
> new data into the space created.
>
By doing this what happens to the old data, does it get clipped and
discarded or would it build up a long invisible tail of data? It sounds like
a good solution, though I might try getting the appropriate values per pixel
column before I draw, doing it that way would undoubtedly be quicker and may
be fast enough to draw a fresh graph each time.
Joe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.cairographics.org/archives/cairo/attachments/20081105/2c0a57b6/attachment.html
More information about the cairo
mailing list