如何使用Web Audio API减少麦克风输入的噪音? [英] How can I reduce the noise of a microphone input with the Web Audio API?

查看:134
本文介绍了如何使用Web Audio API减少麦克风输入的噪音?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用Web Audio API,并使用笔记本电脑的麦克风作为输入源.但是,当我听输入时,我会听到很多白噪声.如何创建过滤器以减少噪音,使声音更清晰?是否有任何库可以针对这种情况提供预先编写的噪声滤波器?

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?

推荐答案

'm在某些POC上工作,并使用BiquadFilter减少了笔记本电脑的烦恼".我也使用过压缩机,但是您不必))

'`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 );
    }
})();

这篇关于如何使用Web Audio API减少麦克风输入的噪音?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆