Browse Source

fixed a bug writing fact chunk for WaveFormats with bits per sample set to 0

pull/1/head
markheath 14 years ago
parent
commit
3502cbf03a
  1. 9
      NAudio/Wave/WaveOutputs/WaveFileWriter.cs

9
NAudio/Wave/WaveOutputs/WaveFileWriter.cs

@ -79,7 +79,7 @@ namespace NAudio.Wave
private void CreateFactChunk()
{
if (this.format.Encoding != WaveFormatEncoding.Pcm)
if (HasFactChunk())
{
this.writer.Write(System.Text.Encoding.ASCII.GetBytes("fact"));
this.writer.Write((int)4);
@ -88,6 +88,11 @@ namespace NAudio.Wave
}
}
private bool HasFactChunk()
{
return this.format.Encoding != WaveFormatEncoding.Pcm && this.format.BitsPerSample != 0;
}
/// <summary>
/// The wave file name or null if not applicable
/// </summary>
@ -375,7 +380,7 @@ namespace NAudio.Wave
private void UpdateFactChunk(BinaryWriter writer)
{
if (format.Encoding != WaveFormatEncoding.Pcm)
if (HasFactChunk())
{
int bitsPerSample = (format.BitsPerSample * format.Channels);
if (bitsPerSample != 0)

Loading…
Cancel
Save