- From: Marcus Geelnard <marcus.geelnard@gmail.com>
- Date: Thu, 5 May 2016 23:20:35 +0200
- To: public-audio@w3.org
- Message-ID: <CAL_EU=y3Cm=EKPUcRKgAN-PjZaoFra-dSL1wc=Xc--gkA2F8Sg@mail.gmail.com>
Hi all! I just recently started doing some (almost) serious work with Web Audio, and I'm glad to find that the API and the implementations are moving along nicely! One of the things I have not been able to find a nice solution to yet, though, is a situation that leaks memory and CPU cycles... (I'm sure there's a solution that I have missed) I'm playing an AudioBuffer using a looping AudioBufferSourceNode, followed by a GainNode that acts as an envelope modulator. Now, one AudioBufferSourceNode + GainNode is created and start():ed for each note that I play, and all JS references to the nodes are dropped. Eventually the GainNode will reach zero (when the envelope cycle has ended), but as far as I can tell, the AudioBufferSourceNode will continue sampling and eat CPU cycles. I think that this is correct behavior (the AudioBufferSourceNode has the playing state set, so it will not be GC:ed), although there seems to be a difference between Blink & Gecko w.r.t how much CPU is consumed by all the silent nodes. Question: What is the best method for stopping / disconnecting a looping source node at a predefined AudioContext time (i.e. when the GainNode has finished all the automation events)? I would like to avoid keeping track of all the active nodes myself (e.g. array of active source nodes + polling & checking against currentTime). /Marcus
Received on Saturday, 7 May 2016 07:45:58 UTC