/// <summary> /// Reads a sequence of bytes from the internal buffer of the <see cref="CircularWriteableBufferingSource" /> and advances the position within the internal buffer by the /// number of bytes read. /// </summary> /// <param name="buffer"> /// An array of bytes. When this method returns, the <paramref name="buffer" /> contains the specified /// byte array with the values between <paramref name="offset" /> and (<paramref name="offset" /> + /// <paramref name="count" /> - 1) replaced by the bytes read from the internal buffer. /// </param> /// <param name="offset"> /// The zero-based byte offset in the <paramref name="buffer" /> at which to begin storing the data /// read from the internal buffer. /// </param> /// <param name="count">The maximum number of bytes to read from the internal buffer.</param> /// <returns>The total number of bytes read into the <paramref name="buffer"/>.</returns> public int Read(byte[] buffer, int offset, int count) { // We generate the needed samples int generateCount = count / _streamingSource.NumChannels; generateCount /= _streamingSource.SampleSize; _streamingSource.GenerateSamples(generateCount); //if(_streamingSource.SampleCount != count) //{ // throw new InvalidProgramException("Samples should be the same"); //} Array.Copy(_streamingSource.Buffer, buffer, count); return(count); }