Re: decodeAudioData and resampling

On Mon, Dec 3, 2012 at 3:17 PM, Ehsan Akhgari <ehsan@mozilla.com> wrote:

> The spec doesn't mention anything about whether the implementation is
> supposed to resample the source audio buffer to the sample rate of the
> audio context when decoding the audio.  From examining the behavior of
> Chrome, I think the WebKit implementation does resample audio when
> decoding, and the AudioBuffer passed to the success callback contains the
> resampled data.  I can see both use cases for doing the resampling and not
> doing that, but I think the most common use case (playing the AudioBuffer
> back later) requires us to resample.
>
> What do people think about this?  No matter what we end up doing, we need
> to say explicitly what needs to happen in the spec.
>
> Thanks!
>

Hi Ehsan, sorry the spec isn't clear about this.  The intended behavior is
for the implementation to resample the decoded audio data to the
AudioContext sample-rate as part of the decodeAudioData() operation.  This
is so that we don't have to resample the data at playback time, which can
get very expensive especially with several sources playing back at the same
time.  Sample-rate converting up-front allows us to use higher-quality
sample-rate conversion algorithms, since it's easier to afford the
expensive algorithms.

Chris


> --
> Ehsan
> <http://ehsanakhgari.org/>
>
>

Received on Tuesday, 4 December 2012 00:04:47 UTC