销毁音频节点的最佳方法是什么 [英] What is the best way to destroy an audionode

查看:181
本文介绍了销毁音频节点的最佳方法是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建需要创建和销毁大量音频节点的对象.据我所知,要销毁音频节点,必须:

I'm building something which requires the creation and destruction of potentially a lot of audio nodes. As far as I am aware, in order to destroy an audio node it is necessary to:

  1. 将节点的所有引用设置为null或其他
  2. 调用stop方法(如果适用)
  3. 断开所有进出连接的连接

前两个很简单,但是我试图找出是否有可能列出所有节点的连接,并且还需要知道列表中是否还有其他内容.我还需要知道如何检测未引用的音频节点的存在

The first two are simple enough but I'm trying to figure out if it's possible to list all the node's connections and also need to know if anything else is missing from my list. I also need to know how I can detect the existence of an unreferenced audio node

推荐答案

这是 AudioNode生命周期的规范:

只要有对它的任何引用,一个AudioNode将一直存在.引用有几种类型:

An AudioNode will live as long as there are any references to it. There are several types of references:

  1. 遵循正常垃圾回收规则的常规JavaScript参考.
  2. AudioBufferSourceNodes和OscillatorNodes的播放参考.这些节点在当前正在播放时会保持对自己的播放引用.
  3. 连接参考,如果另一个AudioNode连接到它,则会发生.
  4. 一个AudioNode自己维护的尾部时间引用,只要它具有尚未发出的任何内部处理状态即可.例如,ConvolverNode的尾巴即使在接收到无声输入后仍会继续播放(想像一下在大型音乐厅中拍手,并继续听到声音在整个音乐厅中回荡).一些AudioNodes具有此属性.请查看特定节点的详细信息.

只要AudioContext处于活动状态,任何循环连接且直接或间接连接到AudioContext的AudioDestinationNode的AudioNode都会保持活动状态.

Any AudioNodes which are connected in a cycle and are directly or indirectly connected to the AudioDestinationNode of the AudioContext will stay alive as long as the AudioContext is alive.

所以,据我了解:

  • 正在播放的AudioNode只需要停止.
  • 最好与其他人断开连接.
  • 断开它们的连接并没有什么坏处.

这篇关于销毁音频节点的最佳方法是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆