我使用本教程:http://typedarray.org/from-microphone-to-wav-with-getusermedia-and-web-audio/
以及此实时演示页:http://typedarray.org/wp-content/projects/WebAudioRecorder/
创建我的高频分析仪。
我的问题是Web Audio API,我的东西,默认情况下会切断高频。
当我录制WAV并播放10000hz信号时,wav包含我的频率。
如果我播放17000hz信号,wav不包含我的频率。
如何禁用低通滤波器?
代码:
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);
}
答案 0 :(得分:1)
这是getUserMedia
而不是Web Audio API。默认情况下,MediaStream
为您提供的getUserMedia
包含已经存在的数据(取决于浏览器):
- 回声被取消了
- 噪音受到抑制
- 已应用自动增益补偿
您可以使用约束禁用它们(例如,对于Firefox):
navigator.mediaDevices.getUserMedia({audio: {
echoCancellation: false,
mozNoiseSuppression: false,
mozAutoGainControl: false
});
我们目前正在对这些属性进行标准化,但我们还没有完成。