AudioNode.disconnect() - Web APIs 编辑

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

Syntax

AudioNode.disconnect();

AudioNode.disconnect(output);

AudioNode.disconnect(destination);

AudioNode.disconnect(destination, output);

AudioNode.disconnect(destination, output, input);

Return value

undefined

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 Optional
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. If no matching connection is found, an InvalidAccessError exception is thrown.
output Optional
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). If this parameter is out-of-bound, an IndexSizeError exception is thrown.
input Optional
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).  If this parameter is out-of-bound, an IndexSizeError exception is thrown.

Exceptions

IndexSizeError
A value specified for input or output is invalid, referring to a node which doesn't exist or outside the permitted range.
InvalidAccessError
The node on which disconnect() was called isn't connected to the specified destination node.

Example

var AudioContext = window.AudioContext || window.webkitAudioContext;

var audioCtx = new AudioContext();

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

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

gainNode.disconnect();

Specifications

SpecificationStatusComment
Web Audio API
The definition of 'disconnect' in that specification.
Working Draft 

Browser compatibility

BCD tables only load in the browser

See also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:83 次

字数:4601

最后编辑:6 年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文