I'm looking to get the microphone activity level of a WebRTC MediaStream. However, I need to get this information without playing back the microphone to the user (otherwise there will be the loopback effect).
The answer in Microphone activity level of WebRTC MediaStream relies on the audio being played back to the user. How can I do this, without playing back the microphone?
I'm looking to get the microphone activity level of a WebRTC MediaStream. However, I need to get this information without playing back the microphone to the user (otherwise there will be the loopback effect).
The answer in Microphone activity level of WebRTC MediaStream relies on the audio being played back to the user. How can I do this, without playing back the microphone?
Share Improve this question asked Jul 8, 2014 at 6:25 apscienceapscience 7,28311 gold badges57 silver badges89 bronze badges 1- No it does not? I just tested the code and the mediastream simply goes into the node and is never played back to the speakers. I believe you HAVE to do with with the AudioAPI and connecting it to a node is not playing the audio back... – Benjamin Trent Commented Jul 8, 2014 at 13:05
1 Answer
Reset to default 7Take a look at createGain
method. It allows you to set stream's volume.
Here is my (simplified) example that I use in my project:
navigator.getUserMedia({audio: true, video: true}, function(stream) {
var audioContext = new AudioContext; //or webkitAudioContext
var source = audioContext.createMediaStreamSource(stream);
var volume = audioContext.createGain();
source.connect(volume);
volume.connect(audioContext.destination);
volume.gain.value = 0; //turn off the speakers
//further manipulations with source
}, function(err) {
console.log('error', err);
});