title: merge multiple audio buffer sources
body: <p>Question about html5 webaudio: is it possible to merge multiple songs together?</p>
  
  <p>I have different tracks that are all played at the same time using webaudio but I need to process the audio so I need all the audio inside one buffer in stead of each of the tracks having it's own buffer.</p>
  
  <p>i've tried merging them by adding their channel data but I always get "Uncaught RangeError: Index is out of range. "</p>
  
  <pre><code>function mergeBuffers(recBuffers, recLength){
  
    var result = new Float32Array(recLength*2);
    var offset = 0;
    for (var i = 0; i &lt; recBuffers.length; i++){
      result.set(recBuffers[0], offset);
      offset += recBuffers[0].length;
    }
    return result;
  }
  
  var recBuffersL = [];
  for (var i=0;i&lt;audioTracks.length; i++)
  {
      recBuffersL[i] = audioTracks[i].currentBuffer.getChannelData(0);
  
  }
  
  var recBuffersR = [];
  for (var i=0;i&lt;audioTracks.length; i++)
  {
      recBuffersR[i] = audioTracks[i].currentBuffer.getChannelData(1);
  
  }
  
  
  var buffers = [];
  buffers.push( mergeBuffers(recBuffersL, recBuffersL.length) );
  buffers.push( mergeBuffers(recBuffersR, recBuffersR.length) );
  </code></pre>