Skip to content

Instantly share code, notes, and snippets.

@coleww
Created June 22, 2016 01:43
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 coleww/5d75b4514ef593323a03c70c09bdd200 to your computer and use it in GitHub Desktop.
Save coleww/5d75b4514ef593323a03c70c09bdd200 to your computer and use it in GitHub Desktop.
looper buddy
<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