private void WriteHeader(WavHeader header) { writer.Write(Encoding.UTF8.GetBytes(WavConst.Riff)); //writer.Write (header.ChunkID); writer.Write(0); // wait for Flush writer.Write(Encoding.UTF8.GetBytes(WavConst.Wave)); //writer.Write (header.RiffType); writer.Write(Encoding.UTF8.GetBytes(WavConst.Fmt)); //writer.Write (header.FormatChunkID); writer.Write(header.FormatChunkLength); writer.Write((short)header.AudioFormat); writer.Write((short)header.Channels); writer.Write(header.SampleRate); writer.Write(header.AvarageBytePerSecond); writer.Write((short)header.BlockAlign); writer.Write((short)header.BitsPerSample); // TODO Write extra values if (header.FormatChunkLength == 18) { throw new NotSupportedException("Extra values are not supported"); } writer.Write(Encoding.UTF8.GetBytes(WavConst.Data)); dataChunkPosition = writer.BaseStream.Position; writer.Write(0); // wait for Flush }
public WavReader(Stream stream) { reader = new BinaryReader(stream); Header = new WavHeader(); Header.Read(stream); }
public WavWriter(Stream output, WavHeader header) { this.output = output; writer = new BinaryWriter(output, Encoding.UTF8); WriteHeader(header); }