W3cubDocs

/Web APIs

ConvolverNode: normalize property

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.

Value

A boolean.

Examples

js

const audioCtx = new (window.AudioContext || window.webkitAudioContext)();
const convolver = audioCtx.createConvolver();

// …

// grab audio track via XHR for convolver node

let soundSource;
let concertHallBuffer;

ajaxRequest = new XMLHttpRequest();
ajaxRequest.open("GET", "concert-crowd.ogg", true);
ajaxRequest.responseType = "arraybuffer";

ajaxRequest.onload = () => {
  let audioData = ajaxRequest.response;
  audioCtx.decodeAudioData(
    audioData,
    (buffer) => {
      concertHallBuffer = buffer;
      soundSource = audioCtx.createBufferSource();
      soundSource.buffer = concertHallBuffer;
    },
    (e) => console.error(`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

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
normalize 18 12 25 No 15 6 4.4.3 18 25 14 6 1.0

See also

© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/ConvolverNode/normalize