This project has moved and is read-only. For the latest updates, please go here.

Visualize entire wave while playing

Mar 31, 2011 at 10:14 AM
Edited Mar 31, 2011 at 10:15 AM

A have made player based on NAudioDemo example.

When I click play button I want to start playing immediately and then start drawing the wave. I would like to visualize entire wave, not just the currently playing buffer.

Well, my question is, how to read entire wavestream for visualization purposes while playing?

A was thinking about my own class derived from wavestream, where I would read underlying wavestream to memory in constructor. Overriden Read() method would then read from memory, not underlying wavestream.

Apr 3, 2011 at 5:11 PM

that would work, although would require potentially a lot of memory. You could alternatively create a second WaveStream for the purposes of visualisation.


Apr 4, 2011 at 3:48 AM

I have an example of this in my WPF control library:

I use a second WaveStream on a separate thread to achieve this result. The waveform can fill out as the song plays.

Apr 4, 2011 at 10:10 AM
Edited Apr 4, 2011 at 10:11 AM

My initial thought was to avoid encoding files twice but is seems that the performance loss is 'cheaper' than memory usage in this case.

@jacobj: nice example, for now I will use what I have already done, because to rewrite yours compoment for my usage would be probably more difficult. I'm using bitmap to visualize waveform as it's faster and I don't need to stretch. I have troubles with very long songs, it's causes OutOfMemoryException but I can split bitmaps, or potencionally use drawingcontext instead of writablebitmap.

Apr 4, 2011 at 10:30 AM

@jacobj - that looks a really nice project, thanks for sharing