Created
October 31, 2015 12:31
-
-
Save AdrienFromToulouse/5906a791a135dd00c8ce to your computer and use it in GitHub Desktop.
Streaming - Web Audio API
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
var audioCtx = new AudioContext(); | |
myScriptProcessor = audioCtx.createScriptProcessor(16384, 1, 1); | |
var rawAudioTemp = new Float32Array(data); // Your raw PCM incoming data | |
for (i = 0 ; i < rawAudioTemp.length ; i++) { | |
rawAudio.push(rawAudioTemp[i]); | |
} | |
streamingNode.onaudioprocess = function(event) { | |
for (chan= 0 ; chan< event.outputBuffer.numberOfChannels ; chan++) { | |
var out = event.outputBuffer.getChannelData(chan); | |
for (sample = 0 ; sample < 16384 ; sample++) { | |
out[sample] = rawAudio[sample + k * 16384]; | |
} | |
} k++; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment