问题
I've been playing around with the Web Audio API and using my laptop's microphone as an input source. I can hear a lot of white noise when I listen to the input though; how can I create a filter to reduce the noise so that the sound is clearer? Are there any libraries that provide a pre-written noise filter for this situation?
回答1:
'`m working on some POC and reduced laptop "life noses" with a BiquadFilter. I have also use a compressor but you don't have to ))
(function(){
var filter, compressor, mediaStreamSource;
// Start off by initializing a new context.
var context = new (window.AudioContext || window.webkitAudioContext)();
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia;
navigator.getUserMedia( {audio:true}, initAudio , function(err){
console.log('usermedia error', err)
});
function initAudio(stream) {
compressor = context.createDynamicsCompressor();
compressor.threshold.value = -50;
compressor.knee.value = 40;
compressor.ratio.value = 12;
compressor.reduction.value = -20;
compressor.attack.value = 0;
compressor.release.value = 0.25;
filter = context.createBiquadFilter();
filter.Q.value = 8.30;
filter.frequency.value = 355;
filter.gain.value = 3.0;
filter.type = 'bandpass';
filter.connect(compressor);
compressor.connect(context.destination)
filter.connect(context.destination)
mediaStreamSource = context.createMediaStreamSource( stream );
mediaStreamSource.connect( filter );
}
})();
回答2:
You might try a type of high pass filter if what you're hearing is more of a hiss than full-spectrum noise. I believe the Web Audio API has that type of filter that you could implement.
来源:https://stackoverflow.com/questions/16949768/how-can-i-reduce-the-noise-of-a-microphone-input-with-the-web-audio-api