ConvolverNode.normalize - Web APIs 编辑
The normalize
property of the ConvolverNode
interface is a boolean that controls whether the impulse response from the buffer will be scaled by an equal-power normalization when the buffer
attribute is set, or not.
Its default value is true
in order to achieve a more uniform output level from the convolver, when loaded with diverse impulse responses. If normalize is set to false
, then the convolution will be rendered with no pre-processing/scaling of the impulse response. Changes to this value do not take effect until the next time the buffer
attribute is set.
Syntax
var audioCtx = new AudioContext(); var convolver = audioCtx.createConvolver(); convolver.normalize = false;
Value
A boolean.
Example
var audioCtx = new (window.AudioContext || window.webkitAudioContext)();
var convolver = audioCtx.createConvolver();
...
// grab audio track via XHR for convolver node
var soundSource, concertHallBuffer;
ajaxRequest = new XMLHttpRequest();
ajaxRequest.open('GET', 'concert-crowd.ogg', true);
ajaxRequest.responseType = 'arraybuffer';
ajaxRequest.onload = function() {
var audioData = ajaxRequest.response;
audioCtx.decodeAudioData(audioData, function(buffer) {
concertHallBuffer = buffer;
soundSource = audioCtx.createBufferSource();
soundSource.buffer = concertHallBuffer;
}, function(e){"Error with decoding audio data" + e.err});
}
ajaxRequest.send();
...
convolver.normalize = false; // must be set before the buffer, to take effect
convolver.buffer = concertHallBuffer;
Specifications
Specification | Status | Comment |
---|---|---|
Web Audio API The definition of 'normalize' in that specification. | Working Draft |
Browser compatibility
BCD tables only load in the browser
See also
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论