/// <summary> /// Loads a sound from an WAVE file. /// </summary> /// <param name="stream">The WAVE file to load the sound from.</param> /// <exception cref="InvalidDataException"><paramref name="stream"/> does not contain a valid WAVE sound file.</exception> /// <remarks>This should only be called by <see cref="Get"/> to prevent unnecessary duplicates.</remarks> protected XWaveSound(Stream stream) { #region Sanity checks if (stream == null) { throw new ArgumentNullException(nameof(stream)); } #endregion using (var waveFile = new WaveStream(stream)) { SoundFormat = waveFile.Format; SoundData = new MemoryStream((int)waveFile.Length); waveFile.CopyToEx(SoundData); } }