- From: Matt Diamond <mdiamond@jhu.edu>
- Date: Sun, 15 Jul 2012 13:06:34 -0700
- To: Chris Wilson <cwilso@google.com>
- Cc: public-audio@w3.org
- Message-ID: <CADdpXtsaeUOqj1+ZgP-MhCDCJ=u-eQYyNkoTcSZQ+UwkYNYYdQ@mail.gmail.com>
Thanks for the tip! An earlier version of this did in fact use pre-computed noise buffers, but I felt there was a vaguely perceptible "looping" effect because of the looping noise sample (it was a cool effect though). Another reason was that I was presenting a version of this script at a meetup, and felt like utilizing a JavaScriptAudioNode for real-time noise generation would be more interesting to demonstrate... but yes, it certainly takes a bit of a toll, and running a bunch of AudioBufferSource nodes would probably be much less taxing. Still, I'm pretty impressed that the API is able to handle so much, even if it's only on higher-end machines (I'm running it on a year-old MacBook Pro). Matt On Sun, Jul 15, 2012 at 8:03 AM, Chris Wilson <cwilso@google.com> wrote: > 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 20:07:02 UTC