title: How can I load a sound file into memory using NAudio and use it later?
body: <p>I'm playing the same sound files (randomly choosing between them) 5 times a second, and I'm always loading into memory, so the program uses a lot of memory. How could I load the sound file into memory, and start it from there? I'm using NAudio. Current code:</p>
  
  <pre><code>var sound = "sounds/test.mp3";
  using (var audioFile = new AudioFileReader(sound))
  using (var outputDevice = new WaveOutEvent())
  {
      outputDevice.Init(audioFile);
      outputDevice.Play();
      while (outputDevice.PlaybackState == PlaybackState.Playing)
      {
          Thread.Sleep(1000);
      }
      threadStop();
  }
  </code></pre>