Created
November 19, 2015 03:52
-
-
Save dariusk/416c0ac484a05cb22bd4 to your computer and use it in GitHub Desktop.
John Cage's 4'33" in the Web Audio API.
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
// John Cage's 4'33" with the Web Audio API | |
function makeSilence(e) { | |
var buflen = e.outputBuffer.length; | |
var dataL = e.outputBuffer.getChannelData(0); | |
var dataR = e.outputBuffer.getChannelData(1); | |
dataL.fill(0); | |
dataR.fill(0); | |
} | |
function InitAudio() { | |
var audioContext = window.AudioContext || window.webkitAudioContext; | |
var audioctx = new audioContext(); | |
gainNode = audioctx.createGain(); | |
gainNode.gain.value = 0.5; | |
jsNode = audioctx.createScriptProcessor(2048, 0, 2); | |
jsNode.onaudioprocess = makeSilence; | |
jsNode.connect(gainNode); | |
gainNode.connect(audioctx.destination); | |
} | |
InitAudio(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment