document the decodeAudioData() method
authorcrogers@google.com
Mon, 29 Aug 2011 17:05:58 -0700
changeset 5 79fa66345278
parent 4 0ae3f655f7f5
child 6 dadd018d7a34
document the decodeAudioData() method
webaudio/specification.html
--- a/webaudio/specification.html	Mon Aug 22 14:36:33 2011 -0700
+++ b/webaudio/specification.html	Mon Aug 29 17:05:58 2011 -0700
@@ -588,6 +588,12 @@
 
             AudioBuffer createBuffer(in unsigned long numberOfChannels, in unsigned long length, in float sampleRate);
             AudioBuffer createBuffer(in ArrayBuffer buffer, in boolean mixToMono);
+            
+            void decodeAudioData(in ArrayBuffer audioData,
+                                 in [Callback] AudioBufferCallback successCallback,
+                                 in [Optional, Callback] AudioBufferCallback errorCallback)
+                raises(DOMException);
+            
 
             <span class="comment">// AudioNode creation </span>         
             AudioBufferSourceNode createBufferSource();
@@ -634,9 +640,6 @@
 
         </dd>
 
-
-        AudioBuffer createBuffer(in ArrayBuffer buffer, in boolean mixToMono);
-
         <dl><dt id="dfn-createBuffer">The <code>createBuffer</code> from ArrayBuffer method</dt> 
         <dd>
         <p>Creates an AudioBuffer given the audio file data contained in the ArrayBuffer.  The ArrayBuffer can, for example, be loaded from an XMLHttpRequest 
@@ -647,8 +650,28 @@
 
         </dd>
 
-
-
+        <dl><dt id="dfn-decodeAudioData">The <code>decodeAudioData</code> method</dt> 
+        <dd>
+        <p>
+        Asynchronously decodes the audio file data contained in the ArrayBuffer.  The ArrayBuffer can, for example, be loaded from an XMLHttpRequest 
+        with the new <code>responseType</code> and <code>response</code> attributes.  Audio file data can be in any of the formats supported
+        by the <code>audio</code> element.
+        </p>
+        
+        <p>
+          The decodeAudioData() method is preferred over the createBuffer() from ArrayBuffer method because it is asynchronous and does not block
+          the main JavaScript thread.
+        </p>
+
+        <p><dfn id="dfn-audioData">audioData</dfn> is an ArrayBuffer containing audio file data.</p>
+        
+        <p><dfn id="dfn-successCallback">successCallback</dfn> is a callback function which will be invoked when the decoding is
+        finished.  The single argument to this callback is an AudioBuffer representing the decoded PCM audio data.</p>
+
+        <p><dfn id="dfn-errorCallback">errorCallback</dfn> is a callback function which will be invoked if there is an error decoding 
+        the audio file data.</p>
+        
+        </dd>
 
         <dl><dt id="dfn-createBufferSource">The <code>createBufferSource</code> method</dt> 
         <dd>