title: Playing live audio stream from byte[] packet
body: <p>I'm trying to play sound provided by an Ethernet microphone.</p>
  
  <p>The device stream live audio via udp packets, that I read in a network receiver thread :</p>
  
  <pre><code>MemoryStream msAudio = new MemoryStream();
  
  private void process_stream(byte[] buffer)
  {
      msAudio.Write(fragment, 0, fragment.Length);
  }
  </code></pre>
  
  <p>process_stream is called in a task</p>
  
  <p>Then I have another task to play the stream in NAudio (NAudio isn't mandatory) : </p>
  
  <pre><code>  while (IsConnected)
          {
              msAudio.Position = 0;
              var waveFormat = new WaveFormat(8000, 16, 1); // Same format
              using (WaveStream blockAlignedStream = new BlockAlignReductionStream(
                                                              WaveFormatConversionStream.CreatePcmStream(
                                                                  new RawSourceWaveStream(msAudio , waveFormat))))
              {
                  using (WaveOut waveOut = new WaveOut(WaveCallbackInfo.FunctionCallback()))
                  {
                      waveOut.Init(blockAlignedStream);
                      waveOut.Play();
                      while (waveOut.PlaybackState == PlaybackState.Playing)
                      {
                          System.Threading.Thread.Sleep(100);
                      }
                  }
              }
          }
  </code></pre>
  
  <p>My problems is  : </p>
  
  <ul>
  <li>I hear Toc Toc Toc noise (about 4 times by second)</li>
  <li>The audio is sloooowed, voice is deformed like bitrate is too low (but 8khz is correct) </li>
  <li>The audio is looped, I think i have to flush my stream, but I don't see were...</li>
  </ul>
  
  <p>Thanks a lot if you can tell me some advice...</p>
  
  <p>P.S : 
  for helping, original code is working in android using AudioTrack. the code is <a href="https://github.com/Parrot-Developers/Samples/blob/master/Android/SDKSample/app/src/main/java/com/parrot/sdksample/audio/AudioPlayer.java" rel="nofollow noreferrer">here</a></p>
  
  <p>P.S 2 : Here the "image" of the audio noise that I have :
  <a href="https://i.stack.imgur.com/gNAty.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gNAty.png" alt="RawAudio"></a></p>