- From: Chris Wilson <cwilso@google.com>
- Date: Tue, 20 Mar 2012 10:34:18 -0700
- To: Raymond Toy <rtoy@google.com>
- Cc: Chris Lowis <chris.lowis@bbc.co.uk>, public-audio@w3.org
Received on Tuesday, 20 March 2012 17:34:52 UTC
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 UTC