Re: Pitch preservation in AudioBufferSourceNode

On Thu, Nov 29, 2012 at 4:26 PM, Karl Godard <karl@indiloop.com> wrote:

> Hello all,
>
> I was wondering if there were plans to provide an option to preserve the
> pitch of an audio source when the playbackRate is changed on an
> AudioBufferSourceNode. I know that this happens in the HTMLMediaElement
> class, so I was wondering why it hasn't been implemented in the web audio
> api as well.
>
> Cheers!
>
> -Karl
>

There are a couple of things making me very hesitant to add
pitch-preservation to AudioBufferSourceNode *directly*.  There is no
standard pitch-shifting / time-stretching algorithm, and depending on the
algorithm chosen, the result can be radically different.  Also the nature
of the source material can affect the choice of what general type of
algorithm would be used.  This type of processing is also fairly expensive
and difficult to implement / embed directly in AudioBufferSourceNode given
all the different variations of playback that are possible.

But, the good news is that it's possible to use the building blocks of the
Web Audio API to implement different pitch-shifting / time-stretching
algorithms.  I've seen people implement phase vocoder algorithms directly
in JavaScript.  And I've been playing with some time-domain algorithms
using simple overlap-add approaches, and more recently have been playing
with some code to estimate pitch for PSOLA (Pitch Synchronous Overlap and
Add).  It's not fully baked yet, but I can put up an example once I've
cleaned it up a bit.

Cheers,
Chris

Received on Monday, 3 December 2012 21:09:05 UTC