When creating a basic JavaScript application that involves opening a stream from the user and analyzing frequencies, I found that while Google Chrome and Opera work well by providing feedback in the headphones, Firefox often remains silent. Additionally, Firefox sometimes produces unstable feedback and closes the stream prematurely. It seems that the functionality does not fully work in Firefox yet.
To demonstrate this issue, I have created a fiddle. If your browser does not support it, an error may appear in the console.
The crucial part of the code is the function called when the user grants microphone access:
//Adding some initial parameter
var inputPoint = context.createGain();
// Creating an AudioNode from the stream.
var source = context.createMediaStreamSource(stream);
source.connect(inputPoint);
// Creating an Analyser for spectral analysis
window.analyser = context.createAnalyser();
analyser.fftSize = 2048;
inputPoint.connect(analyser);
analyser.connect(context.destination);
//Applying zero gain to potentially silence the sound (maintaining gain at 0)
var zeroGain = context.createGain();
zeroGain.gain.value = 0.0;
inputPoint.connect(zeroGain);
zeroGain.connect(context.destination);
I borrowed the concept of zero gain from a simple sound recorder demo, but unfortunately, what works for them does not seem to work for my project. Their demo also functions smoothly in Firefox, unlike my implementation.