[英]What is the best way to destroy an audionode
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:据我所知,为了销毁音频节点,有必要:
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我还需要知道如何检测未引用音频节点的存在
Here's the specifications on the lifetime of an AudioNode :以下是 AudioNode 生命周期的规范:
An AudioNode will live as long as there are any references to it.只要有任何引用,AudioNode 就会存在。 There are several types of references:有几种类型的引用:
- A normal JavaScript reference obeying normal garbage collection rules.一个遵循普通垃圾收集规则的普通 JavaScript 引用。
- A playing reference for both AudioBufferSourceNodes and OscillatorNodes. AudioBufferSourceNodes 和 OscillatorNodes 的播放参考。 These nodes maintain a playing reference to themselves while they are currently playing.这些节点在当前播放时维护对自己的播放引用。
- A connection reference which occurs if another AudioNode is connected to it.当另一个 AudioNode 连接到它时发生的连接引用。
- A tail-time reference which an AudioNode maintains on itself as long as it has any internal processing state which has not yet been emitted.只要 AudioNode 具有任何尚未发出的内部处理状态,它就会自行维护的尾时引用。 For example, a ConvolverNode has a tail which continues to play even after receiving silent input (think about clapping your hands in a large concert hall and continuing to hear the sound reverberate throughout the hall).例如,ConvolverNode 有一个尾部,即使在接收到无声输入后仍会继续播放(想想在大型音乐厅里拍手并继续听到整个大厅内回荡的声音)。 Some AudioNodes have this property.一些 AudioNodes 有这个属性。 Please see details for specific nodes.请参阅特定节点的详细信息。
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.只要 AudioContext 处于活动状态,任何以循环方式连接并直接或间接连接到 AudioContext 的 AudioDestinationNode 的 AudioNode 都将保持活动状态。
So, from my understanding:所以,根据我的理解:
如果您只调用没有参数的audioNode.disconnect()
,它将断开节点的所有输入以及来自它的所有输出。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.