W3C home > Mailing lists > Public > public-audio@w3.org > July to September 2012

Re: Web Audio API ambient drone

From: Chris Wilson <cwilso@google.com>
Date: Sun, 15 Jul 2012 08:03:08 -0700
Message-ID: <CAJK2wqXJh8Eqaa9bHgWRhsyhmjS2Hb5kLaBFD-AQ-+Ofo7V=rQ@mail.gmail.com>
To: Matt Diamond <mdiamond@jhu.edu>
Cc: public-audio@w3.org
Hey Matt-

Neat!  I like the apparent pitch generated by bandpass filter.

One comment - instead of continually generating noise via
JavaScriptAudioNodes, you'd probably find it much more performant to
pre-generate a couple of seconds (to avoid any detectable periodicity) of
noise in a Buffer and playing it as an AudioNode.  That would probably be a
bit more performant than continually calling Math.random for each sample.

var lengthInSamples =  2 * audioContext.sampleRate;
var noiseBuffer = audioContext.createBuffer(1, lengthInSamples,
audioContext.sampleRate);
var bufferData = noiseBuffer.getChannelData(0);
for (var i = 0; i < lengthInSamples; ++i) {
    bufferData[i] = (2*Math.random() - 1);
}

On Sat, Jul 14, 2012 at 12:26 PM, Matt Diamond <mdiamond@jhu.edu> wrote:

> Hey all,
>
> Put together a little experiment in synthesizing an ambient sound texture
> using the Web Audio API:
>
> http://matt-diamond.com/drone.html
>
> Matt
>
Received on Sunday, 15 July 2012 15:03:37 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Sunday, 15 July 2012 15:03:37 GMT