BaseAudioContext: createConvolver() method
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since April 2021.
ThecreateConvolver()
method of theBaseAudioContext
interface creates aConvolverNode
, which is commonly used to applyreverb effects to your audio. See thespec definition of Convolution for more information.
Note:TheConvolverNode()
constructor is the recommended way to create aConvolverNode
; seeCreating an AudioNode.
In this article
Syntax
createConvolver()
Parameters
None.
Return value
Examples
>Creating a convolver node
The following example shows how to use an AudioContext to create a convolver node.You create anAudioBuffer
containing a sound sample to be usedas an ambience to shape the convolution (called theimpulse response) andapply that to the convolver. The example below uses a short sample of a concert hallcrowd, so the reverb effect applied is really deep and echoey.
For more complete applied examples/information, check out ourVoice-change-O-matic demo (seeapp.js for the code that is excerpted below).
const audioCtx = new AudioContext();// …const convolver = audioCtx.createConvolver();// …// Grab audio track via fetch() for convolver nodetry { const response = await fetch( "https://mdn.github.io/voice-change-o-matic/audio/concert-crowd.ogg", ); const arrayBuffer = await response.arrayBuffer(); const decodedAudio = await audioCtx.decodeAudioData(arrayBuffer); convolver.buffer = decodedAudio;} catch (error) { console.error( `Unable to fetch the audio file: ${name} Error: ${err.message}`, );}
Specifications
Specification |
---|
Web Audio API> # dom-baseaudiocontext-createconvolver> |
Browser compatibility
Loading…