本文介绍了Web音频API-捕获音频-禁用低通滤波器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用本教程: http://typedarray.org/from-microphone-to-wav-with-getusermedia-and-web-audio/

和此实时演示页面: http://typedarray.org/wp-content/projects/WebAudioRecorder/

创建我的高频分析仪.

我的问题是,默认情况下,Web Audio API会切断高频.

My problem is that Web Audio API, i thing, by default cut off high frequencies.

当我录制WAV并播放10000hz信号时,wav包含我的频率.

When i record WAV and play 10000hz signal, wav contain my freq.

如果我播放17000hz信号,WAV将不包含我的频率.

If i play 17000hz signal, wav don't contain my freq.

如何禁用低通滤波器?

代码:

function success(e){
    // creates the audio context
    audioContext = window.AudioContext || window.webkitAudioContext;
    context = new audioContext();

    // creates a gain node
    volume = context.createGain();

    // creates an audio node from the microphone incoming stream
    audioInput = context.createMediaStreamSource(e);

    // connect the stream to the gain node
    audioInput.connect(volume);

    /* From the spec: This value controls how frequently the audioprocess event is
    dispatched and how many sample-frames need to be processed each call.
    Lower values for buffer size will result in a lower (better) latency.
    Higher values will be necessary to avoid audio breakup and glitches */
    var bufferSize = 2048;
    recorder = context.createJavaScriptNode(bufferSize, 2, 2);

    recorder.onaudioprocess = function(e){
        console.log ('recording');
        var left = e.inputBuffer.getChannelData (0);
        var right = e.inputBuffer.getChannelData (1);
        // we clone the samples
        leftchannel.push (new Float32Array (left));
        rightchannel.push (new Float32Array (right));
        recordingLength += bufferSize;
    }

    // we connect the recorder
    volume.connect (recorder);
    recorder.connect (context.destination);
}

推荐答案

这是在 getUserMedia 中,而不是Web Audio API中.默认情况下, getUserMedia 为您提供的 MediaStream 包含已包含的数据(取决于浏览器):-回声已取消-抑制了噪音-已应用自动增益补偿

This is in getUserMedia and not the Web Audio API. By default, the MediaStream that getUserMedia gives you contains data that has been (depending on the browser):- echo cancelled- had the noise suppressed- had automatic gain compensation applied

您可以使用约束禁用这些约束(例如,对于Firefox):

You can disable those using constraints (for example, for Firefox):

navigator.mediaDevices.getUserMedia({audio:{echoCancellation:假,mozNoiseSuppression:否,mozAutoGainControl:否});

我们目前正在对这些属性进行标准化,但尚未完成.

We are currently standardizing those properties, but we're not done yet.

这篇关于Web音频API-捕获音频-禁用低通滤波器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 00:56