title: Naudio buffer and realtime streaming
body: <p>My application is a text-to-speech application.
  I develop a simple class based on NAudio to play the generated wave byte array (taht contains the text to be read). 
  Here is my code:</p>
  
  <pre><code>private BufferedWaveProvider _bufferedWaveProvider = new BufferedWaveProvider(new WaveFormat(16000, 1));
  private WaveOut _waveOut = new WaveOut();
  
  public NAudioPlayer(){
  _waveOut.Init(_bufferedWaveProvider);
  _waveOut.Play();
  }
  
  public void Play(byte[] textBytes){
      _bufferedWaveProvider.ClearBuffer();
      _bufferedWaveProvider.AddSamples(textBytes, 0, textBytes.Length);
  }
  </code></pre>
  
  <p>I do not know how to manage the buffer in order to prevent from full buffer exceptions.
  Reading other posts, I thought about setting the buffer length but I do not what is the maximal size of the byte array (sent by another application).
  More, I would like to avoid unexpected breaks when playing (so I think that using Thread.sleep to let the buffer discharging would not be a good idea...).</p>
  
  <p>How can I solve this problem?</p>