W3C home > Mailing lists > Public > public-xg-audio@w3.org > October 2010

Proposal: JavaScriptCueNode

From: Joseph Berkovitz <joe@noteflight.com>
Date: Wed, 6 Oct 2010 13:52:21 -0400
Message-Id: <40D562DA-D908-4BAF-99F9-DDD7A431CF9E@noteflight.com>
To: public-xg-audio@w3.org
Hi audio incubator,

This is a simple and powerful idea that was suggested to me by audio  
tools developer Joa Ebert of Hobnox last year (no connection to this  
group's work) and I want to share it here. I think it could have a lot  
of value and seems relatively easy to implement.

JavaScriptCueNode (new feature)

It is very useful to be able to have an audio scheduler cue the  
invocation of some arbitrary code at a specific point on the audio  
timeline, with no accompanying audio output.

Use cases:

- control some other piece of the application in synchrony with what  
is happening in the audio at that point.  (Example: make some  
graphical element highlight in time to a musical beat, as in Drum  
Machine demo)

- generate a new section of audio experience that smoothly extends the  
current one before it ends (Example: dynamic generation of loops in a  
gaming experience or as in Drum Machine demo)

Such functions are easiest to drive from the audio framework, instead  
of having the rest of the app try to trigger itself at the exact  
correct moment or interval.  For example, look at the schedule()  
function in the Drum Machine demo, and the somewhat tricky time  
calculations and setTimeout() calls that it has to perform to loop/ 
advance the groove and draw the playhead.  This would be much easier  
to code if it were called on a rhythmic basis coming out of the audio  
engine itself.

Such a node can be simply realized in the API as something similar to  
a JavaScriptAudioNode but with zero outputs, and which exposes a  
noteOn() function to schedule its occurrence.  Something like:

interface JavaScriptCueNode : AudioNode {
    attribute EventListener onnoteprocess;
    void noteOn(in float when);

... .  .    .       Joe

Joe Berkovitz
Noteflight LLC
160 Sidney St
Cambridge, MA 02139
phone: +1 978 314 6271
Received on Wednesday, 6 October 2010 18:49:07 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 19:54:30 UTC