Streaming audio via socket

Hey

I’m trying to stream an audio feed from an .net app via socket to Unity and play that feed back within the game.
The .net app streams the audio from microphone, using NAudio.

public class AudioReceiver : MonoBehaviour
{

  Socket socket;
  NetworkStream stream;
  BufferedWaveProvider waveOutputProvider;
  byte[] bytes = new Byte[6400];
  float[] tmp = new float[6400 / 4];
  bool playing = false;

  // Use this for initialization
  void Start ()
  {

  }
 
  // Update is called once per frame
  void Update ()
  {
    tmp = new float[6400 / 4]; 
    stream.Read (bytes, 0, 6400);
    Buffer.BlockCopy (bytes, 0, tmp, 0, 6400);
    if (!playing) {
      audio.loop = true;
      audio.clip = AudioClip.Create ("Stream", 16000, 1, 16000, false, true, onReaderCallback);
   
      audio.Play ();
      playing = true;
    }
  }

  void onReaderCallback (float[]data)
  {
    Debug.Log (data.Length+" "+ tmp.Length);
    for (var i=0; i<tmp.Length; i++) {
      data  _= tmp *;*_

}
}

void Awake ()
{
Debug.Log (“Connecting”);
socket = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
socket.Connect (“127.0.0.1”, 9000);
Debug.Log (“Connected”);
stream = new NetworkStream (socket);
}
}
Here is some quick&dirty code which I think should work. Sizes of the buffer are based on the amount of bytes which are sent from the server app.

Hi… Did you find solution for this? Can you share it??