Web Audio APIs - Capture audio - Disable low pass

2019-09-17 01:24发布

问题:

I use this tutorial: http://typedarray.org/from-microphone-to-wav-with-getusermedia-and-web-audio/

and this live demo page: http://typedarray.org/wp-content/projects/WebAudioRecorder/

to create my high frequency analyzer.

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

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

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

How to disable low pass filter?

code:

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); 
}

回答1:

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

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

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

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