大网数据广告活动
Web 标准与前端开发

AudioNode: disconnect() method

· 52CE 我爱测

The **`disconnect()`** method of the AudioNode interface lets you disconnect one or more nodes from the node on which the method is called.

Web Audio API

The disconnect() method of the AudioNode interface lets you disconnect one or more nodes from the node on which the method is called.

Syntax

disconnect()
disconnect(output)
disconnect(destination)
disconnect(destination, output)
disconnect(destination, output, input)

Parameters

There are several versions of the disconnect() method, which accept different combinations of parameters to control which nodes to disconnect from. If no parameters are provided, all outgoing connections are disconnected.

  • destination
    • : An AudioNode or AudioParam specifying the node or nodes to disconnect from. If this value is an AudioNode, a single node is disconnected from, with any other, optional, parameters (output and/or input) further limiting which inputs and/or outputs should be disconnected. If this value is an AudioParam, then the connection to that AudioParam is terminated, and the node's contributions to that computed parameter become 0 going forward once the change takes effect.
  • output
    • : An index describing which output from the current AudioNode is to be disconnected. The index numbers are defined according to the number of output channels (see Audio channels).
  • input
    • : An index describing which input into the specified destination AudioNode is to be disconnected. The index numbers are defined according to the number of input channels (see Audio channels). Not applicable if destination is an AudioParam.

Return value

None (undefined).

Exceptions

  • IndexSizeError DOMException
    • : Thrown if the value specified as input or output is invalid, referring to a node which doesn't exist or is outside the permitted range.
  • InvalidAccessError DOMException
    • : Thrown if the node on which disconnect() is called isn't connected to the specified destination node.

Examples

const audioCtx = new AudioContext();

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

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

gainNode.disconnect();

Specifications

Browser compatibility

See also

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。