Search code examples
javascriptfirefoxsurround

Web audio api 5.1 surround example not working in firefox


I've been playing a lott lately with the Web Audio Api on both Firefox and Chrome. A few days ago i started to experiment with a surround set. When i was trying surround audio in the web audio api i came to notice that my example works fine in Chrome v59 but not in Firefox v54.

// create web audio api context
var audioCtx = new (window.AudioContext || window.webkitAudioContext)();
audioCtx.destination.channelInterpretation = 'discrete';
audioCtx.destination.channelCountMode = 'explicit';
audioCtx.destination.channelCount = 6;


var oscillators = [];

var merger = audioCtx.createChannelMerger(6);

console.log(audioCtx.destination, merger);
//merger.channelInterpretation = 'discrete';
//merger.channelCountMode = 'explicit';
//merger.channelCount = 6;

var addOscilator = function(channel, frequency) {
    var oscillator = audioCtx.createOscillator();

    oscillator.frequency.value = frequency; // value in hertz
    oscillator.connect(merger,0,channel);
    oscillator.start();

    oscillators.push(oscillator);
};

addOscilator(0,300);
addOscilator(1,500);
addOscilator(2,700);
addOscilator(3,900);
addOscilator(4,1100);
addOscilator(5,1300);

merger.connect(audioCtx.destination);

When i do a console log of the audio context destination the maxChannelCount is 6 and the channelCount is also 6 but i still get only output on the left and right channel. these channels play all the output. (So its downmixed from 5.1 to stereo)

I also tried playing a 5.1 surround audiofile in a html-audio element in firefox and this worked fine. In other words, the browser is reconizing and able to output o the surround set.

Am i doing something wrong in this example or is this a feature not yet implemented by firefox(because the web audio api is still a draft)? I can't find any reports like this so i think its a fault on my side, but the inconsitency between the browsers makes me doubt.

Thanks in advance


Solution

  • After some deeper research it turned out to be a bug in firefox v54.

    https://bugzilla.mozilla.org/show_bug.cgi?id=1378070

    The channels will be processed but in the end down mixed to stereo. Mozilla is at the time of writing working on a fix.

    Marked as resolved in firefox v57.