Sep 5, 2013 at 1:51 PM
Edited Sep 5, 2013 at 1:52 PM
I am drawing the waveform of a wav file on a mediaobject representation.
The user can make the duration of this media object smaller. The wav is then played only the duration and the rest is cut off.
I can draw the waveform of the entire wav no problem, and for the smaller duration I thought I could just change the length of the wavestream like so:
WaveDrawer wd = new WaveDrawer();
wd.WaveStream = new NAudio.Wave.WaveFileReader(lr.URL);
TimeSpan ts = (_representedObject as MediaObject).Duration;
wd.WaveStream.SetLength((long)(wd.WaveStream.WaveFormat.AverageBytesPerSecond * ts.TotalSeconds));
But this results in the exception "Can't set length of WaveFormatString".
What am I doing wrong? Or is there another way to go about this?