This project has moved. For the latest updates, please go here.

Visualize entire wave while playing

Mar 31, 2011 at 9:14 AM
Edited Mar 31, 2011 at 9: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.

Coordinator
Apr 3, 2011 at 4: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.

Mark

Apr 4, 2011 at 2:48 AM

I have an example of this in my WPF control library: http://wpfsvl.codeplex.com/

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 9:10 AM
Edited Apr 4, 2011 at 9: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.

Coordinator
Apr 4, 2011 at 9:30 AM

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