title: NAudio recording
body: <p>i have this code here : </p>
  
  <pre><code> NAudio.Wave.WaveIn sourceStream = null;
      NAudio.Wave.DirectSoundOut waveOut = null;
      NAudio.Wave.WaveFileWriter waveWriter = null;
          private void button3_Click(object sender, RoutedEventArgs e) // Start
      {
          ShowImage();
  
          sourceStream = new NAudio.Wave.WaveIn();
          sourceStream.WaveFormat = new NAudio.Wave.WaveFormat(44100, 2);
  
          NAudio.Wave.WaveInProvider waveIn = new NAudio.Wave.WaveInProvider(sourceStream);
  
          waveOut = new NAudio.Wave.DirectSoundOut();
          waveOut.Init(waveIn);
  
          sourceStream.StartRecording();
      }
  
      private void sourceStream_DataAvailable(object sender, NAudio.Wave.WaveInEventArgs e)
      {
          if (waveWriter == null) return;
  
          waveWriter.WriteData(e.Buffer, 0, e.BytesRecorded);
          waveWriter.Flush();
      }
  
      private void btnStop_Click(object sender, RoutedEventArgs e)
      {
          if (waveOut != null)
          {
              waveOut.Stop();
              waveOut.Dispose();
              waveOut = null;
          }
          if (sourceStream != null)
          {
              sourceStream.StopRecording();
              sourceStream.Dispose();
              sourceStream = null;
          }
          if (waveWriter != null)
          {
              waveWriter.Dispose();
              waveWriter = null;
          }
  
          sourceStream = new NAudio.Wave.WaveIn();
          sourceStream.WaveFormat = new NAudio.Wave.WaveFormat(44100, 2);
          sourceStream.DataAvailable += new EventHandler&lt;NAudio.Wave.WaveInEventArgs&gt;(sourceStream_DataAvailable);
          waveWriter = new NAudio.Wave.WaveFileWriter(@"../../StoryImages/", sourceStream.WaveFormat);
  
          sourceStream.StopRecording();
      }
  </code></pre>
  
  <p>Am i doing it correctly? I seen tutorials and tried but i am really weak in programming , theres a problem with the Buffer that seems to crash my whole application. It always says buffer is full. Theres a problem with </p>
  
  <blockquote>
    <p>WriteData(e.Buffer , 0,e.BytesRecorded);</p>
  </blockquote>
  
  <p>i am using NAudio to do this in WPF , am using visual studio 2010.</p>