Re: Schedule arbitrary callback at future time

I see, that makes sense.  A recorder node would be killer!


On Tue, May 7, 2013 at 2:27 PM, Chris Wilson <cwilso@google.com> wrote:

> Hey Josh-
>
> The real problem with this approach is that you simply can't "get" a
> callback at a precise time in audio-clock time.  JavaScript, in a nutshell,
> just isn't a real-time language - the main thread may be busy with layout
> for a number of milliseconds, or it may be delayed by garbage collection.
>  The best approach is what Web Audio does most of the time - scheduling
> events that are more bounded (i.e. don't call arbitrary JavaScript that may
> have side effects) for precise times in the future, which are calculated
> and executed on a separate thread.
>
> If a recorder node is added to Web Audio at some point, I would expect its
> "start recording" method to have a time parameter; however, in the mean
> time, you should pretty easily be able to replicate one by using a script
> processor node and just calculate where you are in the buffer (based on the
> .playbackTime on the audio processing event), and just grab a part of a
> buffer.
>
>
> On Tue, May 7, 2013 at 11:24 AM, Josh Nielsen <josh@joshontheweb.com>wrote:
>
>> Hi all, this is my first time posting to the group, please let me know if
>> I am breaking any etiquette.  I'm very excited to see the webaudio api
>> shaping up!
>>
>> I think I have seen this brought up before but I want to throw my vote in
>> for a way to schedule callbacks to fire at a future time.  I am in the
>> process of building a synthesizer/loop recorder and I need to do things
>> like start recording audio at a specific time in the future.  Currently I
>> am using a javascript node's onaudioprocess  callback (as per suggested her
>> in the past) to get close enough but the granularity is based on the buffer
>> length and it is not exact. It would be really handy to bind a callback to
>> be fired in the future just like you can with an oscillators .start().  You
>> can see a prototype of what I'm talking about here
>> http://grooveclock.com/synth.html
>>
>> tl;dr - +1 for arbitrary callbacks scheduled at a future time
>>
>> --
>> Thanks,
>> Josh Nielsen
>> @joshontheweb <http://twitter.com/joshontheweb>
>> joshontheweb.com
>>
>
>


-- 
Thanks,
Josh Nielsen
@joshontheweb <http://twitter.com/joshontheweb>
joshontheweb.com

Received on Tuesday, 7 May 2013 20:43:06 UTC