title: Convert Raw to Wav Streams in NodeJS
body: <p>I am using a nodeJS library <code>naudio</code> —<a href="https://github.com/Streampunk/naudiodon" rel="noreferrer">link</a>— to record sound from a 2 microphones (total 4 channel audio with each microphone being stereo). This library spits out  a <code>.raw</code> file in the following specs: <code>16 BIT, 48000Hz Sample Rate, Channel Count 4</code></p>
  
  <pre><code>// var portAudio = require('../index.js');
  var portAudio = require('naudiodon');
  var fs = require('fs');
  
  //Create a new instance of Audio Input, which is a ReadableStream
  var ai = new portAudio.AudioInput({
    channelCount: 4,
    sampleFormat: portAudio.SampleFormat16Bit,
    sampleRate: 48000,
    deviceId: 13
  });
  
  ai.on('error', console.error);
  
  //Create a write stream to write out to a raw audio file
  var ws = fs.createWriteStream('rawAudio_final.raw');
  
  //Start streaming
  ai.pipe(ws);
  ai.start();
  
  process.once('SIGINT', ai.quit);
  </code></pre>
  
  <p>Instead of the <code>.raw</code> file, I am trying to convert this to two individual <code>.wav</code> files. With the above encoding and information, what would be the best way to do so? I tried to dig around for easy ways to deinterleaving and getting <code>.wav</code> but seem to be hitting a wall.</p>