title: Web audio 5.1 (6 channel) output
body: <p>I am trying to route stereo audio through a <code>channelsplitter</code> to 6 channels with gain controls, and then back into a <code>channelMerger</code>, to control all 6 channels of a 5.1 set. The set is connected through HDMI, and windows outputs to all 6 channels correctly (a screen where you can let all 6 speakers play a sound separately).</p>
  
  <p>The only examples I could find have this piece of code:</p>
  
  <pre><code>if (context.destination.maxChannelCount &gt;= 6) {
      context.destination.channelCount = 6;
  }
  else {
      context.destination.channelCount = 2;
  }
  </code></pre>
  
  <p>When initialising the audiocontext, my channelCount defaults to 2 and the maxChannelCount is 6.</p>
  
  <p>I use the following code to create the splitter, merger and gains inbetween:</p>
  
  <pre><code>if (context.destination.maxChannelCount &gt;= 6) {
      context.destination.channelCount = 6;
  }
  else {
      context.destination.channelCount = 2;
  }
  
  context.destination.channelCountMode = "explicit";
  context.destination.channelInterpretation = "discrete";
  
  var ammount = context.destination.channelCount;
  
  console.log('Ammount of channels:',ammount); //this outputs 6
  
  window.channelSplitter = context.createChannelSplitter(ammount);
  window.channelMerger = context.createChannelMerger(ammount);
  
  postGain.connect(channelSplitter); //postGain is the last node of the audio system
  channelMerger.connect(context.destination);
  window.channelGains = [];
  for(i=0;i&lt;ammount;i++){
      channelGains[i] = context.createGain();
  
      channelSplitter.connect(channelGains[i],i,0);
      channelGains[i].connect(channelMerger,0,i);
  }
  </code></pre>
  
  <p>I have tried this in chrome(39.0.2171.71 m), where maxChannelCount is 6. Firefox outputs 2.</p>
  
  <p>Edit:
  After fiddling with the channelSplitter, I found out that all outputs besides the first two are left silent. That is correct according to the <a href="https://developer.mozilla.org/en-US/docs/Web/API/AudioNode.channelInterpretation" rel="noreferrer">spec</a>, when using channelinterpretation 'speakers'.
  This would mean that I need to fill the channels myself, probably by using the algorithms described <a href="http://www.sersc.org/journals/IJSIP/vol2_no4/7.pdf" rel="noreferrer">here</a>.I still have to check if chrome outputs all 6 channels correctly.</p>