how to play pcm data in chrome,using javascript(WEB APP).
//incomingData is Float32Array,pcm data.
this.Play = function(incomingData, endCallback)
{
if(incomingData && incomingData.length > 0)
{
var length = incomingData.length;
var channelBuffer = this.AudioContext.createBuffer(this.ChannelCount, length, this.SampleRate); // Create Mono Source Buffer from Raw Binary
//because channelBuffer doesn't support
copyToChannel method ,data cann't be put to channelBuffer
//channelBuffer.copyToChannel(incomingData, 0, 0); //not supported in latest Chrome
var source = this.AudioContext.createBufferSource(); // Create Sound Source
source.buffer = channelBuffer; // Add Buffered Data to Object
source.connect(this.AudioContext.destination); // Connect Sound Source to Output source.
source.onended = endCallback;
source.start(0);
}
}