How to avoid playing back the sound that is being recorded

I'm talking about feedback - when you make a simple javascript application that opens a stream from the user and reads the frequency analysis (or whatever is it) it thorws all received data back to the headphones in both Google Chrome and Opera. Firefox is silent most of the time and randomly creates a huge mess with unstable feedback - it also closes the stream after few seconds. Generally the thing doesn't work in Firefox yet.

I created a fiddle. If your browser doesn't support it you'll just get error in the console I assume.

The critical part of the code is the function that is called when user accepts the request for the microphone access:

        //Not sure why do I do this
        var inputPoint = context.createGain();

        // Create an AudioNode from the stream.
        var source = context.createMediaStreamSource(stream);

        //Analyser - this converts raw data into spectral analysis
        window.analyser = context.createAnalyser();
        //Mores stuff I know nothing about
        analyser.fftSize = 2048;
        //Sounds much like connecting nodes in MatLab, doesn't it?
        ///THIS should probably make the sound silent (gain:0) but it doesn't
        var zeroGain = context.createGain();
        zeroGain.gain.value = 0.0;
        //More connecting... are you already lost which node is which? Because I am.

Zero gain idea is not mine, I have stolen it from simple sound recorder demo. But what works for them doesn't work for me. The demo has also no problems in Firefox, like I do.



in function mediaGranted(stream) {...

comment out .. Fiddle line #46: //analyser.connect(context.destination); ..

more info nice demo:


Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.