/// <summary>Saves the WaveFormat information structure into a binary stream</summary> /// <param name="writer">Writer through which to write the WaveFormat structure</param> /// <param name="waveFormat">Wave format structure to be written to the file</param> public static void Save(BinaryWriter writer, ref WaveFormatExtensible waveFormat) { WaveFormatEx.Save(writer, WaveFormatExtensible.Size, ref waveFormat.FormatEx); writer.Write((UInt16)waveFormat.ValidBitsPerSample); writer.Write((UInt32)waveFormat.ChannelMask); byte[] subFormatGuidBytes = waveFormat.SubFormat.ToByteArray(); writer.Write(subFormatGuidBytes, 0, 16); }
/// <summary>Reads the WaveFormat information structure from a binary stream</summary> /// <param name="reader">Reader from which to read the WaveFormat structure</param> /// <param name="waveFormat">Wave format structure to be written to the file</param> /// <returns>The total size of the structure as indicated in the size field</returns> public static int Load(BinaryReader reader, out WaveFormatExtensible waveFormat) { int totalSize = WaveFormatEx.Load(reader, out waveFormat.FormatEx); waveFormat.ValidBitsPerSample = reader.ReadUInt16(); waveFormat.ChannelMask = (ChannelMaskFlags)reader.ReadUInt32(); byte[] subFormatGuidBytes = reader.ReadBytes(16); waveFormat.SubFormat = new Guid(subFormatGuidBytes); return(totalSize); }
/// <summary>Write a format chunk using the extensible WaveFormat structure</summary> /// <param name="waveFormatExtensible"> /// Extensible WaveFormat structure to write into the chunk /// </param> public void WriteChunk(ref WaveFormatExtensible waveFormatExtensible) { WaveFormatExtensible.Save(this.writer, ref waveFormatExtensible); }
/// <summary>Reads the WaveFormat information structure from a binary stream</summary> /// <param name="reader">Reader from which to read the WaveFormat structure</param> /// <param name="waveFormat">Wave format structure to be written to the file</param> /// <returns>The total size of the structure as indicated in the size field</returns> public static int Load(BinaryReader reader, out WaveFormatExtensible waveFormat) { int totalSize = WaveFormatEx.Load(reader, out waveFormat.FormatEx); waveFormat.ValidBitsPerSample = reader.ReadUInt16(); waveFormat.ChannelMask = (ChannelMaskFlags)reader.ReadUInt32(); byte[] subFormatGuidBytes = reader.ReadBytes(16); waveFormat.SubFormat = new Guid(subFormatGuidBytes); return totalSize; }