Skip to content

Instantly share code, notes, and snippets.

@kevincennis
Created February 28, 2013 02:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevincennis/5053725 to your computer and use it in GitHub Desktop.
Save kevincennis/5053725 to your computer and use it in GitHub Desktop.
White noise
var sr = 48e3
, sec = 5
, len = sr * sec
, ctx = new webkitAudioContext()
, arr = new Float32Array(len)
, buf = ctx.createBuffer(1, len, sr)
, src = ctx.createBufferSource()
, i = 0
for ( ; i < len; ++i ) arr[i] = Math.random()
buf.getChannelData(0).set(arr)
src.buffer = buf
src.loop = true
src.connect(ctx.destination)
src.start(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment