- From: Joseph Berkovitz <joe@noteflight.com>
- Date: Mon, 15 Apr 2013 19:32:27 -0400
- To: Stuart Memo <stuartmemo@gmail.com>
- Cc: public-audio@w3.org
- Message-Id: <CB7636AF-4F2D-47C2-B582-E069EA4E3E4F@noteflight.com>
Hi Stuart, It isn't a silly question at all since it points at the need for clearer documentation in the future. The reason that ScriptProcessorNodes do not have start and stop times is that they act as processors of the raw sample blocks which serve as the basis for the AudioContext's operation. These blocks of necessity have a regular size and always begin/end at sample block boundaries. Adding scheduling to these nodes would make their operation more complicated to define and would mess with their "straight to the metal" simplicity. The scheduling of a GainNode's gain in front of your noise generator will work, but you could also do this within the ScriptProcessorNode although it's slightly more complicated. You can examine the playbackTime of each AudioProcessEvent, determine whether a start/stop occurs during the current sample block, and and begin/cease synthesis of a nonzero signal at the appropriate number of frames within the block. Perhaps an even simpler (and less performance intensive) way is to algorithmically pre-generate one or more reasonably long AudioBuffers of white noise and surface these as audio via one or more AudioBufferSourceNodes, which can be scheduled with start() and stop(). If you needed continuous white noise this wouldn't be so good, but since you're emulating drum sounds it may be a reasonable approach. . . . . . ...Joe Joe Berkovitz President Noteflight LLC Boston, Mass. phone: +1 978 314 6271 www.noteflight.com "Your music, everywhere" On Apr 15, 2013, at 6:41 PM, Stuart Memo <stuartmemo@gmail.com> wrote: > Hi all, > > I'm currently using a ScriptProcessorNode to generate white noise to emulate various drum sounds. My understanding from reading the spec is that there doesn't seem to be any way of scheduling a ScriptProcessorNode to start and stop it at desired times. The best solution to this problem I can think of is to schedule a gain node to mute/unmute at a certain time and then do my own garbage collection with setTimeout to disconnect the ScriptProcessorNode. > > This might be an edge case, and there's probably a very good reason that you shouldn't be able to start and stop a ScriptProcessorNode, but I thought I would flag it anyway. How about connectAtTime & disconnectAtTime as an alternative? Silly? Probably. > > - Stuart
Received on Monday, 15 April 2013 23:32:56 UTC