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

Re: Advice on the convolver node

From: Chris Rogers <crogers@google.com>
Date: Thu, 22 Mar 2012 10:31:49 -0700
Message-ID: <CA+EzO0kyirFVE5TpbTWfBMU+n5Mquw950rxRdnvD-NxnhoM0sw@mail.gmail.com>
To: Chris Lowis <chris.lowis@bbc.co.uk>
Cc: Raymond Toy <rtoy@google.com>, public-audio@w3.org
On Thu, Mar 22, 2012 at 3:18 AM, Chris Lowis <chris.lowis@bbc.co.uk> wrote:

> On 20/03/2012 17:18, Raymond Toy 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:
>>
>
> Hi Raymond,
>
> Thank you for your advice! I've been trying to get to grips with the
> convolver node by reading the source in Webkit, but I'm having a little
> trouble understanding whether I can do what I want with it.
>
> I'm attempting to create a "ring modulation" effect. In the time domain
> I'd like to multiply the input signal (an audio buffer node) with a 30Hz
> sine wave. I thought I could achieve the same in the frequency domain using
> a convolution.
>

Hi Chris, ring-modulation or amplitude-modulation is a type of "non-linear"
effect and so convolution will not be the appropriate technique for
achieving it, since convolution is for "linear" effects.

In the meantime, if you want to play with AM-type effects you could
modulate the .gain attribute on an AudioGainNode by using
the setValueCurveAtTime() method (with say a 5-second long 30Hz sine wave).
 This can get you started, but what we really want is to be able to connect
outputs of AudioNodes to an AudioParam, which is not *yet* possible.  This
will be important for synthesis...

Cheers,
Chris



>
> I have something like
>
>  convolver = context.createConvolver()
>  loadImpulseResponse('sine_**30hz.wav', convolver, context);
>  source.connect(convolver)
>  convolver.connect(context.**destination)
>
> Where sine_30hz.wav is a single-channel, 30Hz sine wave of 5 seconds in
> duration. The source is a audio buffer node. I've reverted to loading the
> "impulse response" using an XMLHttpRequest to make sure I'm not doing
> something stupid.
>
> When I load the "echo-chamber.wav" impulse response from the demos
> repository I get the expected result. When I use my 30Hz Sine wav, just
> silence.
>
> Am I missing something here? The documentation of the Convolution node
> suggests that it is operating as a FIR filter, I'm not quite sure whether
> it is possible to do a straight convolution with this node.
>
> Thank you again for your help!
>
> Cheers,
>
> Chris
>
>
Received on Thursday, 22 March 2012 17:32:23 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Thursday, 22 March 2012 17:32:30 GMT