I am trying to route stereo audio through channelsplitter to 6 channels with gain controls and then back to channelMerger to control all 6 channels of 5.1 set. The set is connected via HDMI, and the windows go out to all 6 channels correctly (a screen on which you can allow all 6 speakers to play sound separately).
The only examples I could find have this piece of code:
if (context.destination.maxChannelCount >= 6) { context.destination.channelCount = 6; } else { context.destination.channelCount = 2; }
When initializing the audio context, my default Channel is 2, and maxChannelCount is 6.
I use the following code to create a splitter, merge and strengthen between them:
if (context.destination.maxChannelCount >= 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<ammount;i++){ channelGains[i] = context.createGain(); channelSplitter.connect(channelGains[i],i,0); channelGains[i].connect(channelMerger,0,i); }
I tried this in chrome (39.0.2171.71 m), where maxChannelCount is 6. Firefox 2 outputs.
Edit: After messing around with channelSplitter, I found out that all outputs except the first two remain silent. This is true to specification when using channel βspeakersβ. This would mean that I should fill in the channels myself, perhaps using the algorithms described here here. I still need to check if chrome outputs all 6 channels correctly.
source share