Created
June 22, 2016 01:43
-
-
Save coleww/5d75b4514ef593323a03c70c09bdd200 to your computer and use it in GitHub Desktop.
looper buddy
This file contains hidden or 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
<script> | |
var the_path_to_your_sound_file = "surf.mp3" | |
var context = new AudioContext(); | |
var playSound = context.createBufferSource(); | |
var getSound = new XMLHttpRequest(); | |
getSound.open("GET", the_path_to_your_sound_file, true); | |
getSound.responseType = "arraybuffer"; | |
getSound.onload = function() { | |
context.decodeAudioData(getSound.response, function(buffer){ | |
playSound.buffer = buffer; | |
playSound.connect(context.destination); | |
playSound.loop = true | |
playSound.start(0); | |
}); | |
} | |
getSound.send(); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment