/// <summary> /// Initializes a new instance of the <see cref="WaveFileReader" /> class. /// </summary> /// <param name="stream">Stream which contains wave file data.</param> public WaveFileReader(Stream stream) { if (stream == null) throw new ArgumentNullException("stream"); if (!stream.CanRead) throw new ArgumentException("stream is not readable"); _stream = stream; var reader = new BinaryReader(stream); if (new String(reader.ReadChars(4)) == "RIFF") { reader.ReadInt32(); //FileLength reader.ReadChars(4); } _chunks = ReadChunks(stream); _dataChunk = (DataChunk)_chunks.FirstOrDefault(x => x is DataChunk); if (_dataChunk == null) throw new ArgumentException("The specified stream does not contain any data chunks.", "stream"); Position = 0; }