problem with WaveFileWriter

Oct 19, 2010 at 9:31 AM

Hello

Have some code like that

 

WaveStream mp3Reader = new Mp3FileReader(source);
byte[] AllTrack = new byte[mp3Reader.Length];
mp3Reader.Read(AllTrack, 0, (int)mp3Reader.Length);
WaveFileWriter LoopedWave = new WaveFileWriter(File.Create("c:\\1.wav"), mp3Reader.WaveFormat);
LoopedWave.WriteData(AllTrack, 0, AllTrack.Length);
LoopedWave.Close();

and in LoopedWave.Close() catch divide by zero in

protected virtual void Dispose(bool disposing)

in string

w.Write((int)((dataChunkSize * 8) / format.BitsPerSample));

(format.BitsPerSample == 0;)

I doing something wrong or what?

 

 

Coordinator
Nov 4, 2010 at 7:10 PM

looks like you are trying to put MP3 into a WAV file. While it is possible, it is not exactly a normal thing to do. If you need to convert to WAV, then look at the WaveFormatConversionStream

Mark