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

Assertion failed from a mixer about an input stream

Jan 5, 2010 at 5:03 AM

I am now running naudio-35666 and I'm mixing two streams this way:

 

      var intro = new WaveChannel32(new WaveFileReader("Intro.wav"));
      intro.PadWithZeroes = false;

      var audio = new WaveChannel32(new WaveFileReader("in.wav"));
      audio.PadWithZeroes = false;

      var mixer = new WaveMixerStream32();

      mixer.AutoStop = true;
      mixer.AddInputStream(intro);
      mixer.AddInputStream(audio);

      WaveFileWriter.CreateWaveFile("out.wav", mixer);

When creating the out.wav I get the assertion error:

A mixer input did not provide the requested amount of data

at WaveMixerStream32.Read(byte[] buffer, int offset, int count) ...NAudio\Wave\WaveStreams\WaveMixerStream32.cs(155)

If I ignore the assertion, the out.wav file looks just fine.

Intro looks like this on the debugger:

 

intro	{NAudio.Wave.WaveChannel32}	NAudio.Wave.WaveChannel32
+		base	{NAudio.Wave.WaveChannel32}	NAudio.Wave.WaveStream {NAudio.Wave.WaveChannel32}
		Block	null	System.EventHandler
		BlockAlign	8	int
		destBytesPerSample	8	int
		Length	4178064	long
		length	4178064	long
		PadWithZeroes	false	bool
		pan	0.0	float
		Pan	0.0	float
		Position	257369872	long
		position	257369872	long
		Sample	null	System.EventHandler
+		sampleEventArgs	{NAudio.Wave.SampleEventArgs}	NAudio.Wave.SampleEventArgs
+		sourceBuffer	{byte[352800]}	byte[]
		sourceBytesPerSample	2	int
+		sourceStream	{NAudio.Wave.WaveFileReader}	NAudio.Wave.WaveStream {NAudio.Wave.WaveFileReader}
		Volume	1.0	float
		volume	1.0	float
+		WaveFormat	{IeeeFloat}	NAudio.Wave.WaveFormat
+		waveFormat	{IeeeFloat}	NAudio.Wave.WaveFormat

 

and audio looks like this:

 

audio	{NAudio.Wave.WaveChannel32}	NAudio.Wave.WaveChannel32
+		base	{NAudio.Wave.WaveChannel32}	NAudio.Wave.WaveStream {NAudio.Wave.WaveChannel32}
		Block	null	System.EventHandler
		BlockAlign	8	int
		destBytesPerSample	8	int
		Length	257425408	long
		length	257425408	long
		PadWithZeroes	false	bool
		pan	0.0	float
		Pan	0.0	float
		Position	257425408	long
		position	257425408	long
		Sample	null	System.EventHandler
+		sampleEventArgs	{NAudio.Wave.SampleEventArgs}	NAudio.Wave.SampleEventArgs
+		sourceBuffer	{byte[352800]}	byte[]
		sourceBytesPerSample	2	int
+		sourceStream	{NAudio.Wave.WaveFileReader}	NAudio.Wave.WaveStream {NAudio.Wave.WaveFileReader}
		Volume	1.0	float
		volume	1.0	float
+		WaveFormat	{IeeeFloat}	NAudio.Wave.WaveFormat
+		waveFormat	{IeeeFloat}	NAudio.Wave.WaveFormat

I've added some debugging output to NAudio so I know it expected 1411200 but got 1355664.

Am I doing something wrong?

 

Coordinator
Jan 5, 2010 at 9:35 AM

yes, this assert should be safe to ignore. its because pad with zeroes is false (the mixer stream was originally written to expect all its inputs to always return the exact number of bytes requested).

I'll look into removing this assert in a future version

Mark