BaseAudioContext: createConvolver() メソッド

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.

createConvolver()BaseAudioContext インターフェイスのメソッドで、 ConvolverNode を生成します。これは一般に音声にリバーブ効果を適用するために使用されます。詳しくは畳み込み効果の仕様定義 を参照してください。

メモ: ConvolverNode() コンストラクターは ConvolverNode を作成するための推奨される方法です。 AudioNode の作成を参照してください。

構文

js
createConvolver()

引数

なし。

返値

ConvolverNode です。

畳み込みノードの作成

次の例は、畳み込みノードを作成するための AudioContext の使用方法を示しています。畳み込み効果を形成するアンビエンスとして使用するサウンドサンプル(インパルスレスポンスと呼ばれます)を含む AudioBuffer を作成し、それを畳み込みに適用します。下の例では、コンサートホールの観客の短いサンプルを使っているので、適用されるリバーブ効果はとても深く、エコーがかかっているようです。

応用例や情報については、 Voice-change-O-matic デモを参照してください(関連コードは app.js を参照してください)。

js
const audioCtx = new AudioContext();
// ...

const convolver = audioCtx.createConvolver();
// ...

// 畳み込みノードのために fetch() で音声トラックをつかむ
try {
  const response = await fetch(
    "https://mdn.github.io/webaudio-examples/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(
    `音声ファイル ${name} が読み取れませんでした。エラー: ${err.message}`,
  );
}

仕様書

Specification
Web Audio API
# dom-baseaudiocontext-createconvolver

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
createConvolver

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

関連情報