问题
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)
回答1:
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);
回答2:
Actually, you don't even need to connect the analyser. It should process without being connected to the destination.
来源:https://stackoverflow.com/questions/34482708/mute-microphone-in-speakers-but-still-be-able-to-analyze-createanalyser-with-w