public static MemoryStream GetWavAsMemoryStream(this byte[] data, int sampleRate, int audioChannels = 1, int bitsPerSample = 16) { MemoryStream memoryStream = new MemoryStream(); Wav.WriteHeader(memoryStream, sampleRate, audioChannels, bitsPerSample); Wav.SeekPastHeader(memoryStream); memoryStream.Write(data, 0, data.Length); Wav.UpdateHeader(memoryStream); return(memoryStream); }
public static MemoryStream GetWavAsMemoryStream(this Stream data, int sampleRate, int audioChannels = 1, int bitsPerSample = 16) { MemoryStream memoryStream = new MemoryStream(); Wav.WriteHeader(memoryStream, sampleRate, audioChannels, bitsPerSample); Wav.SeekPastHeader(memoryStream); data.Position = 0L; data.CopyTo(memoryStream); Wav.UpdateHeader(memoryStream); return(memoryStream); }