Skip to content

Instantly share code, notes, and snippets.

@kevincennis
Created May 27, 2013 23:39
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/5659580 to your computer and use it in GitHub Desktop.
Save kevincennis/5659580 to your computer and use it in GitHub Desktop.
playback raw float-32 LPCM audio
var xhr = new XMLHttpRequest()
xhr.open('GET', 'path/to/file.mixlair')
xhr.responseType = 'arraybuffer'
xhr.onload = function(){
var buffer = new Float32Array(xhr.response)
, ac = new webkitAudioContext()
, ab = ac.createBuffer(1, buffer.length, 44100)
, src = ac.createBufferSource()
ab.getChannelData(0).set(buffer)
src.buffer = ab
src.connect(ac.destination)
src.start(0)
}
xhr.send()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment