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

Re: Advice on the convolver node

From: Raymond Toy <rtoy@google.com>
Date: Thu, 22 Mar 2012 09:59:45 -0700
Message-ID: <CAE3TgXEq_GBXKEq36BC+pgrwK+PzS6Lj4PX9t1uAgv8px+-p1g@mail.gmail.com>
To: Chris Lowis <chris.lowis@bbc.co.uk>
Cc: 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.

If your impulse response is a 30Hz sine wave, consider what happens in the
frequency domain.  You transform the input signal and transform your 30Hz
sine.  The transform of that is a narrow spike at 30 Hz.  Multiply the
transforms together and you get a narrow spike at 30Hz.  Inverse transform
to get the desired signal.  All you get out would be a 30Hz sine wave, at

One possible way to do your time domain multiplication is to use an audio
gain node with a setValueCurveAtTime.  Use your 30Hz sine wave as the curve
and feed your input into the gain node.  This should multiply your signal
by your 30Hz sine.

> 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.

This should work.  But note that there is an internal normalization going
on.  If you want just straight convolution, you should set the normalize
attribute to false.

Received on Thursday, 22 March 2012 17:00:18 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:49:58 UTC