Skip to content

Commit

Permalink
Fix WaveFormat issue with StereoToMonoSampleProvider naudio#141
Browse files Browse the repository at this point in the history
  • Loading branch information
markheath committed Dec 6, 2016
1 parent def393d commit e90fdd2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion NAudio/Wave/SampleProviders/StereoToMonoSampleProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public StereoToMonoSampleProvider(ISampleProvider sourceProvider)
throw new ArgumentException("Source must be stereo");
}
this.sourceProvider = sourceProvider;
WaveFormat = new WaveFormat(sourceProvider.WaveFormat.SampleRate, 1);
WaveFormat = WaveFormat.CreateIeeeFloatWaveFormat(sourceProvider.WaveFormat.SampleRate, 1);
}

/// <summary>
Expand Down
10 changes: 10 additions & 0 deletions NAudioTests/WaveStreams/StereoToMonoSampleProviderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,15 @@ public void RightChannelOnly()
Assert.AreEqual(1 + 2*sample, buffer[sample], "sample #" + sample);
}
}

[Test]
public void CorrectOutputFormat()
{
var stereoSampleProvider = new TestSampleProvider(44100, 2);
var mono = stereoSampleProvider.ToMono(0f, 1f);
Assert.AreEqual(WaveFormatEncoding.IeeeFloat, mono.WaveFormat.Encoding);
Assert.AreEqual(1, mono.WaveFormat.Channels);
Assert.AreEqual(44100, mono.WaveFormat.SampleRate);
}
}
}

0 comments on commit e90fdd2

Please sign in to comment.