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

Must read complete blocks. Using Wave16ToFloatProvider

Aug 21, 2013 at 3:53 PM
Edited Aug 21, 2013 at 3:54 PM
When calling wave16.Read below, I get the error "Must read complete blocks". Have been fiddling with this for a few hours and not managed to find a resolution. Can anybody help me out please?
WaveStream conversionStream = WaveFormatConversionStream.CreatePcmStream(rdr);
MediaFoundationResampler resampler = new MediaFoundationResampler(conversionStream, new WaveFormat(44100, 1));
resampler.ResamplerQuality = 60;

WaveFileReader tmpReader = new WaveFileReader("tempConverted.wav");

mainBuffer = new byte[tmpReader.Length];
Wave16ToFloatProvider wave16 = new Wave16ToFloatProvider(tmpReader);
wave16.Read(mainBuffer, 0, (int)tmpReader.Length);
finalFmt = wave16.WaveFormat;
Aug 27, 2013 at 4:14 PM
what is the value of tmpReader.Length? It needs to be a multiople of wave16.WaveFormat.BlockAlign, which is likely to be 2 in your case. I would also recommend reading in smaller blocks, of say a second at a time, rather than trying to convert an entire file in one go.