elaborate on decoding steps for AudioContext createBuffer() and decodeAudioData()
authorcrogers
Tue, 04 Dec 2012 15:23:07 -0800
changeset 233 f3d3cf6ebe15
parent 232 a658660f3174
child 234 6b85e7696c1d
elaborate on decoding steps for AudioContext createBuffer() and decodeAudioData()
webaudio/specification.html
--- a/webaudio/specification.html	Tue Dec 04 14:56:19 2012 -0800
+++ b/webaudio/specification.html	Tue Dec 04 15:23:07 2012 -0800
@@ -931,13 +931,29 @@
       file data (for example from a .wav file). </p>
       <p>The <dfn id="dfn-mixToMono">mixToMono</dfn> parameter determines if a
       mixdown to mono will be performed. Normally, this would not be set. </p>
+
+      <p>
+      The following steps must be performed:
+      </p>
+      <ol>
+      <li>Decode the encoded <dfn>buffer</dfn> from the AudioBuffer into linear PCM.
+      If a decoding error is encountered due to the audio format not being recognized or supported, or
+      because of corrupted/unexpected/inconsistent data then return NULL (and these steps will be terminated).</li>
+      <li>If <dfn>mixToMono</dfn> is true, then mixdown the decoded linear PCM data to mono.
+      </li>
+      <li>Take the decoded (possibly mixed-down) linear PCM audio data,
+      and resample it to the sample-rate of the AudioContext if it is different from the sample-rate
+      of <dfn>buffer</dfn>.  The final result will be stored
+      in an AudioBuffer and returned as the result of this method.
+      </li>
+      </ol>
     </dd>
 </dl>
 <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
+      XMLHttpRequest using the <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
@@ -952,6 +968,26 @@
       <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>
+      
+      <p>
+      The following steps must be performed:
+      </p>
+      <ol>
+      <li>Queue a decoding operation to be performed on another thread.</li>
+      <li>The decoding thread will attempt to decode the encoded <dfn>audioData</dfn> into linear PCM.
+      If a decoding error is encountered due to the audio format not being recognized or supported, or
+      because of corrupted/unexpected/inconsistent data then the <dfn>errorCallback</dfn> will be
+      scheduled to run on the main thread's event loop and these steps will be terminated.</li>
+      <li>The decoding thread will take the result, representing the decoded linear PCM audio data,
+      and resample it to the sample-rate of the AudioContext if it is different from the sample-rate
+      of <dfn>audioData</dfn>.  The final result (after possibly sample-rate converting) will be stored
+      in an AudioBuffer.
+      </li>
+      <li>
+      The <dfn>successCallback</dfn> function will be scheduled to run on the main thread's event loop
+      given the AudioBuffer from step (3) as an argument.
+      </li>
+      </ol>
     </dd>
 </dl>
 <dl>