Last active
June 8, 2018 10:11
-
-
Save JustGoscha/10104318 to your computer and use it in GitHub Desktop.
Dynamically create a WebAudio buffer (with noise) and play it!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var AudioContext = AudioContext || webkitAudioContext || mozAudioContext; | |
var context = new AudioContext(); | |
var node = context.createBufferSource() | |
, buffer = context.createBuffer(1, 4096, context.sampleRate) | |
, data = buffer.getChannelData(0); | |
for (var i = 0; i < 4096; i++) { | |
data[i] = Math.random(); | |
} | |
node.buffer = buffer; | |
node.loop = true; | |
node.connect(context.destination); | |
node.start(0); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment