title: How to convert PCM audio stream for online play
body: <p>I have access to an audio stream of PCM audio buffers. I should be clear <strong>I do not have access to the audio file. I only have access to a stream of 4096 byte chunks of the audio data.</strong> </p>
  
  <p>The PCM buffers come in with the following format:</p>
  
  <ul>
  <li>PCM Int 16</li>
  <li>Little Endian</li>
  <li>Two Channels</li>
  <li>Interleaved</li>
  </ul>
  
  <p>To support audio playback on a standard browser I need to convert the audio to the following format:</p>
  
  <ul>
  <li>PCM Float 32</li>
  <li>Big Endian</li>
  <li>Two channels (at most)</li>
  <li>Deinterleaved</li>
  </ul>
  
  <p>This audio is coming from an iOS app so I have access to Swift and Objective C (although I am not very comfortable with Objective C...which makes Apple's <a href="https://developer.apple.com/library/ios/documentation/MusicAudio/Reference/AudioConverterServicesReference/" rel="nofollow">Audio Converter Services</a> almost impossible to use because Swift really doesn't like pointers).</p>
  
  <p>Additionally the playback will occur on a browser so I could handle the conversion in client side Javascript or server sider. I am proficient enough in the following server side languages to do a conversion:</p>
  
  <ul>
  <li>Java (preferred)</li>
  <li>PHP</li>
  <li>Node.js</li>
  <li>Python</li>
  </ul>
  
  <p>If anyone knows a way to do this in any of these languages please let me know. I have worked on this for long enough that I will probably understand even a very technical description of how to do this.</p>
  
  <p>My current plan is to use bitwise operations to deinterleave the left and right channels, then cast the Int 16 Buffer to a Float 32 Buffer with the <a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API" rel="nofollow">Web Audio API</a>. Does this seem like a good plan?</p>
  
  <p>Any help is appreciated, thank you.</p>