AudioContext.destination

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.

AudioContextdestination 属性返回一个 AudioDestinationNode,表示 context 中所有音频的最终目标节点,一般是音频渲染设备,比如扬声器。

示例

备注:如果需要完整的实现示例,可以去看看 MDN Github repo 的演示,比如 voice-change-o-matic

js
const audioCtx = new AudioContext();
// 旧式的 webkit/blink 浏览器需要一个前缀

const oscillatorNode = audioCtx.createOscillator();
const gainNode = audioCtx.createGain();

oscillatorNode.connect(gainNode);
gainNode.connect(audioCtx.destination);

规范

Specification
Web Audio API
# dom-baseaudiocontext-destination

浏览器兼容性

BCD tables only load in the browser

参见