title: Audio streaming by websockets
body: <p>I'm going to create voice chat. My backend server works on Node.js and almost every connection between client and server uses socket.io.</p>
  
  <p>Is websockets appropriate for my use case? I prefer communication client -> server -> clients than P2P because I expect even 1000 clients connected to one room.</p>
  
  <p>If websocket is ok, then which method is the best to send AudioBuffer to server and playback on other clients? I do it like that:</p>
  
  <pre><code>navigator.getUserMedia({audio: true}, initializeRecorder, errorCallback);
  function initializeRecorder(MediaStream) {
      var audioCtx = new window.AudioContext();
      var sourceNode = audioCtx.createMediaStreamSource(MediaStream);
  
      var recorder = audioCtx.createScriptProcessor(4096, 1, 1);
      recorder.onaudioprocess = recorderProcess;
  
      sourceNode.connect(recorder);
  
      recorder.connect(audioCtx.destination);
  }
  function recorderProcess(e) {
      var left = e.inputBuffer.getChannelData(0);
  
      io.socket.post('url', left);
  }
  </code></pre>
  
  <p>But after receive data on other clients I don't know how to playback this Audio Stream from Buffer Arrays.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>1) Why if I don't connect ScriptProcessor (recorder variable) to destination, onaudioprocess method isn't fired?</p>
  
  <p>Documentation info - "although you don't have to provide a destination if you, say, just want to visualise some audio data" - <a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API" rel="nofollow">Web Audio concepts and usage</a></p>
  
  <p>2) Why I don't hear anything from my speakers after connect recorder variable to destination and if I connect sourceNode variable directly to destination, I do.
  Even if onaudioprocess method doesn't do anything.</p>
  
  <p>Anyone can help?</p>