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

Re: Advice on the convolver node

From: Chris Lowis <chris.lowis@bbc.co.uk>
Date: Thu, 22 Mar 2012 10:18:06 +0000
Message-ID: <4F6AFC5E.4000709@bbc.co.uk>
To: Raymond Toy <rtoy@google.com>
CC: public-audio@w3.org
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.

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 10:18:49 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Thursday, 22 March 2012 10:18:50 GMT