W3C home > Mailing lists > Public > public-audio@w3.org > January to March 2012

Re: Advice on the convolver node

From: Chris Wilson <cwilso@google.com>
Date: Tue, 20 Mar 2012 10:34:18 -0700
Message-ID: <CAJK2wqVsx29Jaxt9LBOjnXs=bH=4Ss7wv++06ZDeLLY3F14g2g@mail.gmail.com>
To: Raymond Toy <rtoy@google.com>
Cc: Chris Lowis <chris.lowis@bbc.co.uk>, public-audio@w3.org
Yes.  A buffer is a buffer.

On Tue, Mar 20, 2012 at 10:18 AM, Raymond Toy <rtoy@google.com> wrote:

>
>
> On Tue, Mar 20, 2012 at 9:30 AM, Chris Lowis <chris.lowis@bbc.co.uk>wrote:
>
>>
>> My question - is it possible to set the convolver buffer from a regular
>> javascript array? For example to generate the impulse response using
>> Math.sin()?
>>
>>
> Yes, you can do this.  Something like the following should work:
>
>     var convolver = context.createConvolver();
>
>     convolver.buffer = myImpulseResponse();
>
> where myImpulseResponse can be something like:
>
> function myImpulseResponse() {
>     var audioBuffer = context.createBuffer(1, sampleFrameLength,
> context.sampleRate);
>
>     var n = audioBuffer.length;
>     var data = audioBuffer.getChannelData(0);
>
>     <fill data array with your desired impulse response>
>
>    return audioBuffer;
> }
>
> Ray
>
>
Received on Tuesday, 20 March 2012 17:34:52 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 20 March 2012 17:34:52 GMT