Dec 26, 2011 at 6:51 PM


i wonder if it is possible with NAudio to draw the whole Waveform after loading a file and not on the fly while the file is played. Couldnt find out how this works. Some example code would be much appreciated. (Drawing itself isnt the point here, its more about getting all the data for the whole graph in the beginning, in lists maybe)

Dec 26, 2011 at 7:05 PM

thats quite easy. You know how to create a stream that supports creating a waveform. So just don t play the stream because the only thing the engine is doing is to read from the stream and play the read data. So simply just read from the stream into a buffer but don't play it...
Little example how to that.

int read = 0;

while(read < stream.Length)

stream.Read(somebuffer, 0, 20000);


Dec 26, 2011 at 8:54 PM

Thanks for the answear but could you get a bit more precise on the example?

Im working with the wpfdemo but when i use your code on the inputstream it just crashes? (Sorry for my noobish questions :) )

Dec 26, 2011 at 9:43 PM

yes, thefiloe's approach is the way to go. You should open the file twice - once for the playback engine, and once for the WaveForm renderer. The demo app is set up to draw the waveform while it plays so not really suitable for drawing up front.