Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mute microphone in speakers but still be able to analyze (createAnalyser) with Web Audio Api?

Im trying to create an Analyser node to get the signal from a microphone, and be able to create a graphic with the received input. But I dont want to the speakers to still recive the microphone signal.

Source (microphone) -> Analyser -> Destination(?)

The destination is always the speakers... Can I put the destination to a void or similar, and be able to still analyze the microphone?

I tried to play with the Volumne (gain node) but that affects the analyser in the end.

In summary: I need to be able to analyze an input from the microphone but mute that signal on the speakers.

EDIT: Here is what I'm doing.

analyser = context.createAnalyser();
analyser.smoothingTimeConstant = 0.4;
analyser.fftSize = 64;

microphone.connect(analyser)
analyser.connect(context.destination);

This is working fine... but Im getting the sound on the speakers. If I ask for example:

var data = new Uint8Array(analyzer.frequencyBinCount);
analyzer.getByteFrequencyData(data)

Then data will contain the reponse from microphone.

But if I add gain after like this

volume.gain.value = 0; 
microphone.connect(analyser)
analyser.connect(volume);
volume.connect(context.destination);

or I do not make the connect to context.destination, then the data array will be all 0 (not reponse from microphone)

like image 905
JsStack Avatar asked Oct 15 '25 09:10

JsStack


2 Answers

Actually, you don't even need to connect the analyser. It should process without being connected to the destination.

like image 191
cwilso Avatar answered Oct 16 '25 22:10

cwilso


Add a gain node after the analyser node and set its value to 0. So..

var volume = context.createGain();
volume.gain.value = 0;

microphone.connect(analyser);
analyser.connect(volume);
volume.connect(context.destination);
like image 31
Stuart Memo Avatar answered Oct 16 '25 21:10

Stuart Memo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!