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

WaveChannel32 gives me an exception: Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection.

Dec 31, 2009 at 6:30 PM

Hello,

I'm trying to mix some audio using a WaveMixerStream32 so I'm using WaveChannel32 to feed it the streams in the proper format. I've got an exception with the following message:

Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection.

The minimum example I could make that also throw that error didn't include WaveMixerStream32 at all with took me to the conclusion that the problem was in how I'm using WaveChannel32. The code is this:

 

var audio = new WaveFileReader(OriginalAudioFileName);
var audio32 = new WaveChannel32(new WaveFileReader(OriginalAudioFileName));
WaveFileWriter.CreateWaveFile(PublicAudioFileName + "audio.wav", audio);
WaveFileWriter.CreateWaveFile(PublicAudioFileName + "audio32.wav", audio32);

audio.wav is generated just fine. audio32.wav is 58 bytes and that line thrown the exception.

What am I doing wrong?

 

Coordinator
Jan 4, 2010 at 10:55 AM

thanks for reporting this. I've fixed the bug in WaveChannel32 that is causing this problem (get the latest NAudio code from codeplex). Also, you must remember to set audio32.PadWithZeroes = false before you call WaveFileWriter.CreateWaveFile or you will create an infinitely long WAV file (I might remove this requirement in future versions to save anyone else from making this mistake).

Mark

Jan 4, 2010 at 1:01 PM
Hello Mark,

Thank you for looking into this so quickly. I'll give it another try today or tomorrow. I understand I'll have to get the version from source control and compile it myself, is that correct?

At one point it seems I workarounded the original problem I've had and I did ended up with a 10GB wav (by dumping a 100MB wav), so thank you very much for the hint about PadWithZeroes, I was already having that problem.

Thanks.

On Mon, Jan 4, 2010 at 11:55, markheath <notifications@codeplex.com> wrote:

From: markheath

thanks for reporting this. I've fixed the bug in WaveChannel32 that is causing this problem (get the latest NAudio code from codeplex). Also, you must remember to set audio32.PadWithZeroes = false before you call WaveFileWriter.CreateWaveFile or you will create an infinitely long WAV file (I might remove this requirement in future versions to save anyone else from making this mistake).

Mark

Read the full discussion online.

To add a post to this discussion, reply to this email (naudio@discussions.codeplex.com)

To start a new discussion for this project, email naudio@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com




--
J. Pablo Fernández <pupeno@pupeno.com> (http://pupeno.com)
Mar 24, 2010 at 3:52 AM

Please excuse my ignorance here. I am having this exact issue. I have downloaded the changes from Jan 4, however I have no idea how to apply them to the dll. I usually work alone and this is a first to me. Also, thank you for the work you have done on this library. Great stuff!

 

Coordinator
Mar 25, 2010 at 4:53 PM

Agonisties, do you have VS 2008? If so you can build your own copy of NAudio.dll from the latest code in CodePlex.

Mark