I'm capturing a PCI WAV live audio stream from a microphone on a remote computer. Sampling rate of 44100 in a Mono16 format. I'm grabbing 250ms chunks into a short[] buffer and transferring it to a server. The server captures the "chunks" and assembles them into a playable Wav file.(just for testing, So i know the data makes it to the server correctly). I'm trying to then send the unaltered "chunks" to a web page and want to play them back using the AudioContext. I've tried every example i can find and i cannot get the AudioContext to even make even a beep, nothing not a sound. no errors thrown either.
Here's my latest attempt of many......Any help would be appreciated.
var context = new AudioContext();
connection.on("SendBuffer", function (user, bufferchunk) {
playByteArray(bufferchunk);
});
connection.start().then(function () {
}).catch(function (err) {
return console.error(err.toString());
});
function playByteArray(bytes) {
var buffer = new Uint16Array(bytes.length);
buffer.set(new Uint16Array(bytes), 0);
context.decodeAudioData(buffer.buffer, play);
}
function play(audioBuffer) {
var source = context.createBufferSource();
source.buffer = audioBuffer;
source.connect(context.destination);
source.start(0);
}