最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Do I need to disconnect an Oscillator AudioNode after stop it? - Stack Overflow

programmeradmin4浏览0评论

I had seen in several tutorials people using .disconnect() after an .stop() in Oscillators Nodes.

As far as I understand, an Oscillator Node is disposable so when it stop and get thrown away, doesn't it get disconnected too?

Am I understanding something wrong? Why do I need to use .disconnect() after an .stop() ?

I had seen in several tutorials people using .disconnect() after an .stop() in Oscillators Nodes.

As far as I understand, an Oscillator Node is disposable so when it stop and get thrown away, doesn't it get disconnected too?

Am I understanding something wrong? Why do I need to use .disconnect() after an .stop() ?

Share Improve this question asked Apr 14, 2016 at 15:49 distantedistante 7,0256 gold badges61 silver badges103 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 6

According to the W3C Specification:

When an AudioNode has no references it will be deleted. Before it is deleted, it will disconnect itself from any other AudioNodes which it is connected to.

So when an AudioNode get stopped and no references are left it will disconnect itself and it is thus not needed to explicitly call disconnect() after stop().

You shouldn't need to disconnect the oscillator after stop(). In fact, after scheduling the start and stop times of the oscillator, you should be able to drop the reference to the oscillator immediately and the oscillator should still play. After stopping, it should automatically disconnect itself.

Of course there could be bugs in the implementation that makes disconnect to the right thing. But that's a bug.

发布评论

评论列表(0)

  1. 暂无评论